Embeddings

Generate vector embeddings for search, clustering, and semantic retrieval.

POST/v1/embeddings
NameTypeRequiredDescription
model
stringRequiredEmbedding model ID
input
string | string[] | image_url object[]RequiredText inputs; cohere/embed-v4 also accepts image_url objects as individual inputs
encoding_format
stringfloat (default) or base64
dimensions
integerOptional output dimension reduction when model supports it

Examples

Use a currently listed embedding model; the response values below are illustrative. Verify model availability and supported dimensions for your account.

cURL
curl https://api.therouter.ai/v1/embeddings \
  -H "Authorization: Bearer $THEROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "zhipu/embedding-3",
    "input": ["therouter docs", "routing and fallbacks"]
  }'
embeddings-response.json
{
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "index": 0,
      "embedding": [0.0123, -0.0488, 0.1932, -0.0157]
    },
    {
      "object": "embedding",
      "index": 1,
      "embedding": [0.0099, -0.0311, 0.1641, -0.0214]
    }
  ],
  "model": "zhipu/embedding-3",
  "usage": {
    "prompt_tokens": 8,
    "total_tokens": 8
  }
}
Batching
Use array input to batch related records in one request. The output order matches input order by index.

Cohere Embed v4 image inputs

Use an image_url object for an image. A plain URL string is embedded as text. The URL may be an HTTPS/HTTP image URL, a base64 data URI, or a file ID returned by /v1/files for the same tenant. The gateway handles all three through its resource layer.

bash
curl https://api.therouter.ai/v1/embeddings   -H "Authorization: Bearer $THEROUTER_API_KEY"   -H "Content-Type: application/json"   -d '{
    "model": "cohere/embed-v4",
    "input": [{"type":"image_url","image_url":{"url":"https://httpbin.org/image/png"}}],
    "input_type": "search_document",
    "dimensions": 256
  }'
Input and output
PNG, JPEG, GIF and WebP are supported, up to 5 MB per image and 96 input items per request. Strings and image objects may share an array; each item produces its own vector in order. Fused text-image items and PDF inputs are not supported. Dimensions are 256, 512, 1024 or 1536 (default 1536). Set input_type to search_document (default), search_query, classification, or clustering. The truncate field is not currently forwarded.
Image usage and pricing
TheRouter's image embedding platform price is $0.47 per million image tokens; no additional margin applies to this image rate. The response's usage.image_tokens is included in usage.prompt_tokens. For image-containing requests, Bedrock reports the input token counts. Text-only Cohere requests currently use a character-based token estimate.
Help & contact