# Embeddings

> POST /v1/embeddings — text vectors for search, RAG and clustering in the OpenAI format.

`POST /v1/embeddings` returns text vectors in the OpenAI Embeddings format. It
works only with embedding models from the [catalog](https://llmbox.cc/en/docs/models).

## Request

```bash [curl]
curl https://llmbox.cc/v1/embeddings \
  -H "Authorization: Bearer $LLMBOX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/text-embedding-3-small",
    "input": ["How do I return an item?", "Delivery times within the city"]
  }'
```

```python [Python]
from openai import OpenAI

client = OpenAI(base_url="https://llmbox.cc/v1", api_key="$LLMBOX_API_KEY")
resp = client.embeddings.create(
    model="openai/text-embedding-3-small",
    input=["How do I return an item?", "Delivery times within the city"],
)
vectors = [item.embedding for item in resp.data]
```

## Response

```json
{
  "object": "list",
  "data": [
    {"object": "embedding", "index": 0, "embedding": [0.0123, -0.0456, 0.0789]},
    {"object": "embedding", "index": 1, "embedding": [0.0321, 0.0654, -0.0987]}
  ],
  "model": "openai/text-embedding-3-small",
  "usage": {"prompt_tokens": 14, "total_tokens": 14}
}
```

## Parameters

| Field | Description |
| --- | --- |
| `model` | Embedding model ID from the catalog. |
| `input` | A string, an array of strings, or pre-tokenized input (an array of numbers or an array of arrays). An empty string, an empty array, or empty items return `400`; at most 2048 inputs per request. |
| `encoding_format` | `float` (default) — an array of numbers; `base64` — the vector as a string. The OpenAI Python SDK requests `base64` itself and decodes the response. |
| `dimensions` | Vector size, if the model supports it (for example, `text-embedding-3-*`). |

Other fields are not passed to the model — see [Request parameters](https://llmbox.cc/en/docs/params).

## Cost

Only input tokens are charged: `usage.prompt_tokens` × the model's price per
1M input tokens. Embeddings have no output. Before the request, an input
estimate is reserved on your balance; if it does not fit, the request is
rejected with `402` — send fewer or shorter strings per request.

## Notes

- **The response is never streamed**; the `stream` field is ignored.
- **The model type must match the endpoint**: a text model on
  `/v1/embeddings` (or an embedding model on chat) returns `404 model_not_found`.
- The model sets the limits on the number of strings and input length;
  exceeding them returns a `400` error.
