How to Use Claude Code with Crazyrouter: Base URL Setup, Model Routing, and Cost Savings
Switch Claude Code to Crazyrouter in minutes. Set your base URL, access multiple models through one key, reduce API cost, and keep your existing coding workflow.

How to Use Claude Code with Crazyrouter: Base URL Setup, Model Routing, and Cost Savings#
If you are already using Claude Code, switching to Crazyrouter takes about 2 minutes. You keep your existing workflow, gain access to more models, and typically reduce your API cost by 40-50%.
Why Switch Claude Code to Crazyrouter?#
| Feature | Anthropic Direct | Via Crazyrouter |
|---|---|---|
| Claude Code works | ✅ | ✅ |
| Pricing | Official rates | 40-50% lower |
| Models available | Claude only | Claude + GPT + Gemini + Grok + 300 more |
| Billing | Anthropic account | Unified, one invoice |
| Failover | None | Auto-failover between channels |
| Model switching | Manual code change | Change one parameter |
Setup: 3 Steps#
Step 1: Get a Crazyrouter API Key#
- Register at crazyrouter.com
- Go to Token Management
- Create a token — copy the
sk-key
Step 2: Set Environment Variables#
# Add to your shell profile (.bashrc, .zshrc, etc.)
export ANTHROPIC_BASE_URL=https://crazyrouter.com
export ANTHROPIC_API_KEY=sk-your-crazyrouter-key
Reload your shell:
source ~/.bashrc # or source ~/.zshrc
Step 3: Use Claude Code Normally#
claude
That's it. Claude Code will now route through Crazyrouter. Your prompts, context, and workflow stay exactly the same.
Verify It Works#
Run a quick test:
claude "What model are you and what is your base URL?"
You should see Claude respond normally. Check your Crazyrouter console logs to confirm requests are flowing through.
Advanced: Model Routing#
One of the biggest advantages of using Crazyrouter is model flexibility. You can switch between models without changing your integration.
Use Different Claude Versions#
# Default: Claude Sonnet (balanced)
export ANTHROPIC_MODEL=claude-sonnet-4-5-20250929
# For complex tasks: Claude Opus (strongest)
export ANTHROPIC_MODEL=claude-opus-4-6-20250918
# For simple tasks: Claude Haiku (fastest, cheapest)
export ANTHROPIC_MODEL=claude-haiku-4-5-20250929
Use Non-Claude Models via OpenAI Codex / Other Tools#
Since Crazyrouter supports OpenAI-compatible format too, you can also use:
# For OpenAI Codex CLI
export OPENAI_BASE_URL=https://crazyrouter.com/v1
export OPENAI_API_KEY=sk-your-crazyrouter-key
This means one Crazyrouter key powers both Claude Code and OpenAI Codex.
Cost Comparison#
For a typical developer using Claude Code moderately (about 500K tokens/day):
| Setup | Monthly Cost (est.) |
|---|---|
| Anthropic Max 5x subscription | $100/month (fixed) |
| Anthropic Max 20x subscription | $200/month (fixed) |
| Anthropic API direct | ~$60-80/month |
| Crazyrouter API | ~$30-45/month |
The savings come from Crazyrouter's lower per-token rates. For heavy users, the difference adds up fast.
Common Issues and Fixes#
| Issue | Solution |
|---|---|
ANTHROPIC_BASE_URL not recognized | Make sure you exported it and reloaded your shell |
| 401 Unauthorized | Check your API key is correct and has sufficient balance |
| Slow responses | Check status page; try a different model |
| Want to use both Claude and GPT | Set both ANTHROPIC_* and OPENAI_* env vars to Crazyrouter |
FAQ#
Does Claude Code work exactly the same through Crazyrouter?#
Yes. Same model, same capabilities, same context window. Crazyrouter proxies to the official Anthropic API.
Can I use Claude Code and OpenAI Codex with the same key?#
Yes. One Crazyrouter key works for both. Set the appropriate base URL for each tool.
Will my Claude Code settings and permissions carry over?#
Yes. Claude Code settings are local to your machine. Only the API routing changes.
Is there any latency difference?#
Minimal. Crazyrouter adds typically <50ms of routing overhead.
Can I switch back to Anthropic direct anytime?#
Yes. Just remove or change the ANTHROPIC_BASE_URL environment variable.





