Claude Code on Chinese Fuel: cheap LLMs via an API key

A practical How-To: which Chinese LLMs (DeepSeek, GLM, Kimi, MiniMax, Qwen, Xiaomi MiMo) actually plug into Claude Code via an Anthropic-compatible endpoint, verified pricing (June 2026), a task→model matrix, ready-made PowerShell configs, claude-code-router, and the honest line — where to keep native Claude.

Claude Code on Chinese Fuel: cheap LLMs via an API key

Claude Code counts tokens at Anthropic's rate. On a large research run that reads hundreds of sources, or on an iterative landing page rewritten twenty times, the bill grows fast — and the lion's share is eaten not by "thinking" but by volume: reading, drafts, the housekeeping calls of agents. The good news: that volume can be offloaded onto Chinese models that cost 10–50× less, without changing a single familiar step in Claude Code. The bad: there's a precisely drawn line here, and if you don't know it, the savings turn into rework.

This guide is practical. Below: how it works mechanically, which providers actually plug in (with verified pricing as of June 2026), which model to take for which task, ready-made configs for Windows, the two tactics that cut the bill the hardest, and an honest list of where you must not save.

01 · How it works: two variables

Claude Code isn't bolted to Anthropic's servers forever. It reads the backend address from the environment: ANTHROPIC_BASE_URL (where to send requests) and ANTHROPIC_AUTH_TOKEN (what to authenticate with). If a provider exposes an Anthropic-compatible endpoint — usually an address with a /anthropic suffix — you redirect the CLI to someone else's server with a single variable, and your entire workflow (agents, skills, parallel tool-use) runs without a single change in code.

Як Claude Code перемикається на китайський бекенд через дві змінні Claude Code твій звичний CLI агенти · скіли · tool-use 2 ENV-змінні ANTHROPIC_BASE_URL ANTHROPIC_AUTH_TOKEN Китайський /anthropic DeepSeek · GLM · Kimi MiniMax · Qwen · MiMo Відповідь ×10–50 дешевше МЕЖА: через /anthropic НЕ проходить — лишай на нативному Claude MCP-сервери (Notion · GitHub · Postgres · Figma) · web_search · images / скріншоти / PDF anthropic-beta · фінальна якість української · чутливі геополітичні теми (цензура)
Diagram 1. The whole trick is to redirect the CLI with two variables. The same line applies across all Chinese providers: the "trimmed" Anthropic endpoint doesn't carry MCP, web_search, images, or the sensitive stuff.

The key watershed of the entire comparison is this: DeepSeek, Zhipu GLM, Moonshot Kimi, MiniMax, Alibaba Qwen, and even Xiaomi MiMo already have an official /anthropic — they plug in within thirty seconds. But that endpoint is "trimmed" in all of them: it does not carry MCP servers, Claude Code's native web_search, images/PDF, and features behind anthropic-beta. This isn't a bug of a particular provider but a shared property — and it's exactly what determines what can be offloaded onto the cheap option and what must stay on Claude.

02 · Who actually connects and how much it costs

Below are the providers with a working /anthropic, ordered from the cheapest-and-effective. Prices verified from official documentation (June 2026), in dollars per 1M tokens.

ModelEndpointInputOutputCache-hitContextStrength
DeepSeek v4-flashapi.deepseek.com/anthropic$0.14$0.28$0.00281Mcheapest usable default
DeepSeek v4-prosame one$0.435$0.87$0.00361Mstrong reasoner (→ opus)
GLM-4.7-FlashXapi.z.ai/api/anthropic$0.07$0.40$0.01~200Kultra-cheap bulk content
GLM-4.6 / 4.7same one$0.60$2.20$0.11200Kmultilingual (UK) + tool-use
GLM-5.2same one$1.40$4.40$0.261M (opt-in)flagship-quality coding
Kimi k2.7-codeapi.moonshot.ai/anthropic$0.95$4.00$0.19262Klong-horizon agentic coding
MiniMax M2.7api.minimax.io/anthropic$0.30$1.20$0.06200Kcheap agentic coding
Qwen3-Coder-Nextdashscope…/apps/anthropic$0.30–0.80$1.50–4.00~10–20%262Kmultilingual coding
Xiaomi MiMo v2.5api.xiaomimimo.com/anthropic~$0.15~$0.29~$0.0031Mcheap 1M agent
Claude Opus / Sonnetnative$5+$25+cache_control200K+reference + MCP / web / images

Separately — subscriptions with a fixed price instead of a meter, if your load is predictable:

SubscriptionPrice / moModelFor whom
GLM Coding PlanLite $18 · Pro $72 · Max $160 (promo −30% until September 2026)glm-5.2daily coding / landing pages
MiniMax Token PlanPlus $20 · Max $50 · Ultra $120M2.xagentic sessions
Qwen Coding PlanPro $50 (Lite discontinued)qwen3.7-plusmultilingual coding

