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/embeddingsAuthentication
All requests must include your API key in the HTTP header:
Authorization: Bearer YOUR_API_KEYSupported 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
| Parameter | Type | Description |
|---|---|---|
model | string | Model ID to use, e.g., text-embedding-3-small |
input | string/array | Text to convert to vectors, can be a single string or array of strings |
Optional Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
encoding_format | string | float | Return format: float or base64 |
dimensions | integer | - | Output vector dimensions (supported by some models only) |
user | string | - | Unique identifier for end user |
Code Examples
cURL
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
| Field | Type | Description |
|---|---|---|
object | string | Fixed value "list" |
data | array | Array of embedding vectors, one per input text |
data[].object | string | Fixed value "embedding" |
data[].index | integer | Index of input text in batch request (starting from 0) |
data[].embedding | array[float] | Float vector, dimensions depend on model: • text-embedding-3-small: 1536 dimensions • text-embedding-3-large: 3072 dimensions • text-embedding-004: 768 dimensions |
model | string | Actual model name used |
usage.prompt_tokens | integer | Number of tokens consumed by input text |
usage.total_tokens | integer | Total tokens consumed (for embedding API, equals prompt_tokens) |
Vector Dimensions
Different models return different dimensional vectors:
| Model | Dimensions | Use Case |
|---|---|---|
| text-embedding-3-small | 1536 | General embeddings, cost-effective |
| text-embedding-3-large | 3072 | High-precision embeddings, more accurate |
| text-embedding-004 | 768 | Google’s text embedding model |
| text-embedding-ada-002 | 1536 | Classic 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
}Related Resources
- Authentication - Learn how to get and use API keys
- Available Models - View all supported models and pricing
- Chat API - Conversational AI interface
Last updated on