Create Embeddings

Generate embedding vectors for one or many text inputs.

POST/v1/embeddings

Request Parameters

NameTypeRequiredDescription
model
stringRequiredEmbedding model identifier.
input
string | string[]RequiredInput text or array of text strings. Arrays support up to 2,048 items.
encoding_format
stringOutput format: float or base64.
dimensions
integerOptional reduced dimensions when supported.
user
stringUnique identifier for the end-user. Forwarded to the provider.

Request Example

bash
curl -X POST https://api.therouter.ai/v1/embeddings \
  -H "Authorization: Bearer $THEROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "zhipu/embedding-3",
    "input": ["therouter", "routing"]
  }'

Cohere Embed v4 images

Use an image_url object, not a URL string. The URL may be a public image URL, a base64 data URI, or a file ID uploaded by the same tenant.

json
{
  "model": "cohere/embed-v4",
  "input": [{"type":"image_url","image_url":{"url":"https://httpbin.org/image/png"}}],
  "input_type": "search_document",
  "dimensions": 256
}

Images cost $0.47 per million image tokens at the TheRouter platform rate. See the embeddings reference for limits and usage details.

Response

json
{
  "object": "list",
  "data": [
    {"object": "embedding", "index": 0, "embedding": [0.012, -0.035, 0.221]},
    {"object": "embedding", "index": 1, "embedding": [0.017, -0.029, 0.198]}
  ],
  "model": "zhipu/embedding-3",
  "usage": {"prompt_tokens": 4, "total_tokens": 4}
}
Notes
Batch inputs are returned in-order using the index field.
Help & contact