03 · Which model for which task

The main mistake is hunting for "one model for everything." The right way is to route by task type.

Яку дешеву модель під яку задачу, і що завжди лишати на Claude Маршрут за задачею Великі дослідження deep research · fan-out Лендінги ітеративний front-end Масовий контент EN / UK обсяги Агентний кодинг tool-use loops DeepSeek v4-flash $0.14 / $0.28 · 1M ctx cache-hit $0.0028 (×50) GLM Coding Plan glm-5.2 · підписка $12–72/міс фікс GLM-4.7-FlashX $0.07 / $0.40 UK краще за DeepSeek GLM Coding Plan фолбек: MiniMax M2.7 $0.30 / $1.20 Патерн NeuroDrift: масовий обсяг / чернетка → дешева модель · фінальний прохід (факт-чек, укр-полір) → Claude ЗАВЖДИ НА CLAUDE (китайський /anthropic цього не тягне) MCP-стек: Notion · GitHub · Postgres · Figma · Gmail · нативний web_search images / скріншоти / PDF · фінальна якість української · чутливі теми приватні дані клієнтів (китайські сервери = GDPR / compliance-ризик)
Diagram 2. The cheap model covers the volume; Claude stays the irreducible minimum for MCP, web_search, images, final Ukrainian, and the sensitive stuff.
TaskPrimary modelWhy / caveat
Large researchDeepSeek v4-flash (gathering/reading) → v4-pro or Claude (synthesis)1M context + cache-hit $0.0028 make bulk reading almost free. But web_search through DeepSeek doesn't work — feed sources as files / via WebFetch, keep the web phase on Claude.
Landing pagesGLM Coding Plan (glm-5.2); fallback DeepSeek v4-proA fixed subscription removes the meter anxiety while iterating. Images don't go through the endpoint → keep Figma MCP and screen-driven design on Claude.
Bulk contentEN: DeepSeek v4-flash / GLM-4.7-FlashX. UK: GLM-4.6/4.7, final — ClaudeDeepSeek is trained on EN/ZH — its Ukrainian is noticeably weaker. GLM is better multilingually. Cheap draft + Claude polish = optimum.
Agentic codingGLM Coding Plan; fallback DeepSeek v4-proBoth hold parallel tool-use well. MCP (Notion / GitHub / Postgres / Figma) does NOT work through Chinese endpoints — keep such workflows on Claude.
Ukrainian qualityClaude (final); GLM draft; avoid DeepSeek for UK outputDeepSeek's Ukrainian quality is lower (EN/ZH corpus). The Ukrainian reference is Claude. Don't cut corners here blindly.

04 · Ready-made configs (Windows / PowerShell)

Run them in a separate terminal — environment variables override settings.json, so your current native Claude session stays untouched. The "budget" profile for volume and research:

# ПРОФІЛЬ «БЮДЖЕТ» — DeepSeek (дослідження, масовий текст, scaffold)
$env:ANTHROPIC_BASE_URL             = "https://api.deepseek.com/anthropic"
$env:ANTHROPIC_AUTH_TOKEN           = "sk-<твій_deepseek_key>"
$env:ANTHROPIC_API_KEY              = ""        # ОБОВ’ЯЗКОВО порожній, не unset
$env:ANTHROPIC_DEFAULT_OPUS_MODEL   = "deepseek-v4-pro"
$env:ANTHROPIC_DEFAULT_SONNET_MODEL = "deepseek-v4-flash"
$env:ANTHROPIC_DEFAULT_HAIKU_MODEL  = "deepseek-v4-flash"
$env:CLAUDE_CODE_SUBAGENT_MODEL     = "deepseek-v4-flash"   # субагенти на найдешевшому
claude

The "coding / landing pages" profile on the fixed GLM subscription:

# ПРОФІЛЬ «КОДИНГ / ЛЕНДІНГИ» — GLM Coding Plan (фіксована підписка)
$env:ANTHROPIC_BASE_URL             = "https://api.z.ai/api/coding/paas/v4"
$env:ANTHROPIC_AUTH_TOKEN           = "<твій_zai_key>"
$env:ANTHROPIC_API_KEY              = ""
$env:ANTHROPIC_DEFAULT_OPUS_MODEL   = "glm-5.2"
$env:ANTHROPIC_DEFAULT_SONNET_MODEL = "glm-5.2"
$env:ANTHROPIC_DEFAULT_HAIKU_MODEL  = "glm-4.7"
claude

If you want automatic routing within a single session (housekeeping calls and reading — to the cheapest, the main reasoning — to a pricier one), set up claude-code-router (npm i -g @musistudio/claude-code-router, launch with ccr code):

