Claude Code From China: Two Environment Variables, Alipay Top-Up (2026)
cocodot's Anthropic-compatible endpoint: set ANTHROPIC_BASE_URL and a key and Claude Code runs the real Claude. Setup, model codes, integrity check, errors.
1. Can you actually use Claude Code from China?
Yes, with no hacks. Claude Code speaks Anthropic's own protocol and requires overseas payment — two hurdles for users in China — but it officially supports the ANTHROPIC_BASE_URL environment variable to point requests at a third-party Anthropic-compatible endpoint. That is a standard mechanism Anthropic left in place, not a workaround. cocodot provides such an endpoint that translates and calls the real Claude (Opus / Sonnet / Haiku / Fable), so you set two variables and Claude Code itself stays untouched.
2. Three steps
① Sign up at cocodot, top up via Alipay, create an API key in the console (it starts with cocodot-); ② in your terminal set export ANTHROPIC_BASE_URL=https://cocodot.co/api/ai and export ANTHROPIC_AUTH_TOKEN=your-key; ③ run claude. To pin models add export ANTHROPIC_MODEL=mco-6 (main) and export ANTHROPIC_SMALL_FAST_MODEL=mch-1 (fast). Put them in ~/.zshrc or ~/.bashrc to avoid re-setting. On Windows use $env:ANTHROPIC_BASE_URL="..." in PowerShell, or add them permanently under System Environment Variables.
3. Choosing models: main plus fast
Claude Code uses two models at once: the main model does the real work (reading and writing code, planning), the fast model handles chores (file summaries, quick judgments). See the table: for the main model pick mco-7 (Opus 5, latest flagship, same price as 4.8 with 1M context) or mco-6 (Opus 4.8); budget-sensitive, mcs-6 (Sonnet 5, whose list price is below 4.6). Fix the fast model at mch-1 (Haiku). To switch mid-way, change the variable and restart claude — one key covers everything.
4. Billing and top-up: metered, capped at list
Per-token billing, never above the model's list price; Alipay top-up in CNY lands as USD balance; no extra fee on API usage itself — see cocodot.co/pricing for current fees. No monthly plan, pay for what you use — an advantage for Claude Code users: the official subscription's usage window (reset every few hours) does not exist in metered mode, so you keep running while balance remains. The console shows tokens and charges per call. Start with a small top-up, run one real task, check latency and quality, then add by usage.
5. Worried about a degraded model? Verify, do not guess
The relay industry's biggest trust problem is 'charge for Claude, serve something cheaper'. Do not judge by feel — test: the open-source checker probe.cocodot.co runs six probes (context length, tokenizer traits, model self-description, and more) against any Anthropic / OpenAI-compatible endpoint, no sign-up, keys never stored. We publish it precisely so you can point it at cocodot — verifiable channels are what separate us from account pools and grey relays.
6. Common errors
① Auth failed / 401: is ANTHROPIC_AUTH_TOKEN the complete cocodot key and is the balance above 0? The variable is AUTH_TOKEN, not API_KEY. ② Cannot connect / timeout: ANTHROPIC_BASE_URL must be exactly https://cocodot.co/api/ai — no trailing /v1; Claude Code appends its own path, and this is the most common misconfiguration. ③ Model error: use the codes in the table (mco-6 / mcf-1 / mcs-5 / mch-1), not official names. ④ Occasional tool-call / streaming glitches: the endpoint is marked BETA; basic chat, file read/write, command execution and streaming are stable, and edge cases fixed quickly when reported.
7. Not connecting directly? Two other routes
By scenario: inside an IDE — the same cocodot key works on the OpenAI-compatible endpoint https://cocodot.co/api/ai/v1; enter it as a custom endpoint in Cursor / Cherry Studio / Cline with model mco-6. Want the official subscription — use a cocodot US-BIN virtual card to subscribe to Claude Pro / Max on Anthropic's site: official account, official quota, balance under your control. All three routes (direct / IDE / official subscription) draw on one cocodot wallet.
Model codes for Claude Code
| Code | Model | Role | Suggested use |
|---|---|---|---|
| mco-6 | Claude Opus 4.8 | Strongest; complex code / refactors | Main model (ANTHROPIC_MODEL) |
| mcf-1 | Claude Fable 5 | Latest flagship | Main model for early adopters |
| mcs-5 | Claude Sonnet 4.6 | Daily workhorse, cheaper | Main model when budget-sensitive |
| mch-1 | Claude Haiku 4.5 | Fast model for small tasks | Fast model (ANTHROPIC_SMALL_FAST_MODEL) |