Skip to main content

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

ParameterTypeRequiredDescription
modelstringYesThe ID of the model to use
inputstring or arrayYesInput text to embed
encoding_formatstringNoThe 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

ModelDescriptionDimensions
fluence-embeddingGeneral purpose embeddings1536
fluence-embedding-largeLarge embeddings for complex tasks3072

Use Cases

  1. Semantic Search
  2. Text Classification
  3. Clustering
  4. Recommendation Systems
  5. Question Answering

Best Practices

  1. Batch your requests when possible
  2. Cache embeddings for frequently used text
  3. Consider the dimensionality of your embeddings
  4. Normalize embeddings before comparison
  5. Use appropriate distance metrics

Error Codes

Status CodeError CodeDescription
400invalid_requestThe request was invalid
401authentication_errorAuthentication failed
429rate_limit_exceededRate limit exceeded
500server_errorInternal server error

Rate Limits

  • 100 requests per minute
  • 1000 requests per hour