Embeddings¶
Generate vector embeddings for text input. Use embeddings for semantic search, clustering, classification, and RAG (Retrieval-Augmented Generation).
Endpoint¶
Request Body¶
| Parameter | Type | Required | Description |
|---|---|---|---|
model |
string | ✅ | Embedding model ID (e.g. text-embedding-3-small, text-embedding-3-large, text-embedding-ada-002) |
input |
string/array | ✅ | Text to embed. Can be a single string or array of strings for batch processing. |
encoding_format |
string | float (default) or base64 |
|
dimensions |
integer | Output dimensions (for models that support it, like text-embedding-3-*) |
Example¶
Response¶
{
"object": "list",
"data": [
{
"object": "embedding",
"index": 0,
"embedding": [0.0023, -0.0091, 0.0152, ...]
}
],
"model": "text-embedding-3-small",
"usage": {
"prompt_tokens": 9,
"total_tokens": 9
}
}
Batch Embedding¶
Send multiple texts at once for efficiency:
{
"model": "text-embedding-3-small",
"input": [
"First document to embed",
"Second document to embed",
"Third document to embed"
]
}
Each text gets its own entry in data[], ordered by index.