Claude Code's coding experience is best-in-class, but a few things make it a headache for developers outside the US: a $20–$200/month subscription, occasional ban risk, and that two-week Fable 5/Mythos 5 export ban back in June. The good news: Claude Code was designed from day one with a back door built in — swap out its backend model entirely using just two environment variables. This guide pulls together every major migration path on the market into one piece, covering three approaches with a pitfall checklist attached.

Why Switch Claude Code's Backend to DeepSeek?

There's rarely just one reason to migrate. Based on real feedback from the developer community, it usually comes down to a few things:

The four most common reasons to migrate

  • A huge cost gap: Claude Code Max runs $200/month, while completing equivalent coding tasks on the DeepSeek V4 Pro API costs about $7/month on average in real-world usage, as low as $5 — a 15–40x difference. One GitHub project ran the numbers precisely and found it 95x cheaper.
  • Direct connection, no more VPN dependency: DeepSeek's official API domain, api.deepseek.com, connects directly outside mainland China's typical proxy requirements, and combined with a relay setup can even stay stable on an office network.
  • Sidestepping ban and export-control risk: in June this year, Anthropic's flagship models were hit by export controls and went dark globally for two weeks. Once you're on DeepSeek, that kind of uncontrollable external risk disappears entirely.
  • 1M-token ultra-long context: DeepSeek V4 Pro supports a 1-million-token context window, 5x Claude Sonnet 4.6's 200K — a clear advantage for full-repository analysis on large projects.

Before You Switch: How Good Is DeepSeek V4's Coding Ability, Really?

A common worry is "won't dropping Claude make the experience worse?" Let's look at the numbers before deciding.

Metric DeepSeek V4 Pro Claude Sonnet 4.6
SWE-bench Verified 80.6%+ 79.6%
Average across coding benchmarks 73.8 66.4
Context window 1,000,000 tokens 200,000 tokens
Output pricing (per million tokens) $3.20 $15.00 (4.7x more expensive)
Direct connection ✓ Official direct connect ✗ Requires VPN
Image input ✗ Not yet supported ✓ Supported

The takeaway: for pure coding tasks, DeepSeek V4 Pro holds up against Claude Sonnet 4.6, and beats it on some benchmarks. Its one clear weak spot is that it doesn't support image input — worth noting if you regularly hand Claude Code screenshots or design mockups to analyze.

On real-world scenario testing, JavaGuide's in-depth review found the DeepSeek V4 + Claude Code combo handles real engineering tasks well — code audits, database migrations, model upgrades. An independent review on the 4sAPI blog noted that V4-Pro "matches Claude with zero extra config," with surprisingly stable behavior across long agentic task chains.

Option 1: Direct Connection to the Official DeepSeek API (Most Recommended)

This is the approach explicitly documented by DeepSeek, with the simplest config — good for most individual developers.

Step 1: Get a DeepSeek API key

Go to platform.deepseek.com, sign up and log in, and create a new key on the "API Keys" page. New accounts usually come with free credit, so you can test your whole setup before spending anything.

Step 2: Configure environment variables

macOS / Linux (add to ~/.zshrc or ~/.bashrc to persist):

export ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic
export ANTHROPIC_AUTH_TOKEN=your-deepseek-api-key
export ANTHROPIC_MODEL=deepseek-v4-pro[1m]
export ANTHROPIC_DEFAULT_OPUS_MODEL=deepseek-v4-pro[1m]
export ANTHROPIC_DEFAULT_SONNET_MODEL=deepseek-v4-pro[1m]
export ANTHROPIC_DEFAULT_HAIKU_MODEL=deepseek-v4-flash
export CLAUDE_CODE_SUBAGENT_MODEL=deepseek-v4-flash
export CLAUDE_CODE_EFFORT_LEVEL=max

Windows (PowerShell, takes effect immediately in the current session):

$env:ANTHROPIC_BASE_URL="https://api.deepseek.com/anthropic"
$env:ANTHROPIC_AUTH_TOKEN="your-deepseek-api-key"
$env:ANTHROPIC_MODEL="deepseek-v4-pro[1m]"
$env:ANTHROPIC_DEFAULT_OPUS_MODEL="deepseek-v4-pro[1m]"
$env:ANTHROPIC_DEFAULT_SONNET_MODEL="deepseek-v4-pro[1m]"
$env:ANTHROPIC_DEFAULT_HAIKU_MODEL="deepseek-v4-flash"
$env:CLAUDE_CODE_SUBAGENT_MODEL="deepseek-v4-flash"
$env:CLAUDE_CODE_EFFORT_LEVEL="max"

