0to1 .site

The Complete Guide to Every Way of Running Claude Code: Official Native, Relay, Mirror, and CCR Smart Routing

6 min read views
📌 Summary

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

ModeWhere requests landBillingMain pros & cons
Native (official)Anthropic's official computeSonnet 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
MirrorProvider's own GPU clusterDay-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:

ModeCostResponse timeOutput consistency
Native Sonnet 4~$0.429-12s100%
Relay (AnyRouter)~$0.3411-16s100%
Mirror (GAC Code)~$0.258-25s95%
CCR smart routing~$0.158-15s98%

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-routeTypical taskSuggested modelCost / 1K output tokens
thinkBrainstorming / planningKimi K2$0.008
codeSingle-file bug fixesClaude Haiku$0.015
buildWhole-repo refactorsClaude Sonnet-4$0.0375
benchmarkAuto-repairsDeepSeek R1$0.009

This tiered-down strategy makes overall cost 60–70% cheaper than using Sonnet 4 for everything.

🛠️ Troubleshooting Checklist

SymptomLikely causeFix
all messages must have non-empty contentProvider returned an empty stringEnable the filterEmpty transformer
Service startup timeoutBackground daemon not startedRun ccr start manually
Tool calls not workingModel doesn't support toolsExclude incompatible models from the config
Token bill spikesLong contexts all routed to expensive modelsConfigure 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

  1. Plan Mode first: press Shift + Tab to generate an execution plan before coding — fewer rollbacks
  2. Prompt tuning: add "think hard" to the prompt to trigger deeper reasoning
  3. Watch spend: use --show-usage to see token consumption in real time
  4. Quality checks: under mirror mode, always run unit tests to verify generated code
  5. 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

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

views
Share:

📌 Related Posts

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!