Claude Code + Cradler Router

How to run Claude Code on a cheaper API

Claude Code is superb — the per-token bill is not. Cradler Router is a 1:1 compatible Anthropic Messages API endpoint that runs Claude Code for about 61% less, with tool use and prompt caching intact — top up by card in about a minute.

Short answer

Claude Code talks to any Anthropic-compatible endpoint. Set ANTHROPIC_BASE_URL to Cradler Router and ANTHROPIC_AUTH_TOKENto your Router key, and Claude Code runs exactly as before — same agent loop, same tools, same caching — but billed at Router's rate, which runs about 61% below the Anthropic list price. Top up by card; no Anthropic account needed.

One command, every agent

Paste your key, copy the command, run it in a terminal. It writes the config for Claude Code, Codex, and Gemini CLI — plus OpenClaw, ZCode, and Cherry Studio when they're installed — then verifies your key against the Router. Built locally; the key never leaves this page.

npx @cradler/router-setup <your-router-key>

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.

  1. 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.

  2. 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.

  3. 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.

  4. 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-8

That 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.

ModelInput / 1MOutput / 1Mvs Anthropic
claude-opus-4-8$1.95$9.75save ~61%
claude-opus-5$1.95$9.75save ~61%
claude-opus-4-7$1.95$9.75save ~61%
claude-opus-4-6$1.95$9.75save ~61%
claude-sonnet-4-6$1.17$5.85save ~61%
claude-sonnet-5$0.78$3.90save ~61%
claude-haiku-4-5$0.39$1.95save ~61%
claude-fable-5$3.90$19.50save ~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.

The rest of what your Cradler account includes

Router makes Claude Code cheaper. The same account also gives the app you're building a full backend.

Data

Managed PostgreSQL

Auto-evolving schema. No SQL, no migrations, no ALTER TABLE.

Storage

Image / video / audio storage

Through the same SDK as your data, served fast over a global CDN.

DX

Typed TypeScript SDK

@cradler/sdk — query-builder shape your AI tool was trained on.

AI-native

MCP server

@cradler/mcp — Claude and Cursor read and write your data directly.

AI-native

Agent Skill

Drop into your AI agent; it knows how to wire Cradler in.

Frequently asked questions

Do I need an Anthropic account to use Claude Code?

No. Claude Code only needs an Anthropic-compatible endpoint and a key. Cradler Router provides that endpoint, so you point Claude Code at Router with your Cradler key and top up by card (Alipay and WeChat Pay coming soon). There is no separate Anthropic signup.

Does tool use still work when Claude Code runs through Cradler Router?

Yes. Router is a 1:1 compatible Anthropic Messages API endpoint, so Claude Code's full agent loop works: multi-turn tool calls, file reads and edits, and shell commands all pass through. We test the end-to-end tool loop against real Claude Code, not just single requests.

What about prompt caching — Claude Code relies on it heavily.

Prompt caching is preserved. Claude Code's large, repeated context hits the cache the same way it does on the first-party API, so the cost savings are real rather than being eaten by cache misses. Cached input is billed at the low cache-hit rate.

How much cheaper is it than the Anthropic API?

Every Claude model on Router — Sonnet, Opus, and Haiku alike — is priced about 61% below the Anthropic list price. For example claude-sonnet-4-6 costs $1.17/$5.85 per 1M tokens against Anthropic’s $3/$15.

Which Claude models are available?

The current lineup includes Sonnet and Opus tiers (for example claude-sonnet-4-6, claude-sonnet-5, claude-opus-4-6 through 4-8, and claude-opus-5), plus fable-5. The authoritative list is always what /v1/models returns for your key — model IDs can change as versions are added or retired, so read that endpoint rather than hard-coding a name.

How is this different from just using Cradler's database?

Cradler Router (the model gateway) and Cradler's database + file storage are two features of one account. You can use Router on its own for cheaper Claude Code access, but since you already have the account, the same project gives your app a managed PostgreSQL database and file storage with a typed SDK — no SQL, no migrations.

Keep reading

Run Claude Code for less

Create a Cradler account, get a Router key, and point Claude Code at it in two lines. Free to start — top up in your own currency.