To make it permanent on Windows, set these in System Properties → Advanced → Environment Variables, or add them to your PowerShell profile file.

Step 3: Verify the config

Reopen your terminal (so the environment variables load), start Claude Code, and run:

/status

If the Base URL field shows https://api.deepseek.com/anthropic and Model shows deepseek-v4-pro[1m], the config is working. Give it a small task to edit some code, and once that runs successfully, the migration is complete.

⚠️ Important: model IDs are changing soon (effective 2026-07-24)

DeepSeek has officially announced that the old model IDs deepseek-chat and deepseek-reasoner will be retired on July 24, 2026. If your config still uses either of these IDs, switch to deepseek-v4-pro[1m] (primary tasks) and deepseek-v4-flash (sub-agent / quick tasks) before that date, or you'll start getting errors after July 24.

Option 2: Access via an API Relay (Best for Low Latency Outside the US)

If you're on a corporate network, occasionally see instability from the official DeepSeek API, or want one key that flexibly supports DeepSeek + Claude + GPT, an API relay is the better choice. The config is identical to Option 1 — just swap ANTHROPIC_BASE_URL for the endpoint your relay provides.

# Example using a relay that supports DeepSeek (use the actual address your relay provides)
export ANTHROPIC_BASE_URL=https://your-relay-domain.com/anthropic
export ANTHROPIC_AUTH_TOKEN=your-relay-api-key
export ANTHROPIC_MODEL=deepseek-v4-pro
# All other environment variables are the same as Option 1

A few key things to check when picking a relay:

  • Explicit DeepSeek V4 Pro support: some relays only forward Claude/GPT and don't support DeepSeek
  • Anthropic format support (not just OpenAI format): Claude Code speaks the Anthropic protocol, so the relay needs a working /anthropic path, not just an OpenAI-style /v1 endpoint
  • Direct-connect nodes: prefer relays with nodes optimized for your region to avoid connection timeouts on a corporate or internal network

For relays verified to support both DeepSeek and the Anthropic format, see our AI API relay comparison list and filter for "model coverage" that includes DeepSeek.

Option 3: The CC Switch GUI Tool (Easiest, for Anyone Who'd Rather Skip the Command Line)

If you don't want to manually edit environment variables every time, CC Switch is currently the most convenient GUI option. It's a cross-platform desktop app (macOS/Windows/Linux) with 50+ built-in AI API provider presets — the official DeepSeek API is already in the preset list, so you just click to switch, no URL to type in by hand.

  • 67k+ GitHub stars
  • Unified Provider management across Claude Code, Codex, Gemini CLI, and other AI CLI tools
  • Unified MCP management, Skills installation, and a built-in local proxy
  • Configure once and settings persist across tool restarts

See our full walkthrough: the complete CC Switch guide.

Known Limitations After Switching — Read This Before You Migrate

DeepSeek isn't a 100% drop-in replacement for Claude — a few behavioral differences worth knowing about upfront:

What you lose after switching

  • Image input: DeepSeek V4 Pro's current version is text-only and can't process images, screenshots, or design mockups. If your workflow relies on the image → Claude Code pattern to analyze UI, this is the biggest gap.
  • /ultrareview and task budgets: these features depend on Anthropic's backend infrastructure and stop working once you switch the model.
  • xhigh effort mode: some advanced effort-control parameters are Anthropic-proprietary protocol features that DeepSeek doesn't yet support.
  • Claude Desktop doesn't support this setup: Claude Desktop uses OAuth authentication and doesn't read ANTHROPIC_AUTH_TOKEN or ANTHROPIC_BASE_URL. Only the Claude Code CLI supports this.

Frequent Pitfalls Checklist

The most common issues reported by the developer community, ranked by how often they come up:

  1. Set the environment variables but they're not taking effect: don't forget to run source ~/.zshrc (or reopen your terminal) before launching Claude Code. Variables written into a shell config file don't auto-load into a terminal session that's already open.
  2. ANTHROPIC_API_KEY vs ANTHROPIC_AUTH_TOKEN: different versions of Claude Code expect different variable names. To be safe, set both to your DeepSeek key:
    export ANTHROPIC_API_KEY=your-deepseek-key
    export ANTHROPIC_AUTH_TOKEN=your-deepseek-key
  3. reasoning_content field errors: DeepSeek V4 Pro returns a reasoning_content field during its reasoning process, and some Claude Code versions don't recognize it and throw an error. Updating to the latest Claude Code (claude update) usually fixes it.
  4. Relay only supports OpenAI format, not Anthropic format: Claude Code uses the Anthropic protocol, so the base URL's trailing path needs to be /anthropic (not OpenAI's /v1). If a relay only exposes a /v1 endpoint, connecting Claude Code to it will error out or return garbled responses.
  5. Old model IDs stop working after July 24: as noted above, deepseek-chat and deepseek-reasoner retire on 2026-07-24. Update to deepseek-v4-pro[1m] and deepseek-v4-flash ahead of time.
  6. Occasional official-API rate limiting: during peak hours in mainland China, the official DeepSeek API can slow down or briefly time out. Switching to a relay setup (which spreads load across multiple nodes) usually improves this.
  7. API key security: don't commit it to Git: whether it's a DeepSeek key or a relay key, whoever has it has full control of the account. Don't hardcode it into a file you commit — use a .env file with it added to .gitignore, or use your OS's key management tools.