// %APPDATA%\Claude Code Router\config.json — авто-роутинг в одній сесії
{
  "Providers": [
    { "name": "deepseek",
      "api_base_url": "https://api.deepseek.com/chat/completions",
      "api_key": "sk-...", "models": ["deepseek-v4-flash", "deepseek-v4-pro"] },
    { "name": "zai",
      "api_base_url": "https://api.z.ai/api/anthropic",
      "api_key": "...", "models": ["glm-5.2", "glm-4.7"] }
  ],
  "Router": {
    "default":     "zai,glm-5.2",          // головний reasoning
    "background":  "deepseek,deepseek-v4-flash",  // службові виклики
    "think":       "deepseek,deepseek-v4-pro",    // складні кроки
    "longContext": "deepseek,deepseek-v4-flash"   // читання великих обсягів
  }
}

05 · The two tactics that cut the bill the hardest

Дві тактики економії: кеш-префікс і конвеєр чернетка-полір Тактика 1 · Кеш-префікс (тримай незмінне зверху) system prompt · tool schema · великі незмінні файли мінливий запит ◀ кешується: cache-hit ×50 дешевше ($0.0028 vs $0.14) рахується щоразу ⚠ будь-яка зміна ВГОРІ ламає весь кеш-хвіст → незмінне на початок, мінливе вниз Тактика 2 · Конвеєр «чернетка → полір» (твій NeuroDrift-флоу) 1. ОБСЯГ дешево чернетки лонгрідів · boilerplate-лендінг читання джерел · масовий EN-текст 2. ФІНАЛ на Claude факт-чек · верифікація claims · українська дорога модель б’є лише по high-leverage кроках Економія: 90% токенів проходять дешевою моделлю, Claude торкається ~10% — там, де якість справді вирішує.
Diagram 3. The two tactics with the biggest payoff: the right prompt order (cache) and the division of labor between a cheap draft and an expensive final.

Cache prefix. Don't turn caching off. Automatic caching keeps the stable beginning of the prompt — the system prompt, the tool schema, large unchanging files — and serves it at a cache-hit price dozens of times cheaper. The practical consequence: keep the unchanging part on top, the variable part at the bottom. Any change at the start breaks the whole cache tail. Through /anthropic the cache_control headers are ignored, but caching still kicks in automatically on the provider's side — nothing extra to do.

Draft → polish. Generate the bulk volume — drafts, boilerplate, source reading — with a cheap model, and send Claude or v4-pro only on the final pass: fact-checking, claim verification, Ukrainian editing. This is classic batch economics: the expensive model strikes precisely at the steps where its quality actually changes the result.

06 · Where you must NOT save

Here savings turn into rework, because the Chinese /anthropic endpoints physically can't carry this. Switch to native Claude deliberately when the task involves:

  • MCP servers — Notion, GitHub, Postgres, Figma, Gmail. No Chinese endpoint supports them.
  • Native web_search in Claude Code.
  • Images, screenshots, PDF — "from-mockup" design, image analysis.
  • Final Ukrainian quality — flagship texts.
  • Sensitive geopolitical topics — DeepSeek / GLM / Kimi censor or refuse (Taiwan, Tiananmen, criticism of the CCP).
  • Private client data — DeepSeek and GLM store data on servers in the PRC. For GDPR / client projects this is a separate risk; split your profiles by sensitivity.

07 · Pitfalls (as of June 2026)

  • DeepSeek: the old names deepseek-chat / deepseek-reasoner are aliases for v4-flash, and they disappear on July 24, 2026. Migrate your model names before that date.
  • Kimi k2.7-code: always in "thinking" mode (thinking tokens are billed as output), plus an unresolved bug with the document block type breaks file work in Claude Code.
  • MiniMax M3: through /anthropic it returns 200K of context instead of 1M — Claude Code compacts too early; fixed with the variable CLAUDE_CODE_MAX_CONTEXT_TOKENS=1000000. The M2.x models don't accept images.
  • Qwen: Alibaba is under an Anthropic lawsuit for distilling Claude — the long-term stability of the endpoints is in question.

08 · And what about "OpenCode Zen" and OpenRouter

If you run into these names: OpenCode Zen isn't a model but a curated model gateway from the CLI agent OpenCode (a Claude Code competitor). It's attached to Claude Code only through a Cloudflare proxy — an extra layer you don't need. OpenRouter is a gateway to 300+ models with a single key (handy for A/B), but it officially guarantees Claude Code compatibility only for Anthropic models; for the Chinese ones it's another point of failure, so for working sessions a provider's direct /anthropic is more reliable.

Summary

The formula is simple. DeepSeek v4-flash is the workhorse for volume and reading. GLM is for when you need Ukrainian and tool-use. Claude stays on the final polish, MCP, and the sensitive stuff. Keep two or three profiles, switch by task (or hand that off to claude-code-router), don't turn off the cache, and don't skimp on the final pass. The savings on the bulk phase are dozens of times over; the risk is exactly where you deliberately keep Claude.

Comments

Signed-in readers only — to keep it human, not a bot swamp.