Embeddings

POST /v1/embeddings

Always served by the local pool, OpenRouter has no embeddings offering, so there is no cloud path for this endpoint. model is checked against the gateway’s embedding model list specifically (nomic-embed-text by default), not against the chat model list, so sending a chat model id here is rejected rather than forwarded upstream to fail confusingly.

Request body

FieldTypeRequired
modelstringyes, e.g. nomic-embed-text
inputstring or string[]yes
curl https://ai.rcfi.co.ke/v1/embeddings \
  -H "Authorization: Bearer tak_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "nomic-embed-text",
    "input": ["County governments must submit budget estimates by...", "The Controller of Budget approves..."]
  }'

Response

{
  "object": "list",
  "data": [
    { "object": "embedding", "index": 0, "embedding": [0.0123, -0.0451, "…"] },
    { "object": "embedding", "index": 1, "embedding": [0.0087, 0.0219, "…"] }
  ],
  "model": "nomic-embed-text",
  "usage": { "prompt_tokens": 26, "total_tokens": 26 }
}

Errors

400 empty_input (input resolves to an empty list), 400 model_not_allowed / 403 model_not_allowed, 400 context_length_exceeded (checked per input string, not summed across the batch), 502 upstream_error.

See Building a knowledge base for a full embed-then-retrieve walkthrough using this endpoint.