Back to Blog
EnglishTutorial

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.

C
Crazyrouter Team
April 18, 2026 / 873 views
Share:
How to Use Claude Code with Crazyrouter: Base URL Setup, Model Routing, and Cost Savings

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?#

FeatureAnthropic DirectVia Crazyrouter
Claude Code works✅✅
PricingOfficial rates40-50% lower
Models availableClaude onlyClaude + GPT + Gemini + Grok + 300 more
BillingAnthropic accountUnified, one invoice
FailoverNoneAuto-failover between channels
Model switchingManual code changeChange one parameter

Setup: 3 Steps#

Step 1: Get a Crazyrouter API Key#

  1. Register at crazyrouter.com
  2. Go to Token Management
  3. Create a token — copy the sk- key

Step 2: Set Environment Variables#

bash
# 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:

bash
source ~/.bashrc  # or source ~/.zshrc

Step 3: Use Claude Code Normally#

bash
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:

bash
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#

bash
# 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:

bash
# 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):

SetupMonthly 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#

IssueSolution
ANTHROPIC_BASE_URL not recognizedMake sure you exported it and reloaded your shell
401 UnauthorizedCheck your API key is correct and has sufficient balance
Slow responsesCheck status page; try a different model
Want to use both Claude and GPTSet 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.

Implementation Guides

Related Articles

WAN 2.2 Animate API Tutorial for Developers in 2026Tutorial

WAN 2.2 Animate API Tutorial for Developers in 2026

Learn what WAN 2.2 Animate is, how it compares with other video models, and how developers can build text-to-video workflows using API-based routing.

Mar 17
OpenClaw Applications: 10+ Real-World Use Cases in 2026Tutorial

OpenClaw Applications: 10+ Real-World Use Cases in 2026

Discover 10+ OpenClaw applications from customer support automation to content creation. Learn how businesses use OpenClaw for AI-powered workflows across WhatsApp, Telegram, Discord, and more platforms.

Mar 7
How to access all AI models with single API keyTutorial

How to access all AI models with single API key

Use a model gateway to share one key across supported providers, without confusing a common endpoint with universal model access.

Oct 13
Codex CLI Installation Guide 2026: macOS, Linux, WSL, Proxies, and Dev ContainersTutorial

Codex CLI Installation Guide 2026: macOS, Linux, WSL, Proxies, and Dev Containers

Install Codex CLI across common developer environments and learn how to route AI calls through Crazyrouter.

May 25
GLM 4.6 API Guide 2026: Build Chinese-English Agents with Tool CallingTutorial

GLM 4.6 API Guide 2026: Build Chinese-English Agents with Tool Calling

A developer-focused GLM 4.6 API guide article with comparisons, code examples, pricing tradeoffs, FAQ, and a Crazyrouter workflow for production teams.

Jun 2
How to Use JEV 1.13: From Customer-Service Triage to Agent Routing, a Hands-On Test of This Low-Cost Decision ModelTutorial

How to Use JEV 1.13: From Customer-Service Triage to Agent Routing, a Hands-On Test of This Low-Cost Decision Model

JEV 1.13 excels at turning natural language into choices, probabilities, and scores that programs can use directly. Using real-world calls for Chinese customer-service triage, refund decisions, and RAG filtering, this article explains the three usage patterns—Choice, Noul, and Score—and guides you through 12 editable scenarios in the Crazyrouter JEV Decision Playground, where you can inspect results and copy API integration code.

Sep 23