Skip to main content

Embeddings API

The Embeddings API generates vector representations of text, which can be used for search, clustering, recommendations, and other natural language processing tasks.

Endpoint

POST /v1/embeddings

Request Parameters

ParameterTypeRequiredDescription
modelstringYesThe ID of the embedding model to use
inputstring/arrayYesText to embed (string or array of strings)
userstringNoUnique identifier for the end-user
encoding_formatstringNoOutput encoding format (default: 'float')
dimensionsintegerNoSpecify embedding dimensions for models that support it
cache_controlobjectNoControl caching behavior
routingobjectNoCustom routing options for this request

Basic Example

curl http://localhost:5000/v1/embeddings \
-H "Content-Type: application/json" \
-H "Authorization: Bearer condt_your_virtual_key" \
-d '{
"model": "my-embedding-model",
"input": "The quick brown fox jumps over the lazy dog"
}'

Multiple Inputs Example

curl http://localhost:5000/v1/embeddings \
-H "Content-Type: application/json" \
-H "Authorization: Bearer condt_your_virtual_key" \
-d '{
"model": "my-embedding-model",
"input": ["The quick brown fox", "jumps over the lazy dog"]
}'

Response Format

{
"object": "list",
"data": [
{
"object": "embedding",
"embedding": [0.0023064255, -0.009327292, ...],
"index": 0
}
],
"model": "my-embedding-model",
"usage": {
"prompt_tokens": 8,
"total_tokens": 8
}
}

Specifying Dimensions

Some embedding models support different dimensions:

curl http://localhost:5000/v1/embeddings \
-H "Content-Type: application/json" \
-H "Authorization: Bearer condt_your_virtual_key" \
-d '{
"model": "my-embedding-model",
"input": "The quick brown fox jumps over the lazy dog",
"dimensions": 256
}'

Conduit-Specific Extensions

Cache Control

Control the caching behavior for this specific request:

{
"model": "my-embedding-model",
"input": "The quick brown fox jumps over the lazy dog",
"cache_control": {
"no_cache": false,
"ttl": 7200
}
}

Custom Routing

Override the default routing strategy for this specific request:

{
"model": "my-embedding-model",
"input": "The quick brown fox jumps over the lazy dog",
"routing": {
"strategy": "least_cost",
"fallback_enabled": true,
"provider_override": "cohere"
}
}

Best Practices

Model Selection

Different embedding models have different characteristics:

  • Dimensions: Higher dimensions can capture more information but use more storage
  • Semantic Richness: Some models are better at capturing meaning
  • Multilingual Support: Some models handle multiple languages better
  • Speed and Cost: Smaller models are faster and cheaper

Input Truncation

Most embedding models have a token limit. When exceeded:

  • Inputs are automatically truncated
  • A warning is included in the response
  • Consider splitting long texts into smaller chunks

Embeddings Storage

When storing embeddings:

  • Use vector databases like Pinecone, Weaviate, or Milvus
  • Or use specialized libraries like FAISS or HNSWLIB
  • Store model ID with embeddings for compatibility

Error Codes

HTTP CodeError TypeDescription
400invalid_request_errorThe request was malformed
401authentication_errorInvalid or missing API key
403permission_errorThe API key doesn't have permission
404not_found_errorThe requested model was not found
429rate_limit_errorRate limit exceeded
500server_errorServer error

Next Steps