Guide

Running Claude Code from China: A Practical 2026 Guide

2026-04-23 10

Running Claude Code from China: The Real Problem

Claude Code CLI is the best agentic AI coding tool available in 2026. If you are a developer in mainland China, using it productively is legitimately hard. Three specific problems compound:

  1. Direct API access from Chinese networks is unreliable. Traffic to some international API endpoints sometimes resolves, sometimes drops the TLS handshake, sometimes delivers truncated responses. Behavior depends on ISP, time of day, and region.
  2. Foreign payment is blocked on most providers. Credit cards issued in China are rejected by most US-based API services. Even foreign cards registered with Chinese addresses are often rejected.
  3. Peak-hour throttling hits lower-priority regions harder. When a US-based API has high load, it sheds traffic starting from lower-tier customers — and developers in China are disproportionately on lower tiers for payment reasons.

If you have tried to make it work with a commercial VPN, you already know the trade-offs: added latency, unstable connections during long agentic sessions, and the constant worry that your VPN will drop mid-task.

This guide covers the real options for running Claude Code productively from China in 2026.

Option 1: VPN + Direct Foreign Account

This is the default attempt. Subscribe to a reliable VPN, register a foreign API account using a foreign card (via family abroad or a reshipping service), connect normally.

When it works: Short sessions, simple tasks, off-peak hours.

When it breaks:

  • Long refactors: Streaming responses can take 30-120 seconds. VPN drops mid-stream kill your session.
  • Tool use: Claude Code's tool calls create lots of round trips. Each extra latency hop (you → VPN → foreign API) compounds. A session with 50 tool calls amplifies 5 ms of VPN overhead into meaningful waits.
  • Billing: If your foreign payment method fails during a billing cycle, your account is suspended. Recovering it from China is painful.

Realistic cost: $10-20/month for a VPN + whatever the foreign API charges. Plus the unquantified cost of lost productivity when things break.

Option 2: A Domestic-Accessible Claude-Compatible Relay

Claude Code CLI supports the ANTHROPIC_BASE_URL environment variable as an officially documented configuration knob. This means you can point Claude Code at any API service that speaks the Anthropic API protocol — not just Anthropic itself.

A growing number of Chinese-registered services offer such relays. LLM API is one example — a multi-provider relay service whose public endpoint is reachable directly from most Chinese ISPs, with payment via Alipay or WeChat Pay.

The setup with Claude Code is identical to using any other backend, just with two different environment variables:

export ANTHROPIC_BASE_URL=https://llmapi.pro
export ANTHROPIC_API_KEY=your-llmapi-key
claude

Claude Code CLI does not need to know what is behind the URL — it speaks the Anthropic API protocol, and LLM API responds with the same protocol.

What you get:

  • Direct China access — no VPN needed for most ISPs
  • Alipay / WeChat Pay — no foreign card required
  • CNY pricing — no exchange rate hassle (Pro ¥59/月, Max ¥259/月, Ultra ¥979/月)
  • Multi-provider pool — the relay routes your request through multiple upstream APIs so a single vendor's capacity issue does not stall your session

What you trade off:

  • You are trusting a third-party relay service, not a direct provider. Check the relay's terms on data retention and uptime track record.
  • The model pool behind the relay may include multiple vendors; specific model availability depends on the relay's configuration.

For most daily Claude Code use cases — coding, refactoring, tool use, explanations — a domestic-accessible relay is more practical than a VPN setup for Chinese developers.

Option 3: Alibaba DashScope or Similar Chinese Clouds with a Shim

Some developers have tried wiring up Chinese cloud LLM APIs (like Alibaba DashScope for Qwen) with a Claude-compat shim like LiteLLM. This is technically possible but fragile:

  • Claude Code updates its CLI frequently, and each update risks breaking the shim.
  • Tool calling semantics differ subtly — some tool calls work, some do not, and debugging this is miserable.
  • You are effectively using Qwen (or another Chinese model) rather than experiencing Claude Code with the models it was designed around.

If you are committed to Qwen specifically for cost or compliance reasons, this path can work — but it is not the ideal Claude Code experience.

Option 4: Self-Hosted Proxy

Some teams build their own proxy: a cheap overseas VPS running a reverse proxy to a foreign API, reached by Chinese users via a clean domain.

When this makes sense:

  • You have >10 developers and want full control.
  • You have ops capacity to maintain it.
  • You already have an overseas presence with billing.

When this does not make sense:

  • Solo developer or small team.
  • No existing infrastructure expertise.
  • Unwilling to debug SSL, TLS, QUIC, and CDN issues at 3 AM.

For most Chinese developers, the self-hosted overhead exceeds the savings over a managed relay.

Practical Setup: LLM API in 60 Seconds

The fastest working path for a Chinese developer new to Claude Code:

  1. Install Claude Code (if not already):

    npm install -g @anthropic-ai/claude-code
    
  2. Register at llmapi.pro — free tier available, Alipay/WeChat for paid tiers.

  3. Get your API key from the dashboard.

  4. Set environment variables:

    export ANTHROPIC_BASE_URL=https://llmapi.pro
    export ANTHROPIC_API_KEY=sk-...your-key...
    
  5. Verify:

    claude --print "hello"
    

If you get a response, you are done. Proceed to real work.

What Does Not Work from China

Just to save you time, these are unreliable from Chinese networks without a VPN:

  • Many direct foreign API endpoints
  • Most foreign API dashboards
  • Foreign chat-style LLM web UIs
  • GitHub Copilot (requires foreign card anyway)

FAQ

Is LLM API legal to use in China? Yes. LLM API is a Chinese-registered relay service that exposes a Claude-compatible API. You are not accessing any foreign service directly, so cross-border network restrictions do not apply.

Will my code be logged? LLM API does not log prompts or completions. Metadata (request timestamps, token counts, pricing) is retained for billing. Check the privacy policy for authoritative details.

Is there a free tier? Yes, enough to evaluate whether it works for your workflow before paying. Paid tiers start at ¥29/month.

Does latency suffer? For Chinese users, latency to a domestic-accessible relay is typically faster than tunneling to a foreign API through a commercial VPN.

Can I still use a foreign API directly when traveling abroad? Yes — just unset the two environment variables (unset ANTHROPIC_BASE_URL) and Claude Code CLI reverts to its default endpoint.

Bottom Line

Claude Code CLI is the best coding agent available. If you are in China and cannot reliably use it, you are leaving real productivity gains on the table. The fastest practical fix is not a better VPN — it is a domestic-accessible Claude-compatible relay.

Two environment variables. Sixty seconds. Same Claude Code CLI, a different backend.

Get started with LLM API →

分享这篇文章

开始使用 LLM API

免费套餐可用。Claude Code 一行配置。

免费开始