Skip to content

Unify API

Keep your OpenAI SDK. Reach every model.

Keep your OpenAI SDK code. Change the base URL and key, and every model answers on the same request shape.

POST /api/v1/chat/completions
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"],)resp = client.chat.completions.create(removed:     model="gpt-5-mini",added:     model="    messages=[{"role": "user", "content": "Hi"}],)print(resp.choices[0].message.content)
API access starts on Go ($2/mo, or free when you donate one key to the Pool). anyrouter/free is free on Go; anyrouter/auto uses credits.

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: poolside/laguna-s-2.1
x-anyrouter-provider-chain: hagiang
x-anyrouter-credential-source: platform
x-request-id: req_7dd5cca42d4443309b205080

{
  "object": "chat.completion",
  "model": "poolside/laguna-s-2.1",
  "choices": [
    {
      "finish_reason": "stop",
      "message": {
        "content": "Hello! How can I help you today?",
        "reasoning": null,
        "refusal": null,
        "role": "assistant"
      }
    }
  ],
  "usage": {
    "prompt_tokens": 45,
    "completion_tokens": 10,
    "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.

Optional: steer the route

Nothing below is required. Each one is a single field or header on the same request, captured on prod.

  • Pick any model id

    Use owner/model from the catalog instead of a preset.

    "model": "nvidia/nemotron-3-nano-omni-30b-a3b-reasoning"
    → HTTP 200, provider-chain: hagiang
  • Pin a provider

    One header, comma-separated in order of preference.

    X-AnyRouter-Provider: hagiang,kilo
    "model": "poolside/laguna-s-2.1"
    → HTTP 200, provider-chain: hagiang
  • Order providers in the body

    The same idea as OpenRouter's provider object.

    "model": "nvidia/nemotron-3-ultra-550b-a55b"
    "provider": {"order": ["hagiang", "kilo"]}
    → HTTP 200, provider-chain: hagiang

What works

  • Streaming (SSE)
  • Tools / function calling
  • Structured output (response_format)
  • Reasoning effort
  • Image input on vision models

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