Use Claude Code through TrustedRouter
Keep the same Claude Code with one TrustedRouter key, Claude models from multiple providers, and per-key spend caps. Connect through the Anthropic Messages API with two environment variables.One key, Claude models, and per-key spend caps.
Up to 1 million free tokens. No card required.
This path serves Claude models only. For other models in a coding agent, use OpenCode.
Set it up
export ANTHROPIC_BASE_URL="https://api.trustedrouter.com"
export ANTHROPIC_AUTH_TOKEN="$TRUSTEDROUTER_API_KEY"
Create a key in Console → API Keys and set TRUSTEDROUTER_API_KEY before running these exports. The base URL has no /v1: Claude Code appends /v1/messages. See Claude Code's gateway documentation.
Then pin the models. TrustedRouter model IDs carry the anthropic/ prefix, so the IDs Claude Code sends by default, such as claude-sonnet-4-6, are not accepted.
export ANTHROPIC_DEFAULT_OPUS_MODEL="anthropic/claude-opus-5.5"
export ANTHROPIC_DEFAULT_SONNET_MODEL="anthropic/claude-sonnet-5.5"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="anthropic/claude-haiku-5.5"
export ANTHROPIC_DEFAULT_FABLE_MODEL="anthropic/claude-fable-5.2"
These set what Claude Code's model aliases resolve to, including the default model and background tasks. To choose the session's model, keep the pins and also set ANTHROPIC_MODEL, or start with claude --model, and a listed ID.
Run /status in Claude Code to confirm the Anthropic base URL in use. To keep the setup across terminals, put the same variables in the env block of ~/.claude/settings.json, with the key itself as the token value.
curl https://api.trustedrouter.com/v1/messages \
-H "Authorization: Bearer $TRUSTEDROUTER_API_KEY" \
-H "Content-Type: application/json" \
-H "anthropic-version: 2023-06-01" \
-d '{"model":"anthropic/claude-haiku-5.5","messages":[{"role":"user","content":"Reply with PONG only."}],"max_tokens":16}'
The response should contain PONG.
Which Claude models
| Model ID | Input / 1M | Output / 1M | Context | Providers |
|---|---|---|---|---|
anthropic/claude-haiku-5.5 | $0.1055 | $0.5275 | 1,000,000 tokens | 2 |
anthropic/claude-haiku-4.5 | $1.055 | $5.275 | 200,000 tokens | 1 |
anthropic/claude-sonnet-5 | $2.11 | $10.55 | 1,000,000 tokens | 2 |
anthropic/claude-sonnet-5.5 | $2.11 | $10.55 | 1,000,000 tokens | 2 |
anthropic/claude-sonnet-4.5 | $3.165 | $15.825 | 1,000,000 tokens | 1 |
anthropic/claude-sonnet-4.6 | $3.165 | $15.825 | 1,000,000 tokens | 2 |
anthropic/claude-opus-5.5 | $4.22 | $21.10 | 1,000,000 tokens | 2 |
anthropic/claude-opus-4.5 | $5.275 | $26.375 | 200,000 tokens | 1 |
anthropic/claude-opus-4.6 | $5.275 | $26.375 | 1,000,000 tokens | 1 |
anthropic/claude-opus-4.7 | $5.275 | $26.375 | 1,000,000 tokens | 1 |
anthropic/claude-opus-4.8 | $5.275 | $26.375 | 1,000,000 tokens | 2 |
anthropic/claude-opus-5 | $5.275 | $26.375 | 1,000,000 tokens | 1 |
anthropic/claude-fable-5.2 | $8.44 | $42.20 | 1,000,000 tokens | 1 |
anthropic/claude-fable-5 | $10.55 | $52.75 | 1,000,000 tokens | 1 |
anthropic/claude-fable-5.1 | $10.55 | $52.75 | 1,000,000 tokens | 1 |
USD per million tokens, including the 5.5% fee. Each row uses the provider with the lowest cost for the example below, at 20,000 input tokens per request; provider choice and longer prompts can change the rate.
What a session costs
$0.13 for the cheapest listed Claude in this example: anthropic/claude-haiku-5.5; $5.28 for the newest listed Opus, anthropic/claude-opus-5.5.
Assume 50 requests, each with 20,000 uncached input tokens and 1,000 output tokens: 1.00 million input and 0.05 million output tokens in total.
anthropic/claude-haiku-5.5: (1.00 × $0.1055) + (0.05 × $0.5275) = $0.13.
anthropic/claude-opus-5.5: (1.00 × $4.22) + (0.05 × $21.10) = $5.28.
This is an illustrative session with no cached input, rounded to cents. A real session varies with how much context Claude Code re-sends, tool results and output; cached input settles at the route's cache price when the provider publishes one.
Limits
Claude models only: POST /v1/messages accepts the listed Messages-compatible Claude models. For other models in a coding agent, use OpenCode.
Claude Code's own tools, such as reading and editing files and running commands, work as usual. Tools that run on the provider's side, such as web search, are not passed through on this path yet. The setup above is served on the default API host, api.trustedrouter.com.
Cap what an agent can spend with a dedicated key and daily, weekly or monthly USD limits. Set budget_strict: true and budget_alert_only: false when creating the key to include outstanding estimates in enforcement; actual charges can exceed estimates.
Prompt caching preserves Anthropic content blocks and cache_control on /v1/messages. Read who can see your data for the data-access boundaries.
Questions
How do I point Claude Code at a gateway, proxy or router?
Set ANTHROPIC_BASE_URL to https://api.trustedrouter.com and ANTHROPIC_AUTH_TOKEN to your TrustedRouter API key. Then pin the model aliases (ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL, ANTHROPIC_DEFAULT_HAIKU_MODEL and ANTHROPIC_DEFAULT_FABLE_MODEL), and ANTHROPIC_MODEL if you set one, to listed IDs, which carry the anthropic/ prefix.
What ANTHROPIC_BASE_URL should Claude Code use?
Use ANTHROPIC_BASE_URL=https://api.trustedrouter.com without /v1; the client appends /v1/messages. Set ANTHROPIC_AUTH_TOKEN to your TrustedRouter key, and pin the model aliases and ANTHROPIC_MODEL to listed IDs with the anthropic/ prefix.
Can I set a Claude Code spend limit per key?
Yes: use a dedicated TrustedRouter key as ANTHROPIC_AUTH_TOKEN with daily, weekly or monthly limits. Strict mode includes outstanding estimates; actual charges can exceed estimates.
What does Claude Code cost per session?
Add up the input and output tokens of every request in the session and multiply by the model's price per million. The guide works an example of 50 requests at current prices for the cheapest listed Claude model and the newest Opus; listed prices already include the 5.5% fee. Usage is metered against the key set in ANTHROPIC_AUTH_TOKEN.