Skip to content
Claude Code in China: Install, Third-party Providers, and Multi-model Switching (Windows/macOS)

Claude Code in China: Install, Third-party Providers, and Multi-model Switching (Windows/macOS)

Claude Code can feel “easy to start”, but in restricted networks and heterogeneous toolchains the real blockers are usually:

  1. You can’t install (Node/npm permissions, network, registry)
  2. You can’t connect (wrong key/base URL/token, shell config not loaded, IDE/CLI config mismatch)

This guide compresses the path into one mainline: get the CLI running → make the provider work → turn switching + IDE integration into a reusable “toggle”.

“Third-party provider” here means a service exposing an Anthropic-compatible API (accepts ANTHROPIC_BASE_URL plus ANTHROPIC_API_KEY/ANTHROPIC_AUTH_TOKEN). Ensure compliance for your account/keys. Do not “bypass login” by modifying internal state files.

1) Install: get the Claude Code CLI running

1.1 Install Node.js (recommend 18+)

Claude Code is installed via npm. Verify Node/npm:

node --version
npm --version

Common pitfalls:

  • macOS: using system Node + global installs often hits permission issues; using nvm is typically smoother.
  • Windows: PowerShell execution policy/permissions can block installs; inspect the error and use admin only if necessary.

1.2 Install Claude Code

npm install -g @anthropic-ai/claude-code
claude -v

If you can run claude -v, you’ve cleared the first major hurdle.

2) Configure: start with official or third-party providers

At a high level, you need:

  • a provider base URL (Anthropic official, or an Anthropic-compatible endpoint)
  • an API key / auth token
  • a reliable way to load env vars in your shell and IDE

Practical suggestions:

  • prefer project-local .claude/settings.json for team-shared settings
  • keep secrets in environment variables (not committed files)
  • test with a minimal headless call first (claude -p ...) so you can iterate quickly

3) One-click switching: multiple models and multiple providers

If your team uses multiple providers or switches models frequently, treat it like a “toggle”:

  • define profiles (provider + model + key/base URL)
  • write a small script that sets env vars and launches claude
  • keep the script in your repo or team dotfiles

The key is reproducibility: switching shouldn’t depend on “someone remembering which env var to set”.

4) VS Code extension: keep IDE and CLI in sync

Most “it works in terminal but not in VS Code” issues come from env var loading.

Tips:

  • verify the VS Code integrated terminal inherits the same environment
  • avoid maintaining two separate config sources (one for CLI, one for IDE) if possible
  • confirm the CLI and extension are using the same provider/base URL/key

5) Troubleshooting checklist (priority order)

  1. Confirm claude -v works
  2. Confirm Node/npm are available and on PATH
  3. Confirm env vars are actually loaded in the shell you’re using
  4. Confirm base URL + key/token are correct
  5. Confirm the IDE environment matches terminal environment

Sources & further reading