Embeddings API
The Embeddings API allows you to convert text into vector embeddings that can be used for various natural language processing tasks.
Create Embeddings
Endpoint
POST /v1/embeddings
Request Format
{
"model": "string",
"input": "string" | ["string"],
"encoding_format": "string"
}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | The ID of the model to use |
| input | string or array | Yes | Input text to embed |
| encoding_format | string | No | The format to return the embeddings in |
Response Format
{
"object": "list",
"data": [
{
"object": "embedding",
"embedding": [number],
"index": number
}
],
"model": "string",
"usage": {
"prompt_tokens": number,
"total_tokens": number
}
}
Example Request
curl https://api.fluence.ai/v1/embeddings \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "fluence-embedding",
"input": "The quick brown fox jumps over the lazy dog"
}'
Example Response
{
"object": "list",
"data": [
{
"object": "embedding",
"embedding": [
0.0023064255,
-0.009327292,
...
],
"index": 0
}
],
"model": "fluence-embedding",
"usage": {
"prompt_tokens": 9,
"total_tokens": 9
}
}
Supported Models
| Model | Description | Dimensions |
|---|---|---|
| fluence-embedding | General purpose embeddings | 1536 |
| fluence-embedding-large | Large embeddings for complex tasks | 3072 |
Use Cases
- Semantic Search
- Text Classification
- Clustering
- Recommendation Systems
- Question Answering
Best Practices
- Batch your requests when possible
- Cache embeddings for frequently used text
- Consider the dimensionality of your embeddings
- Normalize embeddings before comparison
- Use appropriate distance metrics
Error Codes
| Status Code | Error Code | Description |
|---|---|---|
| 400 | invalid_request | The request was invalid |
| 401 | authentication_error | Authentication failed |
| 429 | rate_limit_exceeded | Rate limit exceeded |
| 500 | server_error | Internal server error |
Rate Limits
- 100 requests per minute
- 1000 requests per hour