cocodot
← Back to guides
Local card declined for overseas AI? cocodot: one card + one key
IntegrationUpdated 2026-08

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.

TL;DR: Claude Code is the mainstream terminal coding agent of 2026, but it requires overseas payment, so it is not directly usable from China. The fastest compliant path is the environment-variable mechanism Claude Code officially supports: ANTHROPIC_BASE_URL points requests at a third-party Anthropic-compatible endpoint. cocodot provides one that calls the real Claude family. Two steps: export ANTHROPIC_BASE_URL=https://cocodot.co/api/ai and export ANTHROPIC_AUTH_TOKEN=your cocodot key, then run claude as usual. Alipay top-up in CNY, per-token billing, prices capped at list (see cocodot.co/pricing). Worried about a degraded relay? Verify with the open-source checker probe.cocodot.co — including against us. Sign up and verify email for a $0.5 credit to test the pipeline (the trial credit covers cheaper models; Claude itself needs a small top-up).

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

CodeModelRoleSuggested use
mco-6Claude Opus 4.8Strongest; complex code / refactorsMain model (ANTHROPIC_MODEL)
mcf-1Claude Fable 5Latest flagshipMain model for early adopters
mcs-5Claude Sonnet 4.6Daily workhorse, cheaperMain model when budget-sensitive
mch-1Claude Haiku 4.5Fast model for small tasksFast model (ANTHROPIC_SMALL_FAST_MODEL)

FAQ

Versus the official Claude Pro / Max subscription — which is better value?

Depends on usage. The subscription is a fixed monthly fee with a usage window (resets every few hours; heavy use hits the wall); direct is metered with no window. Light users: subscribe. Heavy users running Claude Code for hours daily: metered is not interrupted by throttling and tracks real usage.

How do I confirm the model is not degraded?

Run the open-source probe.cocodot.co against the endpoint (context length, tokenizer, self-description — six probes) for results in minutes. We open-sourced it to invite verification — of us too.

Is my code stored?

cocodot is a channel: requests are translated and passed to the model provider; we do not store conversations or code, and console records hold token counts and charges, not content. For sensitive work, layer your company's own redaction policy on top.

Can the trial credit run Claude Code?

The $0.5 signup credit covers cheaper models — enough to confirm the pipeline (config, latency). Running Claude as the main model needs a small top-up. Verify the pipeline first, then pay — the right order.

What happens to a running task when the balance runs out?

New requests are rejected, Claude Code errors and stops; there is no overdraft or debt. Top up and rerun. Glance at the balance before long tasks.

How do I set the variables on Windows?

PowerShell, temporary: $env:ANTHROPIC_BASE_URL="https://cocodot.co/api/ai" and $env:ANTHROPIC_AUTH_TOKEN="your-key". Permanent: add both under System Settings → Environment Variables, then reopen the terminal.

About cocodot

cocodot is a payment and AI access service for developers and cross-border teams in mainland China. It provides US-BIN virtual cards issued by a licensed institution — used to pay for overseas subscriptions and ad accounts — and an OpenAI-compatible AI API gateway for calling Claude, GPT and Gemini from within mainland China. Both share one wallet, funded by Alipay and accounted in USD. Card: $9.9 to open, 3% to load, $1 per active card per month; spending: $0.60 settlement fee on purchases under $20; a corresponding fee applies when the issuer charges one.

Service scope, pricing and limits →
Claude Code From China: Two Environment Variables · cocodot