Embeddings
Endpoint
Section titled “Endpoint”POST /v1/embeddingsRequest body
Section titled “Request body”| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Embedding model ID (e.g. text-embedding-3-small) |
input | string or array | Yes | Text to embed (string or array of strings) |
Example
Section titled “Example”curl https://api.cheapestinference.com/v1/embeddings \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "text-embedding-3-small", "input": "The quick brown fox jumps over the lazy dog" }'Python
Section titled “Python”response = client.embeddings.create( model="text-embedding-3-small", input="The quick brown fox jumps over the lazy dog")print(response.data[0].embedding[:5]) # first 5 dimensionsBatch embeddings
Section titled “Batch embeddings”response = client.embeddings.create( model="text-embedding-3-small", input=[ "First document", "Second document", "Third document" ])# response.data[0].embedding, response.data[1].embedding, ...Response
Section titled “Response”{ "object": "list", "data": [ { "object": "embedding", "index": 0, "embedding": [0.0023, -0.0091, 0.0152, ...] } ], "model": "text-embedding-3-small", "usage": { "prompt_tokens": 9, "total_tokens": 9 }}Available embedding models
Section titled “Available embedding models”| Model ID | Dimensions |
|---|---|
text-embedding-3-small | 1536 |
text-embedding-3-large | 3072 |