The Complete Guide to Every Way of Running Claude Code: Official Native, Relay, Mirror, and CCR Smart Routing
A deep guide to running Claude Code on a budget: three calling modes plus smart CCR routing to cut your API costs by up to 70%.
If you're into AI coding but keep wincing at high API bills, this article is your lifeline. Today we take a deep dive into how to use Claude Code — from the three basic invocation modes to advanced smart-routing configuration — so you enjoy powerful AI coding while cutting costs by up to 70%.
📊 Claude Code Invocation Modes at a Glance
Before diving in, here are Claude Code's "three pipes":
| Mode | Where requests land | Billing | Main pros & cons |
|---|---|---|---|
| Native (official) | Anthropic's official compute | Sonnet 4: $3/MTok input, $3.75/MTok output | ✅Highest output consistency ❌Expensive; poor connectivity from China |
| Relay (API forwarding) | Official compute, forwarded via a third party | ~0.95× official price | ✅Big cost drop ❌Depends on relay service stability |
| Mirror | Provider's own GPU cluster | Day-pass / monthly credits | ✅Lowest cost, feature-rich ❌May quietly swap in lower-tier models |
The key distinction: relay = official model + third-party channel; mirror = third-party model hosting + compatible API.
🚀 Detailed Configuration of the Three Modes
1. Native mode: for maximum stability
npm install -g @anthropic-ai/claude-code
export ANTHROPIC_AUTH_TOKEN=sk-xxx
# If you need a proxy for speed
export HTTPS_PROXY=http://127.0.0.1:7890
claude code
Best for: production environments and projects that demand top output consistency
Pros:
- 100% official model guarantee, most stable output quality
- Official SDK support, solid technical support
- Enterprise proxy configuration supported
Cons:
- Highest cost; heavy burden for long-term use
- Unstable network connectivity from within China
- Requires a foreign credit card
2. Relay mode: the best cost-quality balance
Take AnyRouter as an example
export ANTHROPIC_AUTH_TOKEN=ar_live_xxx # Get it from the AnyRouter console
export ANTHROPIC_BASE_URL=https://api.anyrouter.top/v1
claude code
Best for: individual developers and small-team projects
Pros:
- 30–70% cost reduction, excellent value
- Still official models, quality guaranteed
- Simple setup, no code changes needed
- Friendly to networks in China
Cons:
- Depends on third-party service stability
- Occasional retry latency
- Must renew promptly when a plan expires
3. Mirror mode: the ultra-cheap flexible option
Take the GAC mirror as an example
# Install the mirror CLI
curl -sL https://gac.sh/install | bash
# Use directly after buying a day/monthly pass
gac code
Best for: learning, experiments, and personal side projects
Pros:
- Lowest cost — a ¥9.9 day pass lasts all day
- Built-in extras like Plan Mode and shortcut commands
- Usually fast response
- Multiple payment methods supported
Cons:
- May quietly mix in lower-tier models like Haiku
- Quality fluctuates; needs double-checking
- Possible rate limits at peak hours
🎯 Claude Code Router: The Ultimate Smart-Routing Weapon
Here's the star: Claude Code Router (CCR), a revolutionary tool that can smartly route across the three modes above — and other LLMs too.
If flipping between the three modes feels like a chore, Claude Code Router (CCR) is your ultimate answer. Think of native, relay, and mirror as three different "water pipes," with CCR as the master valve and dispatch center controlling all of them — it can even pull in other models (DeepSeek, Kimi, Qwen, or a local Ollama model). It provides no models itself; instead, per your preset rules, it automatically dispatches Claude Code's requests across multiple LLM providers, picking the most suitable model for each scenario.
CCR's core advantages
• Multi-model smart routing: set "cheap Kimi for easy tasks, the strongest Sonnet 4 for hard ones," and even switch on the fly mid-conversation with the /model command. • Tiered cost optimization: split a complex task — "Kimi for planning, Sonnet 4 for core code generation" — and cut per-request cost by another 60–80%. • Automatic failover: when relay service A goes down, CCR automatically forwards requests to backup mirror B or official C, keeping your work uninterrupted. • Unified interface compatibility: whether the backend is Anthropic, Moonshot, DeepSeek, or local Ollama, CCR's built-in transformer plugins smooth over the API differences so you switch without noticing. • Hot-plug configuration and observability: edit the config file to add new models, no restart needed. Every request is logged, easy for debugging and cost analysis.
Installation and basic configuration
npm i -g @anthropic-ai/claude-code @musistudio/claude-code-router
ccr start # Generates the config file
A typical configuration
{
"LOG": true,
"Providers": [
{
"name": "openrouter",
"api_base_url": "https://openrouter.ai/api/v1/chat/completions",
"api_key": "sk-xxx",
"models": ["anthropic/claude-sonnet-4"],
"transformer": { "use": ["openrouter"] }
},
{
"name": "moonshot",
"api_base_url": "https://api.moonshot.cn/v1/chat/completions",
"api_key": "sk-xxx",
"models": ["moonshotai/Kimi-K2-Instruct"],
"transformer": { "use": ["openrouter","maxtoken"], "max_tokens": 16384 }
}
],
"Router": {
"default": "openrouter,anthropic/claude-sonnet-4",
"think": "moonshot,moonshotai/Kimi-K2-Instruct"
}
}
💰 Measured Cost Comparison
We used generating a full-stack To-Do List scaffold as the test case:
| Mode | Cost | Response time | Output consistency |
|---|---|---|---|
| Native Sonnet 4 | ~$0.42 | 9-12s | 100% |
| Relay (AnyRouter) | ~$0.34 | 11-16s | 100% |
| Mirror (GAC Code) | ~$0.25 | 8-25s | 95% |
| CCR smart routing | ~$0.15 | 8-15s | 98% |
Conclusion: CCR smart routing cuts cost by up to 64% while keeping output quality high!
🎨 Advanced Routing Strategies
Configure different model routes per task type:
| Sub-route | Typical task | Suggested model | Cost / 1K output tokens |
|---|---|---|---|
| think | Brainstorming / planning | Kimi K2 | $0.008 |
| code | Single-file bug fixes | Claude Haiku | $0.015 |
| build | Whole-repo refactors | Claude Sonnet-4 | $0.0375 |
| benchmark | Auto-repairs | DeepSeek R1 | $0.009 |
This tiered-down strategy makes overall cost 60–70% cheaper than using Sonnet 4 for everything.
🛠️ Troubleshooting Checklist
| Symptom | Likely cause | Fix |
|---|---|---|
all messages must have non-empty content | Provider returned an empty string | Enable the filterEmpty transformer |
Service startup timeout | Background daemon not started | Run ccr start manually |
| Tool calls not working | Model doesn't support tools | Exclude incompatible models from the config |
| Token bill spikes | Long contexts all routed to expensive models | Configure a longContext route to a cheap model |
🎯 Which Setup Fits Your Scenario
Production projects
- Recommendation: Native + CCR backup
- Setup: primarily the official API, with CCR as failover
- Fits: commercial projects demanding top stability
Personal dev / learning
- Recommendation: Relay + mirror combo
- Setup: relay for daily work, mirror for experiments
- Fits: cost-sensitive individual developers
Team collaboration
- Recommendation: CCR smart routing
- Setup: multi-provider mix, routed by task
- Fits: teams needing flexibility and cost control
🚀 Productivity Tips
- Plan Mode first: press Shift + Tab to generate an execution plan before coding — fewer rollbacks
- Prompt tuning: add "think hard" to the prompt to trigger deeper reasoning
- Watch spend: use
--show-usageto see token consumption in real time - Quality checks: under mirror mode, always run unit tests to verify generated code
- Compliance: keep an official channel as backup in production
🔮 What's Ahead
Computer Use Tool: Anthropic is expanding the beta of "computer use" — Claude Code will eventually move the mouse and open the IDE by itself, making AI coding truly end-to-end.
Plugin ecosystem: the open-source community is integrating aider, CCR, and other frameworks into VS Code, Zed, and Neovim, forming a unified plugin ecosystem.
Price wars intensify: with Moonshot Kimi K2 and the DeepSeek family joining, dynamic routing + cost probes will become standard equipment for AI coding.
💡 One-Sentence Summary
For most developers: start with relay mode to save 50%+ on cost, then layer in CCR and mirrors for traffic tiering — the most cost-effective way to run Claude Code in 2025.
Master this combo, and you get a top-tier AI coding experience while keeping costs in the most sensible range. Start now — with your next project, make AI coding both powerful and economical!
References
- Claude Code Router (CCR) GitHub repo — the open-source repo for CCR, the core tool in this article; original docs for multi-model smart routing, failover, and transformer configuration
Follow us for more hands-on AI coding tips!
Scan with WeChat to share
Screenshot or long-press the QR code to forward it
📌 Related Posts
2025 Global Payment Integration Guide: Stripe, Paddle, and Overseas Compliance Practices
Guide for Chinese devs going global: payment integration, company registration, and key bank account setup.
Claude Code Complete Guide: From Beginner to Pro with the AI Programming Power Tool
Master Claude Code: from project memory and commands to 26 core features and techniques for deep workflow integration.
Cursor's Series of "Mishaps": Model Unavailability and Pricing Issues
Cursor's regional blocks and price slashes are just the start. The real story is tightening geopolitical control, forcing top AI tools like Manus out of China.
Subscribe to Updates
Leave your email to get the latest articles and project updates — or subscribe with your favorite RSS reader
Add 0to1.site/en/rss.xml to RSS readers like Feedly or Inoreader
Comments (no account needed, anonymous welcome)
No comments yet — be the first!