Skip to Content
EnglishEmbedding API

Embeddings API

The Embeddings API converts text into high-dimensional vector representations for semantic search, text similarity calculation, clustering analysis, and other applications.

Endpoint

POST https://aiapi.services/v1/embeddings

Authentication

All requests must include your API key in the HTTP header:

Authorization: Bearer YOUR_API_KEY

Supported Models

Embedding Models

  • text-embedding-004 - 4th generation text embedding model for semantic search and vector representation

See Available Models for complete model list.

Request Parameters

Required Parameters

ParameterTypeDescription
modelstringModel ID to use, e.g., text-embedding-3-small
inputstring/arrayText to convert to vectors, can be a single string or array of strings

Optional Parameters

ParameterTypeDefaultDescription
encoding_formatstringfloatReturn format: float or base64
dimensionsinteger-Output vector dimensions (supported by some models only)
userstring-Unique identifier for end user

Code Examples

curl https://aiapi.services/v1/embeddings \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "text-embedding-3-small", "input": "Artificial intelligence is transforming the world" }'

Response Format

Success Response

{ "object": "list", "data": [ { "object": "embedding", "index": 0, "embedding": [ -0.006929283, // Dimension 1 -0.005336422, // Dimension 2 0.024047505, // Dimension 3 // ... total 1536 dimensions (text-embedding-3-small) ] } ], "model": "text-embedding-3-small", "usage": { "prompt_tokens": 8, // Input tokens consumed "total_tokens": 8 // Total tokens consumed } }

Response Fields

FieldTypeDescription
objectstringFixed value "list"
dataarrayArray of embedding vectors, one per input text
data[].objectstringFixed value "embedding"
data[].indexintegerIndex of input text in batch request (starting from 0)
data[].embeddingarray[float]Float vector, dimensions depend on model:
• text-embedding-3-small: 1536 dimensions
• text-embedding-3-large: 3072 dimensions
• text-embedding-004: 768 dimensions
modelstringActual model name used
usage.prompt_tokensintegerNumber of tokens consumed by input text
usage.total_tokensintegerTotal tokens consumed (for embedding API, equals prompt_tokens)

Vector Dimensions

Different models return different dimensional vectors:

ModelDimensionsUse Case
text-embedding-3-small1536General embeddings, cost-effective
text-embedding-3-large3072High-precision embeddings, more accurate
text-embedding-004768Google’s text embedding model
text-embedding-ada-0021536Classic model, backward compatible

Error Response

When requests fail, standard error format is returned. See Error Handling documentation for details.

{ "code": "invalid_request_error", "message": "Invalid parameter: input text too long", "data": null }
Last updated on