> ## 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.

```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")

    # 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();
```

**Parameters**

```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
    "input": Union[str, List[CreateEmbeddingInput2]],  # required
    "model": str,  # required
    "cache": {  # optional
        "ttl": Optional[int],
        "type": Literal["exact_match"],  # required
    },
    "dimensions": Optional[int],
    "encoding_format": Optional[Literal["float", "base64"]],
    "fallback_on_codes": List[int],  # optional
    "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]],  # optional
            "tags": List[str],  # optional
        },
        "fallbacks": List[FallbackConfig],  # optional
        "identity": {  # optional
            "display_name": Optional[str],
            "email": Optional[str],
            "id": str,  # required
            "metadata": List[Dict[str, Any]],  # optional
            "tags": List[str],  # optional
        },
        "load_balancer": Optional[EmbeddingLoadBalancerConfig],
        "name": Optional[str],
        "retry": {  # optional
            "count": int,  # required
            "on_codes": List[int],  # optional
        },
        "timeout": {  # optional
            "call_timeout": int,  # required
        },
    },
    "retry": {  # optional
        "count": int,  # required
        "on_codes": List[int],  # optional
    },
    "timeout": {  # optional
        "call_timeout": int,  # required
    },
    "user": Optional[str],
}
```

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

**Response**

```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: "embedding";
  }[];
  model: string;
  object: "list";
  usage: {
    promptTokens: number;
    totalTokens: number;
  };
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.