> ## Documentation Index
> Fetch the complete documentation index at: https://docs.orq.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Router.Embeddings SDK Reference

> SDK reference for the Router.Embeddings API, available in Node.js and Python.

## Router.Embeddings

### Create an Embedding

Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  from orq_ai_sdk import Orq
  import os

  with Orq(
      api_key=os.getenv("ORQ_API_KEY", ""),
  ) as orq:

      res = orq.router.embeddings.create(input=[
          "The food was delicious",
          "And the waiter was friendly",
      ], model="openai/text-embedding-3-small", orq={
          "identity": {
              "id": "contact_01ARZ3NDEKTSV4RRFFQ69G5FAV",
              "display_name": "Jane Doe",
              "email": "jane.doe@example.com",
              "metadata": [
                  {
                      "department": "Engineering",
                      "role": "Senior Developer",
                  },
              ],
              "logo_url": "https://example.com/avatars/jane-doe.jpg",
              "tags": [
                  "hr",
                  "engineering",
              ],
          },
      })

      # Handle response
      print(res)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import { Orq } from "@orq-ai/node";

  const orq = new Orq({
    apiKey: process.env["ORQ_API_KEY"] ?? "",
  });

  async function run() {
    const result = await orq.router.embeddings.create({
      input: [
        "The food was delicious",
        "And the waiter was friendly",
      ],
      model: "openai/text-embedding-3-small",
    });

    console.log(result);
  }

  run();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "input": Union[str, List[Input2]],  # required
        "model": str,  # required
        "cache": {  # optional
            "ttl": Optional[int],
            "type": Literal["exact_match"],  # required
        },
        "dimensions": Optional[int],
        "encoding_format": Optional[Literal["float", "base64"]],
        "fallbacks": {  # optional
            "model": str,  # required
        },
        "load_balancer": {  # optional
            "models": {  # required
                "model": str,  # required
                "weight": float,  # required
            },
            "type": Literal["weight_based"],  # required
        },
        "name": Optional[str],
        "orq": {  # optional
            "cache": Optional[EmbeddingCacheConfig],
            "contact": {  # optional
                "display_name": Optional[str],
                "email": Optional[str],
                "id": str,  # required
                "metadata": List[Dict[str, Any]],
                "tags": List[str],
            },
            "fallbacks": List[FallbackConfig],
            "identity": {  # optional
                "id": str,  # required
                "display_name": Optional[str],
                "email": Optional[str],
                "metadata": List[Dict[str, Any]],
                "logo_url": Optional[str],
                "tags": List[str],
            },
            "load_balancer": Optional[EmbeddingLoadBalancerConfig],
            "name": Optional[str],
            "retry": {  # optional
                "count": int,  # required
                "on_codes": List[int],  # required
            },
            "timeout": {  # optional
                "call_timeout": int,  # required
            },
        },
        "retry": {  # optional
            "count": int,  # required
            "on_codes": List[int],  # required
        },
        "timeout": {  # optional
            "call_timeout": int,  # required
        },
        "user": Optional[str],
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      cache?: {
        ttl?: number;
        type: string;  // required
      };
      dimensions?: number;
      encodingFormat?: string;
      fallbacks?: {
        model: string;  // required
      };
      input: string;  // required
      loadBalancer?: {
        models: {  // required
          model: string;  // required
          weight: number;  // required
        };
        type: string;  // required
      };
      model: string;  // required
      name?: string;
      orq?: {
        cache?: {
          ttl?: number;
          type: string;  // required
        };
        contact?: {
          displayName?: string;
          email?: string;
          id: string;  // required
          metadata?: Record<string, any>[];
          tags?: string[];
        };
        fallbacks?: {
          model: string;  // required
        };
        identity?: {
          id: string;  // required
          displayName?: string;
          email?: string;
          metadata?: Record<string, any>[];
          logoUrl?: string;
          tags?: string[];
        };
        loadBalancer?: {
          models: {  // required
            model: string;  // required
            weight: number;  // required
          };
          type: string;  // required
        };
        name?: string;
        retry?: {
          count: number;  // required
          onCodes: number[];  // required
        };
        timeout?: {
          callTimeout: number;  // required
        };
      };
      retry?: {
        count: number;  // required
        onCodes: number[];  // required
      };
      timeout?: {
        callTimeout: number;  // required
      };
      user?: string;
    }
    ```
  </CodeGroup>
</Expandable>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "data": {
            "embedding": Any,
            "index": int,
            "object": Literal["embedding"],
        },
        "model": str,
        "object": Literal["list"],
        "usage": {
            "prompt_tokens": int,
            "total_tokens": int,
        },
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      data: {
        embedding: any;
        index: number;
        object: string;
      };
      model: string;
      object: string;
      usage: {
        promptTokens: number;
        totalTokens: number;
      };
    }
    ```
  </CodeGroup>
</Expandable>
