Skip to content

Endpoints

Embeddings

Turn text into vectors with an embedding model.

POST/v1/embeddings

Follows OpenAI's Embeddings format. Use an embedding model from /models?type=embeddings, or from GET /v1/models, which lists them with an embeddings output modality. Send the key as Authorization: Bearer sk-df-... or x-api-key.

Example

curl https://deference.si/v1/embeddings \
  -H "Authorization: Bearer $DEFERENCE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/text-embedding-3-small",
    "input": "A ledger is a list of entries."
  }'

Request body

modelstringRequired
An embedding model id.
inputstring | arrayRequired
The text to embed, or an array of strings.
encoding_formatstring
float (default) or base64.
dimensionsinteger
Output size, for models that support shortening.

Response

{
  "object": "list",
  "data": [{ "object": "embedding", "index": 0, "embedding": [0.0123, -0.0456] }],
  "model": "openai/text-embedding-3-small",
  "usage": { "prompt_tokens": 8, "total_tokens": 8 }
}

The embedding array is shortened here. Embeddings are charged for input tokens.