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

# Embeddings

> POST /v1/embeddings — text embedding vectors

Convert text into high-dimensional vectors for semantic retrieval, clustering, recommendation and more.

## Request

```bash theme={null}
curl https://openp.ai/v1/embeddings \
  -H "Authorization: Bearer $OPENPAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "text-embedding-3-small",
    "input": ["hello world", "你好世界"]
  }'
```

### Parameters

| Field             | Type            | Required | Description                                                  |
| ----------------- | --------------- | :------: | ------------------------------------------------------------ |
| `model`           | string          |     ✅    | Embedding model ID                                           |
| `input`           | string \| array |     ✅    | A single string or an array                                  |
| `encoding_format` | string          |          | `float` (default) or `base64`                                |
| `dimensions`      | integer         |          | Truncate to a specified dimension (text-embedding-3-\* only) |
| `user`            | string          |          | End-user identifier                                          |

### Recommended models

| Model ID                 | Dimensions             | Notes                    |
| ------------------------ | ---------------------- | ------------------------ |
| `text-embedding-3-small` | 1536 (reducible ≥ 512) | Default recommendation   |
| `text-embedding-3-large` | 3072 (reducible ≥ 256) | High quality             |
| `text-embedding-ada-002` | 1536                   | Older                    |
| `text-embedding-004`     | 768                    | Google                   |
| `bge-m3`                 | 1024                   | Multilingual open-source |
| `text-embedding-v3`      | 1024                   | Tongyi Qianwen           |

## Response

```json theme={null}
{
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "index": 0,
      "embedding": [0.0023, -0.018, ...]
    },
    {
      "object": "embedding",
      "index": 1,
      "embedding": [0.0021, -0.015, ...]
    }
  ],
  "model": "text-embedding-3-small",
  "usage": {"prompt_tokens": 5, "total_tokens": 5}
}
```

## Python example

```python theme={null}
from openai import OpenAI
client = OpenAI(api_key="sk-...", base_url="https://openp.ai/v1")

resp = client.embeddings.create(
    model="text-embedding-3-small",
    input=["hello", "world"],
)
import numpy as np
vecs = np.array([e.embedding for e in resp.data])
# cosine similarity
sim = vecs @ vecs.T / (np.linalg.norm(vecs, axis=1)[:, None] * np.linalg.norm(vecs, axis=1)[None, :])
```

## Dimension truncation

```json theme={null}
{
  "model": "text-embedding-3-large",
  "input": "hello",
  "dimensions": 256
}
```

Truncated vectors preserve semantics while using less memory / compute.

## Billing

Charged by `prompt_tokens` only — **no output tokens**. See [Billing](/en/pricing/billing).
