Cheap model fallback for Claude Code 核验日期 2026-09-17
Most agent tokens don't need a frontier model. Plan-then-execute keeps the flagship for architecture and hands the grunt work — file edits, boilerplate, docstrings, test scaffolding — to a flash-tier model that costs1–3% as much. Here's how to wire a cheap second model into each agent.
Why fallback saves so much
Interactive coding agents burn a large share of tokens on mechanical steps. Claude Code in particular also runs a background "small fast" model for sub-tasks — and it happily inherits your expensive default if you don't override it. Verified price spread for the same "smart enough" work (per 1M tokens, in/out):
| Provider | Model | Input $/1M | Cache read $/1M | Output $/1M | Good as |
|---|---|---|---|---|---|
| DeepSeek | DeepSeek V4.1 Flash | $0.3 | $0.006 | $1.2 | Fallback or heavy lifting |
| Z.ai (Zhipu GLM) | GLM-5.3 | $1.4 | $0.26 | $4.4 | Fallback or heavy lifting |
| Z.ai (Zhipu GLM) | GLM-5.3-Flash | $0.15 | $0.03 | $0.5 | Primary daily driver / fallback |
| Z.ai (Zhipu GLM) | GLM-4.7 | $0.6 | $0.11 | $2.2 | Fallback or heavy lifting |
| Z.ai (Zhipu GLM) | GLM-4.7-Flash | Free | Free | Free | Primary daily driver / fallback |
| Moonshot AI (Kimi) | Kimi K2.6 | $0.95 | $0.16 | $4 | Fallback or heavy lifting |
| SiliconFlow | DeepSeek-V4-Flash | $0.13 | $0.028 | $0.28 | Primary daily driver / fallback |
| SiliconFlow | GLM-5.3 | $1.4 | $0.26 | $4.4 | Fallback or heavy lifting |
| SiliconFlow | GLM-5.3-Flash | $0.15 | $0.03 | $0.5 | Primary daily driver / fallback |
| SiliconFlow | Kimi-K2.6 | $0.77 | $0.14 | $3.4 | Fallback or heavy lifting |
| SiliconFlow | MiniMax-M2.5 | $0.3 | $0.03 | $1.2 | Fallback or heavy lifting |
| OpenRouter | DeepSeek V4 Flash (deepseek-v4-flash) | $0.07 | $0.014 | $0.14 | Primary daily driver / fallback |
| Anthropic | Claude Sonnet 5 (baseline) | $2.00 | $0.20 | $10.00 | Architecture, reviews, hard debugging |
Pattern 1 — Claude Code: two shells, two models
Claude Code reads its endpoint from env vars at launch, so the simplest robust fallback is two profiles:
# ~/.bashrc — flagship profile (default)
alias cc-max='ANTHROPIC_BASE_URL="https://api.z.ai/api/anthropic" \
ANTHROPIC_AUTH_TOKEN="YOUR_ZAI_KEY" ANTHROPIC_MODEL="glm-5.3" claude'
# ~/.bashrc — cheap fallback profile
alias cc-cheap='ANTHROPIC_BASE_URL="https://api.siliconflow.com/" \
ANTHROPIC_AUTH_TOKEN="YOUR_SF_KEY" ANTHROPIC_MODEL="DeepSeek-V4-Flash" \
ANTHROPIC_SMALL_FAST_MODEL="GLM-5.3-Flash" claude'Within one session you can also steer manually: keep the cheap endpoint as default and promote hard problems to the flagship profile only when the first attempt stalls. The split typically lands 70–90% of tokens on the cheap model.
Pattern 2 — Codex CLI: provider profiles in config.toml
# ~/.codex/config.toml — switch with: codex --profile cheap
[profiles.cheap]
model = "DeepSeek-V4-Flash"
model_provider = "siliconflow"
[profiles.max]
model = "glm-5.3"
model_provider = "zai"
model_catalog_json = "~/.codex/models.json" # GLM metadata, see Z.ai Codex guide
[model_providers.siliconflow]
name = "SiliconFlow"
base_url = "https://api.siliconflow.com/v1"
env_key = "SILICONFLOW_API_KEY"
wire_api = "responses"
[model_providers.zai]
name = "Z.ai GLM"
base_url = "https://api.z.ai/api/v1"
env_key = "ZAI_API_KEY"
wire_api = "responses"Pattern 3 — Cline: per-task model override
Cline lets you switch the model in the settings panel between tasks. Keep two saved configurations — SiliconFlow DeepSeek-V4-Flash for “Act” mode bulk edits, GLM-5.3 for “Plan” mode reasoning (values in /configs).
Verdict
- Default tier: GLM-5.3-Flash ($0.15/$0.50) or DeepSeek-V4-Flash on SiliconFlow ($0.13/$0.28) — both handle routine agent work at 1–3% of Sonnet 5's cost.
- Escape hatch: keep a flagship profile one alias away for reviews and gnarly bugs.
- Free tier exists: GLM-4.7-Flash is listed at $0 on Z.ai — usable as an ultra-fallback for non-critical sub-tasks.
- Mind the ceiling: fallback models fail differently (weaker tool-calling, worse long-context recall). Route work by risk, not just cost.
FAQ
- Does Claude Code have a native "fallback model" setting?
- Not a cost-based one. It exposes
ANTHROPIC_MODELandANTHROPIC_SMALL_FAST_MODEL(plus per-tier defaults likeANTHROPIC_DEFAULT_SONNET_MODEL) — which is enough to run flagship + cheap in parallel via profiles. - Will a flash model break tool calling?
- No — GLM-5.3-Flash and DeepSeek-V4-Flash both support function/tool calls on their official endpoints. Quality on complex multi-step tool chains is where you'll notice the difference, not single calls.
- How do I know which share of tokens went to the cheap model?
- Check each provider's usage dashboard; if you split by profile alias, the per-key usage makes the split obvious.
- Are these numbers first-party?
- Yes — all prices on this page were read from official provider pricing pages on 2026-09-17. Unverifiable ones are marked 待核验.