Skip to content

Claude Code in Mainland China

Run Claude Code without a VPN in China by pointing it at DeepSeek's Anthropic-compatible endpoint.

Trade-off

You'll be running DeepSeek models, not real Claude — comparable coding ability but not identical to Opus/Sonnet. This method is documented by DeepSeek; Anthropic neither supports nor blocks it.

Why this works

Claude Code defaults to api.anthropic.com, which is unreachable from mainland China. DeepSeek exposes an Anthropic-compatible endpoint (api.deepseek.com/anthropic) accessible inside China. Swap the base URL and you're done.

Step 1 — Install Node & Claude Code

bash
# Install Node via Homebrew
brew install node

# Switch npm to a China mirror (avoids timeouts)
npm config set registry https://registry.npmmirror.com

# Install Claude Code
npm install -g @anthropic-ai/claude-code

TIP

Do not use the curl … claude.ai/install.sh script — claude.ai is blocked. The npm route works reliably.

Step 2 — Get a DeepSeek API Key

  1. Go to platform.deepseek.com, register and log in.
  2. Add credit (pay-as-you-go, inexpensive).
  3. Create a key on the API Keys page — it looks like sk-xxxxxxxx.

Step 3 — Configure environment variables

Append the block below to ~/.zshrc, replacing the placeholder with your key:

bash
# Claude Code → DeepSeek V4 (mainland China, no VPN)
export ANTHROPIC_BASE_URL="https://api.deepseek.com/anthropic"
export ANTHROPIC_AUTH_TOKEN="sk-your-deepseek-key"

export ANTHROPIC_MODEL="deepseek-v4-pro"          # main model (opus tier)
export ANTHROPIC_SMALL_FAST_MODEL="deepseek-v4-flash"  # background tasks (haiku tier)

Then reload:

bash
source ~/.zshrc

Step 4 — Run

bash
cd your-project
claude

Claude Code will skip Anthropic's OAuth and connect to the DeepSeek endpoint directly.

Troubleshooting

IssueFix
Changes ignoredRun source ~/.zshrc or open a new terminal after every edit
Verify setupecho $ANTHROPIC_BASE_URL should print the DeepSeek URL
Back to real ClaudeComment out the four export lines and reload (VPN + Anthropic account still required)

Model aliases

Use deepseek-v4-pro / deepseek-v4-flash. The legacy aliases deepseek-chat and deepseek-reasoner retire after 2026-07-24.

Alternative endpoints

ProviderANTHROPIC_BASE_URL
DeepSeekhttps://api.deepseek.com/anthropic
Zhipu GLMhttps://open.bigmodel.cn/api/anthropic
Moonshot Kimihttps://api.moonshot.cn/anthropic

Scholardo is a closed-source commercial product.