# Create Embeddings

`POST https://api.vultrinference.com/v1/embeddings`

Embed text in OpenRouter's embeddings shape, which is OpenAI's with `input_type` and an `id` added.

**Batches:** Up to 2048 inputs per request. The API splits them into batches the model's engine accepts and returns the embeddings in input order.

**Queries and documents:** Instruction-aware models such as `qwen3-embedding-4b` retrieve better when queries carry an instruction. Set `input_type` to `search_query` on queries and the model's instruction is prepended; documents (`search_document`, or no `input_type`) are sent unchanged. A query that already starts with the instruction's marker (e.g. `Instruct:`) is not prefixed again. The prefix's tokens are billed.

**Long inputs:** An input longer than the model's maximum input length is truncated to it, not rejected.

## Body (application/json)

- `model` (string, required): The [embeddings model](#operation/list-models) to use.
- `input` (string or array of strings or array of integers or array of array of integers, required): A string, a list of strings, a list of token ids, or a list of token id lists. Up to 2048 inputs. Multimodal inputs are rejected.
- `encoding_format` (string): `base64` returns each embedding as base64-encoded little-endian float32 values. [default float, float, base64]
- `dimensions` (integer): Truncate embeddings to this many dimensions, for models trained to support it (e.g. Qwen3-Embedding). [at least 1]
- `input_type` (string): `search_query` (or `query`) marks the inputs as search queries, so instruction-aware models get their query instruction. Any other value, or none, sends the inputs unchanged.

## Responses

- `200`: OK (embeddings-response-payload)
- `400`: The request body is not a JSON object, the model rejected the request, or an input is longer than the model's context length (metadata.error_type context_length_exceeded) (error-payload)
- `401`: The API key is missing, unknown or not active. Send it as Authorization: Bearer <key>. (error-payload)
- `404`: Model not found (error-payload)
- `429`: Rate limit exceeded (error-payload)
- `502`: The model could not be reached or returned an unusable response (error-payload)
- `504`: The model timed out (error-payload)
- `413`: The request body is over 16 MB (error-payload)

## Example

```bash
curl https://api.vultrinference.com/v1/embeddings \
  -H "Authorization: Bearer $VULTR_INFERENCE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3-embedding-4b",
    "input": [
      "What is the capital of France?"
    ],
    "input_type": "search_query"
  }'
```

```python
import os
import requests

response = requests.post(
    "https://api.vultrinference.com/v1/embeddings",
    headers={"Authorization": f"Bearer {os.environ['VULTR_INFERENCE_API_KEY']}"},
    json={
        "model": "qwen3-embedding-4b",
        "input": [
            "What is the capital of France?",
        ],
        "input_type": "search_query",
    },
)
print(response.json())
```

```javascript
const response = await fetch("https://api.vultrinference.com/v1/embeddings", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.VULTR_INFERENCE_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "model": "qwen3-embedding-4b",
    "input": [
      "What is the capital of France?"
    ],
    "input_type": "search_query"
  }),
});
console.log(await response.json());
```
