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

# Embeddings

> Generate embedding vectors from text using the OpenAI-compatible embeddings API.

DeepInfra supports the OpenAI embeddings API for all [embedding models](https://deepinfra.com/models/embeddings).

The endpoint is:

```
POST https://api.deepinfra.com/v1/openai/embeddings
```

## Example

<CodeGroup>
  ```python Python theme={null}
  from openai import OpenAI

  openai = OpenAI(
      api_key="$DEEPINFRA_TOKEN",
      base_url="https://api.deepinfra.com/v1/openai",
  )

  input_text = "The food was delicious and the waiter..."
  # Or a list: ["hello", "world"]

  embeddings = openai.embeddings.create(
      model="Qwen/Qwen3-Embedding-8B",
      input=input_text,
      encoding_format="float"
  )

  print(embeddings.data[0].embedding)
  print(embeddings.usage.prompt_tokens)
  ```

  ```javascript JavaScript theme={null}
  import OpenAI from "openai";

  const openai = new OpenAI({
    baseURL: "https://api.deepinfra.com/v1/openai",
    apiKey: "$DEEPINFRA_TOKEN",
  });

  const input = "The quick brown fox jumped over the lazy dog";
  // Or an array: ["hello", "world"]

  const embedding = await openai.embeddings.create({
    model: "Qwen/Qwen3-Embedding-8B",
    input: input,
    encoding_format: "float",
  });

  console.log(embedding.data[0].embedding);
  console.log(embedding.usage.prompt_tokens);
  ```

  ```bash cURL theme={null}
  curl "https://api.deepinfra.com/v1/openai/embeddings" \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer $DEEPINFRA_TOKEN" \
    -d '{
      "input": "The food was delicious and the waiter...",
      "model": "Qwen/Qwen3-Embedding-8B",
      "encoding_format": "float"
    }'
  ```
</CodeGroup>

## Batch embeddings

Pass an array as `input` to embed multiple texts in a single request:

```python theme={null}
embeddings = openai.embeddings.create(
    model="Qwen/Qwen3-Embedding-8B",
    input=["Hello", "World", "How are you?"],
    encoding_format="float"
)

for i, item in enumerate(embeddings.data):
    print(f"Text {i}: {item.embedding[:5]}...")  # First 5 dims
```

## Supported parameters

| Parameter         | Notes                      |
| ----------------- | -------------------------- |
| `model`           | Embedding model name       |
| `input`           | String or array of strings |
| `encoding_format` | `float` only               |

## Available models

Browse [all embedding models](https://deepinfra.com/models/embeddings) — includes Qwen3 Embedding, BAAI/bge, sentence-transformers, and more.
