Back to Blog
tutorialsclaude-code

Using Claude Code from China: 5-Minute Setup with CCSub Relay

Step-by-step guide to using Claude Code in China without VPN. Sign up for CCSub, create an API key, and configure environment variables. Works on macOS, Windows, Linux, and the VS Code extension.

April 8, 20263 min readCyberFisher

Claude Code is Anthropic's official AI coding CLI. The capability is excellent, but direct connections from China are unreliable. Routing through CCSub gives you full Claude Code functionality on Chinese networks with no VPN required. New to the concept? Start with what a Claude API proxy is and why you'd use one.

Why a relay?

Claude Code defaults to api.anthropic.com. From inside China:

  • Connections drop or time out frequently
  • The official subscription requires a non-Chinese credit card
  • Even when you can pay, the FX rate is unfavorable

Routing through CCSub, you get:

  • Direct in-China connectivity — no extra latency, no VPN
  • ¥1 = $1 USD of API balance — roughly 14% of the official rate
  • Full-strength models — Opus 4.6 / Sonnet 4.6 / Haiku 4.5, no quality reductions

Step 1: Sign up for CCSub

Open the CCSub registration page and create an account with your email.

Step 2: Top up your balance

Open "Billing / Subscription" and pay with WeChat Pay, Alipay, or USDT. The minimum top-up is ¥20, and the balance never expires.

Step 3: Create an API key

Open "API Keys" and click "Create Key". The default group is fine; each group's rate and description are shown on the API Keys page.

Copy the sk- prefixed key.

Step 4: Configure Claude Code

macOS / Linux

Open a terminal and run:

export ANTHROPIC_BASE_URL="https://www.ccsub.net"
export ANTHROPIC_AUTH_TOKEN="sk-your-key"

Don't add /v1 or a trailing slash. To persist, append both lines to ~/.zshrc or ~/.bashrc.

For Windows persistence, settings.json precedence, the VS Code extension and error fixes, the Claude Code setup guide is kept up to date with each Claude Code release.

Windows

In CMD (current window only):

set ANTHROPIC_BASE_URL=https://www.ccsub.net
set ANTHROPIC_AUTH_TOKEN=sk-your-key

To make it permanent, write user environment variables from PowerShell; see the Claude Code setup guide.

settings.json

If you would rather not touch system variables, edit ~/.claude/settings.json. It takes precedence over your shell:

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://www.ccsub.net",
    "ANTHROPIC_AUTH_TOKEN": "sk-your-key"
  }
}

The VS Code extension checks credentials before it reads this file, so set claudeCode.environmentVariables in your VS Code user settings instead; see the setup guide.

One-click via CC-Switch

Install CC-Switch. Then create a key on the CCSub API Keys page and click "Import CCS" in the "key created" dialog; the relay is configured automatically (the full key is shown only once, in that dialog). To add the provider by hand, see the CC Switch guide. Codex is configured differently; see the Codex CLI guide.

Step 5: Run claude

After configuring, just run claude in your terminal:

claude "write me a React login component"

FAQ

Q: I get 401 Invalid API Key

The key is missing or wrong. See fixing 401 Invalid API Key in Claude Code. If it never connects, see Connection error.

Q: I see "Not logged in"

Add "hasCompletedOnboarding": true to ~/.claude.json, or use CC-Switch to write the config for you.

Q: A single conversation burns through a lot of credit

Long context inflates cost. Use /clear between unrelated tasks to reset the context window.

Q: Which models are supported?

Model IDs are listed on the models page; switch with /model inside Claude Code. A mistyped ID returns 404; see model not found.


Sign up to get started → CCSub

Ready to use AI APIs?

Sign up for CCSub and get an extra $5 on your first top-up

Get Started

Related Posts