Why route Claude Code at all
Claude Code is one of the best coding agents available, and it is built on the Anthropic Messages API. That API is also the expensive part of a heavy coding day — and it assumes an Anthropic account and a card that many builders outside the US do not have.
Because Claude Code reads its endpoint and key from environment variables, you can send it to a compatible gateway instead. A gateway aggregates supply and passes the same Messages API straight through, so the agent behaves identically — you only change where the request goes and what it costs.
What “1:1 compatible” has to mean
A coding agent is a strict test of a gateway. It is not enough to answer one chat request — Claude Code runs a multi-turn loop of tool calls (reading files, editing them, running commands), and it leans hard on prompt caching to keep a large repeated context affordable. Break either one and the agent either fails or gets expensive.
Cradler Router is validated against real Claude Code, end to end: the tool loop completes, and cached input is billed at the cache-hit rate rather than re-charged every turn. That is the difference between a gateway that demos and one you can code on all day.
Connecting Claude Code to Cradler Router, step by step
Two environment variables — that is the whole integration.
- 01
Create a Cradler account and get a Router key
Sign up at cradler.ai and open the Router section. Top up by card, and create an API key. The same account also runs your Cradler database and file storage.
- 02
Point Claude Code at Cradler Router
Fastest: run npx @cradler/router-setup with your key — it writes the config and verifies the key for you. Or set two environment variables manually: ANTHROPIC_BASE_URL to the Cradler Router endpoint and ANTHROPIC_AUTH_TOKEN to your Router key.
- 03
Pick a model
Run Claude Code as usual, or pass --model to choose a specific Claude model such as claude-sonnet-4-6 or claude-opus-4-8. Use /v1/models to see exactly which model IDs your key can reach.
- 04
Build — with tool use and caching working
Claude Code's agent loop, tool calls, and prompt caching all pass through unchanged. You get the same coding experience at a fraction of the per-token cost.
The configuration
Set the two variables in your shell (or your shell profile to make it permanent), then run Claude Code from the same terminal:
# Point Claude Code at Cradler Router
export ANTHROPIC_BASE_URL="https://router.cradler.ai"
export ANTHROPIC_AUTH_TOKEN="<your-router-key>"
# Run Claude Code as usual
claude
# …or pin a specific model for a session
claude --model claude-opus-4-8That is the entire change. Unset the two variables to switch back to your first-party Anthropic key at any time — nothing about your project is locked to Router.
Models and pricing
Pricing is per 1M tokens, in USD. The older Opus models are the standout value — near-Opus quality at a fraction of the first-party price. Always confirm the live list and current rates with /v1/models; model IDs and prices can change as versions are added or retired.
| Model | Input / 1M | Output / 1M | vs Anthropic |
|---|---|---|---|
| claude-opus-4-8 | $1.95 | $9.75 | save ~61% |
| claude-opus-5 | $1.95 | $9.75 | save ~61% |
| claude-opus-4-7 | $1.95 | $9.75 | save ~61% |
| claude-opus-4-6 | $1.95 | $9.75 | save ~61% |
| claude-sonnet-4-6 | $1.17 | $5.85 | save ~61% |
| claude-sonnet-5 | $0.78 | $3.90 | save ~61% |
| claude-haiku-4-5 | $0.39 | $1.95 | save ~61% |
| claude-fable-5 | $3.90 | $19.50 | save ~61% |
Gotchas worth knowing
Read the model list, don't guess it. Available model IDs are whatever /v1/modelsreturns for your key. A name from a blog post or an older doc may 404 — if a model call fails with “not found”, check the live list first.
Keep your Router key out of your repo. It is a billable credential. Put it in an environment variable or a secrets manager, not in a committed file — and rotate it if it is ever exposed.
Match the model to the job. For most coding turns, claude-sonnet-4-6 is fast and cheap; reach for an Opus model on the hard reasoning steps. Because caching is preserved, keeping one model for a whole session is cheaper than it looks.
One account, model access and a backend
Cradler Router is part of Cradler — the same account that gives your app a managed PostgreSQL database and file storage through a typed SDK, with no SQL and no migrations. So the key you use to make Claude Code cheaper is the same key that stores what Claude Code helps you build. One signup, one bill.