tokrouterdocs
Getting started

Anthropic protocol

Point the Anthropic SDK or Claude Code at TokRouter's /v1/messages endpoint and call any vendor's model with the same key.

.mdOpen in Claude

The gateway speaks Anthropic Messages natively (POST /v1/messages). That means the Anthropic SDK and Claude Code only need a different base URL — no adapter layer.

Anthropic Python SDK

import os
import anthropic

client = anthropic.Anthropic(
    api_key=os.environ["TOKROUTER_API_KEY"],
    base_url="https://api.tokrouter.dev",   # the SDK appends /v1/messages itself
)

msg = client.messages.create(
    model="claude-opus-5-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Explain SSE in one sentence"}],
)
print(msg.content[0].text)

TypeScript SDK

import Anthropic from '@anthropic-ai/sdk'

const client = new Anthropic({
  apiKey: process.env.TOKROUTER_API_KEY!,
  baseURL: 'https://api.tokrouter.dev',
})

Raw HTTP

curl https://api.tokrouter.dev/v1/messages \
  -H "x-api-key: $TOKROUTER_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-opus-5-5",
    "max_tokens": 512,
    "messages": [{"role": "user", "content": "Hello"}]
  }'

Both auth headers work

The Anthropic protocol uses x-api-key; the OpenAI protocol uses Authorization: Bearer. The gateway accepts either — use whichever your SDK sends by default, and do not send both.

Call other vendors with the Anthropic protocol

The model field decides the upstream vendor, independent of the inbound protocol:

msg = client.messages.create(
    model="gpt-5.4",        # Anthropic protocol → OpenAI model
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}],
)

Bridging has boundaries

Fields are interpreted as Anthropic Messages semantics and then mapped onto the target vendor. If the target model lacks a capability (vision, tool use), the gateway returns an error instead of silently degrading. See Protocol bridging.