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

ModelInput $/1MCache read $/1MOutput $/1MEst. 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):

ProviderModelInput $/1MCache read $/1MOutput $/1MSame-usage est.vs Sonnet 5
DeepSeekDeepSeek V4.1 Flash$0.3$0.006$1.2$813% of cost
Z.ai (Zhipu GLM)GLM-5.3$1.4$0.26$4.4$3860% of cost
Z.ai (Zhipu GLM)GLM-5.3-Flash$0.15$0.03$0.5$47% of cost
Z.ai (Zhipu GLM)GLM-4.7$0.6$0.11$2.2$1727% of cost
Moonshot AI (Kimi)Kimi K2.6$0.95$0.16$4$2945% of cost
SiliconFlowDeepSeek-V4-Flash$0.13$0.028$0.28$35% of cost
SiliconFlowGLM-5.3$1.4$0.26$4.4$3860% of cost
SiliconFlowGLM-5.3-Flash$0.15$0.03$0.5$47% of cost
SiliconFlowKimi-K2.6$0.77$0.14$3.4$2438% of cost
OpenRouterDeepSeek V4 Flash (deepseek-v4-flash)$0.07$0.014$0.14$23% of cost
OpenRouterDeepSeek V3.2 (deepseek-chat)$0.2574待核验$1.0287$1117% of cost

Verdict

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 (optionally ANTHROPIC_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 待核验.