How to Use Claude Code in China Without VPN — 3-Line Setup Guide
May 4, 2026 · 6 min read
Claude Code is Anthropic's official terminal-native AI coding agent — arguably the strongest agentic coding tool of 2026. But for developers in mainland China, three friction points have made it nearly unusable: api.anthropic.com is throttled by GFW, USD-only billing rejects most CN-issued cards, and Anthropic doesn't serve China as an official region. This guide shows how to run Claude Code from inside China with three lines of shell config — no VPN, paid via WeChat Pay or Alipay.
Why this works: ANTHROPIC_BASE_URL
Claude Code is built on the official Anthropic SDK, which respects two environment variables: ANTHROPIC_BASE_URL (where to send requests) and ANTHROPIC_API_KEY (auth). Set both to AIPower's passthrough endpoint and Claude Code now talks to AIPower instead of api.anthropic.com. AIPower forwards every request to Anthropic with our authenticated key, bills your account in tokens at Anthropic's exact rates, and returns the upstream response unchanged — including streaming SSE, tool use, multi-turn, and vision.
From Claude Code's perspective, it's talking to Anthropic. From the user's perspective, it's billed in AIPower (WeChat Pay / Alipay / card) at AIPower's per-token rate (transparent — see /pricing).
Step 1: Get an AIPower API key
Sign up at aipower.me/register with email — no Chinese phone or VPN required. Top up $5 (about ¥36) via WeChat Pay or Alipay; this also unlocks Claude Sonnet 4 and Opus 4.6 plus 100 bonus low-cost trial calls. Copy your sk-aipower-... key from the dashboard.
Step 2: Set environment variables
Add these two lines to your ~/.zshrc (or ~/.bashrc for bash users):
export ANTHROPIC_BASE_URL="https://api.aipower.me/anthropic"
export ANTHROPIC_API_KEY="sk-aipower-xxxxxxxxxxxxxxx"Reload your shell: source ~/.zshrc. Verify the env is set with echo $ANTHROPIC_BASE_URL — you should see the AIPower URL.
Step 3: Run Claude Code
From any project directory, run:
claudeThat's it. The CLI now routes through AIPower's Cloudflare global edge into Anthropic's official API. You should see Sonnet 4 responding in your terminal at roughly 50–100ms latency from China — comparable to native Anthropic from US East.
If you prefer pipe-style usage:
echo "Refactor this file to use async/await" | claudeWhat works (and what doesn't)
Fully supported via passthrough:
- Sonnet 4 and Opus 4.6 (Haiku support coming — see changelog)
- Tool use / function calling (Claude Code uses heavily for file edits, bash, search)
- Multi-turn conversations with context
- Streaming SSE (token-by-token output)
- Vision (image inputs)
- Anthropic Beta features via
anthropic-betaheader
Edge cases to know:
- If you already have an Anthropic Pro $20/mo subscription, Claude Code uses your daily quota when calling api.anthropic.com directly. AIPower is independent pay-as-you-go billing — set ANTHROPIC_BASE_URL per-shell or per-project to switch.
- Latency varies by Chinese ISP and POP availability. Beijing / Shanghai / Shenzhen typically hit Cloudflare's nearest POP within 50ms; remote regions may see 100–150ms.
Pricing (international tier)
AIPower's per-token rates for Claude models. CN-region pricing is higher to fund cross-border infrastructure — see /pricing for the complete table including Chinese-region rates.
| Model | Input ($/M tokens) | Output ($/M tokens) |
|---|---|---|
| Claude Sonnet 4 | $3.60 | $18.00 |
| Claude Opus 4.6 | $6.00 | $30.00 |
AIPower's value isn't pure cost — it's China-friendly access (no VPN, WeChat Pay / Alipay billing) plus the ability to mix Claude with GPT-5, DeepSeek, Qwen, and 12 other models through one API key, billed against one balance.
Use the same key for Cursor, Cline, Continue.dev
The setup pattern works for any tool that respects ANTHROPIC_BASE_URL or OPENAI_BASE_URL env vars:
- Cursor — set OpenAI base URL in Cursor settings → use
anthropic/claude-sonnetas model - Cline (autonomous VS Code agent) — same env vars as Claude Code
- Continue.dev — config.json with
provider: "anthropic"+ AIPower base URL
FAQ
Is this legal / against Anthropic ToS?
AIPower operates as a reseller / aggregator gateway (similar architecture to OpenRouter / LiteLLM). Upstream requests go to Anthropic via our usage tier; users pay AIPower (with WeChat Pay / Alipay / card) at AIPower's per-token rate; Anthropic gets paid through our usage. We don't resell discounted tokens or share accounts. This is the standard B2B aggregator pattern.
Will it stop working if Anthropic blocks gateways?
If api.anthropic.com became unreachable from AIPower's infrastructure, the path forward would be wiring AWS Bedrock or GCP Vertex Anthropic endpoints as alternates (both still serve Claude). Our routing architecture leaves room for multi-upstream-per-model — that's a future-state capability, not active today. See smart routing for the current cross-provider routing behavior.
Why not use Claude on AWS Bedrock directly?
You can — but Bedrock requires an AWS account, IAM role setup, and pay-per-region. AIPower abstracts all that into a single OpenAI/Anthropic-shaped endpoint with WeChat Pay billing. For most China-based devs, the time savings are worth more than the negligible cost difference.
Next steps
Get started: aipower.me/claude-code-china
See the full pricing breakdown across all 16 models: aipower.me/pricing
Estimate your monthly Claude Code cost based on usage pattern: aipower.me/cost-calculator
GET STARTED WITH AIPOWER
16 AI models. One API. OpenAI SDK compatible.
Who should use AIPower?
- • Developers needing both Chinese and Western AI models
- • Chinese teams that can't access OpenAI / Anthropic directly
- • Startups wanting multi-model redundancy through one API
- • Anyone tired of paying grey-market intermediary premiums
3 steps to first API call
- Sign up — email only, 10 low-cost trial calls, no card
- Copy your API key from the dashboard
- Change
base_urlin your OpenAI SDK → done
from openai import OpenAI
client = OpenAI(
base_url="https://api.aipower.me/v1", # ← only change
api_key="sk-your-aipower-key",
)
response = client.chat.completions.create(
model="auto-cheap", # or anthropic/claude-opus, deepseek/deepseek-chat, openai/gpt-5, etc.
messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)+100 bonus calls on first $5 top-up · WeChat Pay + Alipay + card accepted · docs · security