Skip to content

Unify API

Keep your Anthropic SDK. Reach every model.

Point the Anthropic SDK or Claude Code at AnyRouter and send Messages requests to any model.

POST /api/v1/messages
import osimport anthropicclient = anthropic.Anthropic(removed:     api_key=os.environ["ANTHROPIC_API_KEY"],added:     base_url="https://anyrouter.dev/api",added:     api_key=os.environ["ANYROUTER_API_KEY"],)msg = client.messages.create(removed:     model="claude-sonnet-4-5",added:     model="    max_tokens=1024,    messages=[{"role": "user", "content": "Hi"}],)for block in msg.content:    if block.type == "text":        print(block.text)
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_f8392517f9f140c08a2b1562

{
  "type": "message",
  "model": "poolside/laguna-s-2.1",
  "content": [
    {
      "type": "text",
      "text": "Hello! How can I help you today?"
    }
  ],
  "stop_reason": "end_turn",
  "usage": {
    "input_tokens": 45,
    "output_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: kilo
  • 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
  • Extended thinking
  • 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