Claude Code Setup for China in 5 Minutes (One-Liner via CodeGateway)

The fastest path for Chinese developers to use Claude Code without a VPN — one shell command, supports macOS / Linux / Windows. See the deep dive on the blog.

TL;DR: Run Anthropic Claude Code from inside China in 5 minutes — one curl line points it at CodeGateway, new accounts get a $2 starting credit, billed per token, no VPN needed.

The fastest way for developers in China to use Claude Code is the CodeGateway one-liner script — a single shell command, no VPN required, no manual SDK config. Below are the commands for macOS / Linux / Windows. Run, then claude to start.

This is a quick command reference. For the full story with real-world latency tests and advanced workflows, see the blog deep dive: Claude Code China Quickstart.

1. Get an API Key (30 seconds)

You need a CodeGateway API key first:

  1. Sign in to CodeGateway Dashboard
  2. Go to API Keys
  3. Click Create Key and copy the string starting with sk-cg-
No account yet? Sign up — $1 free credit on the house, roughly 50 medium-complexity Claude Code calls (Sonnet 4.6, including CodeGateway markup). Enough to verify your setup and try a few real tasks.

2. One-Liner Script (macOS / Linux)

Open terminal, replace YOUR_KEY with your key, and run:

bash
curl -s https://codegateway.dev/setup.sh | bash -s -- --key sk-cg-YOUR_KEY

The script does three things:

  • Installs Claude Code if missing (via pip install or brew install)
  • Writes ~/.claude/settings.json with ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN
  • Backs up your existing shell config (prevents conflicts)

After it finishes, run claude to start. Welcome screen = you're good.


3. One-Liner Script (Windows / PowerShell)

Open PowerShell as Administrator:

powershell
& { $key='sk-cg-YOUR_KEY'; iwr -useb https://codegateway.dev/setup.ps1 | iex }

If you hit "execution policy" errors, run this first:

powershell
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser -Force

4. Manual Config (If You Prefer Not to Run a Script)

Put this in ~/.claude/settings.json:

json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.codegateway.dev",
    "ANTHROPIC_AUTH_TOKEN": "sk-cg-YOUR_KEY"
  }
}

Or set environment variables (good for quick testing):

bash
export ANTHROPIC_BASE_URL="https://api.codegateway.dev"
export ANTHROPIC_AUTH_TOKEN="sk-cg-YOUR_KEY" 

5. Verify

bash
claude --version    # Check that Claude Code is installed
claude              # Start the REPL inside any project directory

Ask something like "Hi, briefly introduce yourself". If Claude responds, the CodeGateway proxy chain is working.

Under the hood: your request is proxied through Cloudflare's global edge network to Anthropic's official API, end-to-end TLS encrypted. Actual latency depends on your network — see real-time response times for each call in Dashboard → Usage.

6. FAQ

Q: Which Claude model should I use?

A: Sonnet 4.6 for daily coding (strong price/performance), Opus 4.7 for complex architecture and refactors. See Claude Code vs Cursor vs Copilot.

Q: How does CodeGateway pricing work?

A: Anthropic's published rate plus a transparent markup (10-20%). The more you use, the lower the markup (down to 1.05x). See Tiered Markups Explained and Billing Guide.

Q: What's the API key format?

A: Must start with sk-cg-. Create one in Dashboard → API Keys. You can have multiple keys per account (one per project).

Q: Is the install script safe?

A: Not open source, but you can download, inspect, then run — split the one-liner into two steps:

bash
# 1. Download the script first, review the contents locally
curl -s https://codegateway.dev/setup.sh -o setup.sh
less setup.sh   # or cat setup.sh — read every action before trusting it

# 2. Run only after you're comfortable
bash setup.sh --key sk-cg-YOUR_KEY

The script collects no personal info — it only modifies ~/.claude/settings.json and your shell config (with backups of the originals).

Q: What files does the script modify?

A: Only two: ~/.claude/settings.json and your shell config (~/.zshrc or ~/.bashrc). Both are backed up first.

Q: Windows says "execution policy" error?

A: Run as Administrator, or execute Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser -Force first.

Q: What about a "401 Unauthorized" error?

A: Check whether your API key is expired or copied incompletely. Full troubleshooting: Error Troubleshooting Guide.


7. Next Steps

  • ✅ Got it working? → Read the Blog Deep Dive for advanced workflows (slash commands, Plan mode, Hooks automation)
  • 💰 Want to see actual costs? → Billing Guide
  • ⚖️ Picking a model? → Claude Code vs Cursor vs Copilot
  • 📚 Official Claude Code docs → Anthropic Documentation

References

AuthorCodeGateway teamReviewed on2026-05-03