Can’t Use Claude Code or Codex in China? Set Them Up with Domestic Models in 2 Minutes
This guide shows how to bypass subscription and cost barriers for Claude Code and Codex by using the free open‑source CC Switch tool to connect them to domestic large‑language models such as DeepSeek, enabling full AI‑coding functionality within minutes.
Many developers in China struggle to use popular AI‑coding tools Claude Code and Codex because foreign accounts are unavailable or the official usage quotas are prohibitively expensive, and there is a risk of account bans.
Both tools support model switching, so the solution is to route their requests through a domestic LLM. The open‑source, cross‑platform desktop application CC Switch provides a visual interface to manage configurations for multiple AI‑coding tools and includes preset suppliers for models like DeepSeek, Qwen, Kimi, and others.
Install CC Switch
Download the appropriate installer from the CC Switch website or GitHub Releases. On macOS you can install with a single Homebrew command: brew install --cask cc-switch Windows users download the .msi package, and Linux users choose the .deb, .rpm or .AppImage variant.
Prepare a DeepSeek API Key
Register on the DeepSeek Open Platform, create a new API key on the API Keys page, and copy it immediately because it is shown only once.
Connect DeepSeek to Claude Code
Install Claude Code ( npm install -g @anthropic-ai/claude-code) and run claude to verify the login step. Then open CC Switch, select the Claude application, click “Add Supplier”, choose the preset DeepSeek , paste the API key, and keep the other fields at their defaults. The preset includes two model versions: DeepSeek‑V4‑Pro (stronger agent capabilities) and DeepSeek‑V4‑Flash . Optionally enable the 1M token mode for long contexts. After saving, enable the model and restart Claude Code; asking “What model are you?” should return a DeepSeek‑based response.
Connect DeepSeek to Codex
Install Codex CLI ( npm install -g @openai/codex) and run codex. Directly editing ~/.codex/config.toml to replace the OpenAI base_url with DeepSeek’s endpoint fails because Codex uses the OpenAI Responses API while DeepSeek implements the Chat Completions API . The mismatch causes 404 errors.
CC Switch solves this by providing a local routing proxy that translates Codex requests into the format DeepSeek understands. Enable “Local Routing” for Codex in CC Switch, add the DeepSeek supplier (same steps as for Claude), and turn on the routing switch. The proxy transparently forwards requests: Codex → CC Switch → DeepSeek → CC Switch → Codex. After saving, restart Codex; the model now reports as DeepSeek while still presenting the original Codex interface.
Verification and Reversal
For both tools, verify the switch by asking the model to identify itself. To revert, simply disable the local routing and restore the default configuration.
Using an open‑source tool and domestic LLMs reduces the cost to a fraction of the official pricing and eliminates the need for foreign accounts, making AI programming accessible in China.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java Tech Enthusiast
Sharing computer programming language knowledge, focusing on Java fundamentals, data structures, related tools, Spring Cloud, IntelliJ IDEA... Book giveaways, red‑packet rewards and other perks await!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