Advanced: Smart Multi-Model Routing with Claude Code Router

If you don't want to give up on Claude entirely but also want automatic fallback to DeepSeek when tokens run low or a task is cost-sensitive, Claude Code Router is worth a look. It runs as a local proxy layer and automatically decides which backend to route to based on task type (complexity, whether images are involved, context length) — by default routing everyday coding tasks to DeepSeek, and only sending tasks that genuinely need Claude's strengths (multimodal input, long-chain reasoning) to Claude.

Once configured, Claude Code's ANTHROPIC_BASE_URL points at the local Router proxy address (e.g., http://127.0.0.1:8080/anthropic), and the Router dispatches from there based on your rules. See the project's GitHub docs for detailed setup — we won't go deep into it here, but this is currently the most flexible way to manage multiple models.

Cost Estimates

Based on real-world data, here's a monthly cost estimate across three usage intensities:

Usage intensity Claude Code Max DeepSeek V4 Pro (direct) Relay (DeepSeek)
Light (personal projects, 1–2h/day) $20/month $1–3/month $2–5/month
Moderate (full-time dev, 4–6h/day) $100/month $5–12/month $8–15/month
Heavy (multi-project, agentic tasks) $200/month $15–30/month $20–40/month

Note: these are estimates — actual cost depends on token consumption, model choice, and your specific use case. DeepSeek is currently in a promotional pricing period and prices may change.

Summary: When to Switch to DeepSeek vs. When to Stay on Claude

✅ Good candidates for switching to DeepSeek

  • Mostly pure coding work: writing code, reviews, refactoring, debugging
  • Need ultra-long context to analyze large projects (the 1M-token edge matters a lot)
  • Subscription cost is a real burden, or the project is early-stage with a tight budget
  • Working in an environment without a stable VPN
  • Need a backup plan after a Claude ban or service outage

🔄 Good candidates for staying on Claude (or a hybrid setup)

  • Your workflow relies heavily on screenshot/design-mockup analysis (DeepSeek V4 Pro doesn't support image input)
  • You use /ultrareview, task budgets, or other Anthropic-proprietary features
  • You need to frequently sync context between Claude Code and the Claude.ai web app
  • You have a strong preference for Claude's output style (Claude's writing/tone differs from DeepSeek's)

For most developers outside the US, the most practical strategy is using DeepSeek V4 Pro as your daily driver, and switching back to Claude for image analysis or tasks that specifically need Claude's strengths. Both CC Switch and Claude Code Router can make this kind of dual-model workflow feel seamless.

The migration itself has a very low technical bar — two environment variables, three minutes to set up. The part that actually takes time is figuring out the hybrid setup that fits your own workflow best.

Need a reliable DeepSeek API relay? Check out our AI API relay comparison list to find providers that support both DeepSeek V4 and the Anthropic format.