Skip to content

Embeddings

Generate vector embeddings for text input using an OpenAI-compatible endpoint.

POST /v1/embeddings

Required capability: embeddings

Request Body

ParameterTypeRequiredDescription
modelstringYesEmbedding model identifier (e.g. text-embedding-3-small, text-embedding-ada-002).
inputstring | string[]YesThe text to embed. Can be a single string or an array of strings for batch embedding.
dimensionsintegerNoThe number of dimensions for the output embeddings. Only supported by models that allow dimensionality reduction.
encoding_formatstringNoOutput encoding: "float" (default) or "base64".
userstringNoEnd-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

FieldTypeDescription
objectstringAlways "list".
dataarrayArray of embedding objects.
data[].objectstringAlways "embedding".
data[].embeddingnumber[]The embedding vector.
data[].indexintegerIndex of the input string this embedding corresponds to.
modelstringThe model used.
usage.prompt_tokensintegerNumber of tokens in the input.
usage.total_tokensintegerTotal tokens consumed.

Example

Terminal window
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

Terminal window
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"
]
}'