Embeddings

Turn text into vectors for search, RAG, and clustering.

On this page

Embeddings#

POST https://cleanapis.com/v1/embeddings

Embeddings convert text into numeric vectors, so semantically similar text ends up close together. They power semantic search, retrieval-augmented generation, clustering, and deduplication.

Request#

Field Type Required Description
model string Yes An embedding model ID
input string|array Yes Text, or an array of texts (max 2048)
encoding_format string No float (default) or base64
dimensions int No Reduce output dimensionality, if the model allows

Single input#

curl https://cleanapis.com/v1/embeddings \
  -H "Authorization: Bearer cc_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "your-embedding-model",
    "input": "The quick brown fox"
  }'
{
  "object": "list",
  "data": [{
    "object": "embedding",
    "index": 0,
    "embedding": [0.0023, -0.0091, 0.0142, "..."]
  }],
  "model": "your-embedding-model",
  "usage": { "prompt_tokens": 5, "total_tokens": 5 }
}

Batch input#

Send an array to embed many texts in one request — far faster than looping.

{
  "model": "your-embedding-model",
  "input": [
    "First document",
    "Second document",
    "Third document"
  ]
}

Results come back in data, each with an index matching the position of its input. Ordering is guaranteed.

Python#

from openai import OpenAI

client = OpenAI(api_key="cc_your_key_here", base_url="https://cleanapis.com/v1")

response = client.embeddings.create(
    model="your-embedding-model",
    input=["First document", "Second document"],
)

for item in response.data:
    print(item.index, len(item.embedding))

Notes#

  • Embeddings bill on input tokens only; there are no completion tokens.
  • Batch size is capped at 2048 inputs; larger batches return 422.
  • Use GET /models and filter on "type": "embedding" to find available models.

Still stuck?

Open a support ticket from your dashboard and we'll take a look.

Get help