Embeddings
Generate vector embeddings for text input using an OpenAI-compatible endpoint.
POST /v1/embeddingsRequired capability: embeddings
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Embedding model identifier (e.g. text-embedding-3-small, text-embedding-ada-002). |
input | string | string[] | Yes | The text to embed. Can be a single string or an array of strings for batch embedding. |
dimensions | integer | No | The number of dimensions for the output embeddings. Only supported by models that allow dimensionality reduction. |
encoding_format | string | No | Output encoding: "float" (default) or "base64". |
user | string | No | End-user identifier for abuse tracking. |
Response
{ "object": "list", "data": [ { "object": "embedding", "embedding": [0.0023064255, -0.009327292, 0.015797347, ...], "index": 0 } ], "model": "text-embedding-3-small", "usage": { "prompt_tokens": 8, "total_tokens": 8 }}Response Fields
| Field | Type | Description |
|---|---|---|
object | string | Always "list". |
data | array | Array of embedding objects. |
data[].object | string | Always "embedding". |
data[].embedding | number[] | The embedding vector. |
data[].index | integer | Index of the input string this embedding corresponds to. |
model | string | The model used. |
usage.prompt_tokens | integer | Number of tokens in the input. |
usage.total_tokens | integer | Total tokens consumed. |
Example
curl https://your-gateway.example.com/v1/embeddings \ -H "Authorization: Bearer aigw_sk_your_api_key" \ -H "Content-Type: application/json" \ -d '{ "model": "text-embedding-3-small", "input": "The quick brown fox jumps over the lazy dog" }'Batch Embedding
curl https://your-gateway.example.com/v1/embeddings \ -H "Authorization: Bearer aigw_sk_your_api_key" \ -H "Content-Type: application/json" \ -d '{ "model": "text-embedding-3-small", "input": [ "First document to embed", "Second document to embed", "Third document to embed" ] }'