Skip to content

Unify API

Keep your embeddings code. Change two lines.

Turn text into vectors with the OpenAI embeddings shape, on the same key as your chat calls.

POST /api/v1/embeddings
import osfrom openai import OpenAIclient = OpenAI(removed:     api_key=os.environ["OPENAI_API_KEY"],added:     base_url="https://anyrouter.dev/api/v1",added:     api_key=os.environ["ANYROUTER_API_KEY"],)emb = client.embeddings.create(removed:     model="text-embedding-3-small",added:     model="nvidia/nemotron-3.5-embed-1b",    input=["Hello", "world"],)print(len(emb.data[0].embedding))

nvidia/nemotron-3.5-embed-1bis served free by a platform upstream, so this runs on any key.

What came back

The cURL tab above, run on prod on 2026-10-31 with a Go key. Only the fields shown are kept, and long values are cut with "…".

captured from prod
HTTP 200
x-anyrouter-model: nvidia/nemotron-3-embed-1b
x-anyrouter-provider-chain: kilo
x-anyrouter-credential-source: platform
x-request-id: req_cf24697f3ec441879f0adb82

{
  "object": "list",
  "model": "nvidia/nemotron-3-embed-1b:free",
  "data": [
    {
      "index": 0,
      "embedding": [
        0.0022859701,
        -0.080008954,
        -0.013601524,
        "…"
      ]
    },
    {
      "index": 1,
      "embedding": [
        0.0038007896,
        -0.077580824,
        0.024034403,
        "…"
      ]
    }
  ],
  "usage": {
    "prompt_tokens": 6,
    "total_tokens": 6,
    "cost": 0
  }
}
x-anyrouter-model
The model that answered. A preset such as anyrouter/free names its pick here; pin a model id and it echoes yours.
x-anyrouter-provider-chain
Each upstream tried, in order. One hop here; when a hop fails the next one answers and the header reads a->b.
x-anyrouter-credential-source
Whose upstream key paid: platform (ours), own_byok (yours) or pool (a donated key).
x-request-id
Quote it to support, or find the request in your logs.
usage.cost
What this request cost you, in USD, in the body. Zero on free models.

What works

  • String or array input
  • float or base64 encoding_format

Decisions models

Not a chat. Send a situation and a question with fixed choices, and get a probability for each choice back. Decisions are free on Go and up, with a 5-request trial on Free.

POST /api/v1/decisions
curl https://anyrouter.dev/api/v1/decisions \
  -H "Authorization: Bearer $ANYROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "hal-x/thx-01", "state": "My card was charged twice",
    "questions": {"team": {"type": "choice", "criteria": {"billing": "Payments", "tech": "API problems"}}}}'

# {"answers": {"team": {"type": "choice", "choice": "billing", "probabilities": {"billing": 0.97, "tech": 0.03}}}, "model": "hal-x/thx-01", "status": "completed"}

Related docs and use cases

Next