Docs navigation

Migration

Migrating from Anthropic

Move Anthropic API traffic to TokenRouter with a base URL swap.

Swap the base URL and the key; everything else passes through to Claude models verbatim — tools, extended thinking, vision, system prompts, streaming.

The change

python
from anthropic import Anthropic

client = Anthropic(
-   api_key=os.environ["ANTHROPIC_API_KEY"],
+   api_key=os.environ["TOKENROUTER_API_KEY"],  # tr_...
+   base_url="https://api.tokenrouter.io",      # note: no /v1
)

message = client.messages.create(
    model="anthropic/claude-sonnet-4-5",
    max_tokens=300,
    messages=[{"role": "user", "content": "Hello via TokenRouter"}],
)
The Anthropic base URL has no /v1 suffix — Anthropic SDKs append /v1/messages themselves.

What carries over

  • Everything. Requests to Claude models are forwarded to Anthropic verbatim: tool use, extended thinking, vision, prompt caching headers, and streaming all behave identically.
  • /v1/messages/count_tokens is supported.
  • Model names keep working — claude-sonnet-4-5 as a bare alias or anthropic/claude-sonnet-4-5 explicitly.

What you gain

Budgets with hard caps per team and key, per-key rate limits, usage analytics, and the option to point the same Messages-shaped code at non-Claude models (or auto) — TokenRouter translates for other providers. Add your Anthropic key in the console under Provider Keys before cutting over.