The cheapest API for Claude Code (verified 2026-09-17)
Claude Code bills against whichever endpoint ANTHROPIC_BASE_URL points at. That single env var is the whole game: keep the agent you know, swap the model behind it. Below are the numbers — pulled from official pricing pages on 2026-09-17, not scraped from blogs.
What "first-party" Claude Code costs per month
| Model | Input $/1M | Cache read $/1M | Output $/1M | Est. heavy use (30M in / 3M out, 50% cache) |
|---|---|---|---|---|
| Claude Sonnet 5 | $2 | $0.2 | $10 | $63 |
| Claude Haiku 4.5 | $1 | $0.1 | $5 | $32 |
| Claude Opus 5 | $5 | $0.5 | $25 | $158 |
| Claude Fable 5.1 | $10 | $0.25 | $50 | $304 |
Estimate: 30M input + 3M output tokens/month with 50% cache-hit ratio. Sonnet 5's $2/$10 is now standard pricing (the introductory window ended per Anthropic's docs). Batch API is −50% but doesn't fit interactive coding.
The cheaper Anthropic-compatible routes
These providers implement the Anthropic Messages protocol directly, so Claude Code works with just a base-URL + key + model change (full snippets in /configs):
| Provider | Model | Input $/1M | Cache read $/1M | Output $/1M | Same-usage est. | vs Sonnet 5 |
|---|---|---|---|---|---|---|
| DeepSeek | DeepSeek V4.1 Flash | $0.3 | $0.006 | $1.2 | $8 | 13% of cost |
| Z.ai (Zhipu GLM) | GLM-5.3 | $1.4 | $0.26 | $4.4 | $38 | 60% of cost |
| Z.ai (Zhipu GLM) | GLM-5.3-Flash | $0.15 | $0.03 | $0.5 | $4 | 7% of cost |
| Z.ai (Zhipu GLM) | GLM-4.7 | $0.6 | $0.11 | $2.2 | $17 | 27% of cost |
| Moonshot AI (Kimi) | Kimi K2.6 | $0.95 | $0.16 | $4 | $29 | 45% of cost |
| SiliconFlow | DeepSeek-V4-Flash | $0.13 | $0.028 | $0.28 | $3 | 5% of cost |
| SiliconFlow | GLM-5.3 | $1.4 | $0.26 | $4.4 | $38 | 60% of cost |
| SiliconFlow | GLM-5.3-Flash | $0.15 | $0.03 | $0.5 | $4 | 7% of cost |
| SiliconFlow | Kimi-K2.6 | $0.77 | $0.14 | $3.4 | $24 | 38% of cost |
| OpenRouter | DeepSeek V4 Flash (deepseek-v4-flash) | $0.07 | $0.014 | $0.14 | $2 | 3% of cost |
| OpenRouter | DeepSeek V3.2 (deepseek-chat) | $0.2574 | 待核验 | $1.0287 | $11 | 17% of cost |
Verdict
- Stay on first-party Claude if: your hourly rate exceeds the API bill. Sonnet 5 at $63/month for a heavy solo workflow is cheap relative to even 30 minutes saved.
- Switch the endpoint if: you run many agents in parallel, use CI bots, or your workload is throughput-shaped. DeepSeek-V4-Flash on SiliconFlow ($0.13/$0.28) runs the same ~33M-token month for about $3.21 — roughly 5% of Sonnet 5's bill.
- Best middle path: Z.ai's GLM Coding Plan (from $18/month flat) — flat-rate pricing removes token anxiety entirely for daily drivers.
- Free exists: GLM-4.7-Flash is officially listed at $0 on Z.ai's pricing page (rate limits apply) — fine for a fallback model.
FAQ
- Do tool calls and sub-agents still work on these endpoints?
- Yes on all three routes we list — DeepSeek, Z.ai and SiliconFlow all document tool-calling support on their Anthropic-compatible endpoints. Behavior quality varies by model; test on a real branch before migrating your main workflow.
- What about prompt caching?
- All three support caching and bill cache reads far below the input rate (e.g. DeepSeek peak cache-hit $0.006/1M, Z.ai GLM-5.3 $0.26/1M). Claude Code is cache-heavy, so the savings compound.
- Is one env var really all it takes?
- For Claude Code: yes —
ANTHROPIC_BASE_URL,ANTHROPIC_AUTH_TOKEN,ANTHROPIC_MODEL(optionallyANTHROPIC_SMALL_FAST_MODEL). Exact copy-paste values are in our config generator. - Are these prices guaranteed?
- No provider guarantees prices. Everything on this page reflects official pages on 2026-09-17; re-verify before locking in a budget. Unverifiable numbers are marked 待核验.