Field SOP
Field SOP

SOP | Two Env Vars to Run Claude Code on DeepSeek-V4-Pro

A hands-on SOP for hooking DeepSeek-V4-Pro into Claude Code: two core env vars (ANTHROPIC_BASE_URL + ANTHROPIC_AUTH_TOKEN) + the Cline custom-base-URL route. Five steps: install, get key, set vars, run, verify. Includes official-verified commands, 5 pitfalls (AUTH_TOKEN ≠ API_KEY, compat ≠ equivalence, thinking billed, price-hike warning, Windows session vars), 5 FAQs.

Published August 13, 20268 min read
<!-- deepseek-v4-pro-claude-code-sop | sop | SOP | Two Env Vars to Run Claude Code on DeepSeek-V4-Pro -->

DeepSeek-V4-Pro-0813 natively supports Anthropic API compatibility, meaning the terminal where you run Claude Code can switch to DeepSeek by changing two core environment variables - running the Claude Code experience at DeepSeek's price. There are two paths: the official Claude Code CLI with env vars (DeepSeek provides an integration guide), and the open-source Cline extension with a custom base URL. Picking the wrong variable or mixing key types means a wasted config - Claude Code wants ANTHROPIC_AUTH_TOKEN, the Anthropic SDK wants ANTHROPIC_API_KEY, and they are not the same thing.

This SOP walks five steps: install tools -> get the key -> set env vars -> run -> verify. It complements this batch's Cline + DeepSeek open-source analysis (the open-source agent in depth) and frontier coding model comparison (why DeepSeek) - those answer "what and why," this one answers "how to hook it up." Env vars and install commands are per DeepSeek's official "Integrating with Claude Code" guide; Cline steps are per its official docs; all per the official site. It draws a line against our Claude Code vs Cursor vs Codex - that one compares tools, this one is the hands-on of hooking up DeepSeek.


1. Two Paths: Claude Code CLI vs Open-Source Cline

The core decision is made before you start: do you want the official terminal flow, or an open-source in-editor agent.

DimensionClaude Code CLI pathCline extension path
Representative toolClaude Code (Anthropic's official CLI)Cline (66K-star open-source VS Code extension, Apache-2.0)
How it hooks into DeepSeekEnv vars (ANTHROPIC_BASE_URL + AUTH_TOKEN)Custom base URL in settings
FormTerminalVS Code sidebar
Open sourceClosedOpen
Suited forPure terminal flow, official experienceWorking in VS Code, swappable provider

In short: terminal flow -> Claude Code CLI; visual operation in the editor -> Cline. Both point at https://api.deepseek.com/anthropic underneath; only the config entry differs.


2. The Five-Step SOP

Step 1: Install the Tools

Claude Code CLI path. Install dependencies first: Node.js 18+; Windows users need Git for Windows. Then install Claude Code:

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

Verify:

bash
claude --version

A version number means success.

Cline path. Search "Cline" in the VS Code marketplace and install, or download the vsix from GitHub Releases. The Cline panel appears in the sidebar. No Node environment needed.

Step 2: Get a DeepSeek API Key

Register on the DeepSeek Platform and create an API Key; copy and save it (it's shown only once). This key is your credential for DeepSeek - both Claude Code and Cline use it.

Step 3: Set Env Vars / Base URL

Claude Code CLI path (two core vars + recommended additions). The env vars from DeepSeek's official integration guide:

Linux / Mac (run in the terminal):

bash
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
export CLAUDE_CODE_AUTO_COMPACT_WINDOW=786432

Windows (PowerShell):

powershell
$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"
$env:CLAUDE_CODE_AUTO_COMPACT_WINDOW="786432"

The two core vars are ANTHROPIC_BASE_URL (pointing at the DeepSeek compatibility endpoint) and ANTHROPIC_AUTH_TOKEN (your DeepSeek key). The rest are recommended additions: ANTHROPIC_MODEL=deepseek-v4-pro[1m] selects the 1M-context Pro variant; *_HAIKU_MODEL and CLAUDE_CODE_SUBAGENT_MODEL use the cheaper Flash for subtasks to control cost; CLAUDE_CODE_AUTO_COMPACT_WINDOW=786432 (~768K) pairs with the 1M context. The [1m] suffix is the 1M-context variant marker.

Cline path. Open the Cline panel settings (gear icon), set API Provider to "Anthropic," check "Use custom base URL," fill in https://api.deepseek.com/anthropic, put your DeepSeek key in the Anthropic API Key field, and set Model to deepseek-v4-pro (or deepseek-v4-flash for the lightweight tier). Save.

Step 4: Run

Claude Code CLI path. After setting the env vars, enter your project directory and launch:

bash
cd /path/to/my-project
claude

Claude Code now runs on DeepSeek-V4-Pro under the hood, not Anthropic's official service. Use the Claude Code interaction as usual (give tasks, watch it edit code, approve actions).

Cline path. Open the project in VS Code, open the Cline sidebar, and give a task (e.g., "add error handling to this function and add unit tests"). It breaks the work into steps, edits files, runs commands, and waits for your confirmation at each step.

Step 5: Verify It's Actually on DeepSeek

After launch, confirm the backend really switched to DeepSeek - don't burn money on Anthropic's official service. Two methods. First, deliberately leave only the DeepSeek ANTHROPIC_AUTH_TOKEN set (no official Anthropic key) - if it runs, it's going through DeepSeek. Second, send a simple query, check whether the response style and speed match DeepSeek, and watch the DeepSeek Platform dashboard to see whether token usage increases. Once confirmed, start real tasks.


3. Five Pitfalls

Pitfall 1: ANTHROPIC_AUTH_TOKEN and ANTHROPIC_API_KEY are not the same thing Both names appear in DeepSeek's docs and are easy to mix up. The "Using the Anthropic API" page (for the Python/Node SDK) writes ANTHROPIC_API_KEY; the "Integrating with Claude Code" page (for the Claude Code CLI) writes ANTHROPIC_AUTH_TOKEN. Claude Code reads ANTHROPIC_AUTH_TOKEN - if you set ANTHROPIC_API_KEY it may not pick it up. Fix: for Claude Code always use ANTHROPIC_AUTH_TOKEN for your DeepSeek key; for SDK calls use ANTHROPIC_API_KEY. Don't mix them up.

Pitfall 2: Interface compatibility ≠ capability equivalence - complex workflows need regression DeepSeek's Anthropic compatibility layer covers the interface format, but tool-call details, prompt-caching behavior, and long-context stability differ from native Claude. Some tool-call flows Claude Code originally tuned for Claude may occasionally misbehave when migrated. Fix: run a round of regression on your real tasks before a production project - don't assume "runs" means "performs identically." Complex agent workflows especially need testing of tool calls and long context.

Pitfall 3: Thinking mode is on by default - token consumption is higher than the headline price DeepSeek-V4-Pro's thinking mode is on by default; the model emits reasoning tokens before answering, and they're billed. CLAUDE_CODE_EFFORT_LEVEL=max pushes reasoning depth further, making the bill climb more visibly. Fix: for cost-sensitive scenarios, lower the effort or explicitly switch to non-thinking mode; use deepseek-v4-flash for subtasks (CLAUDE_CODE_SUBAGENT_MODEL) to control cost. The headline ¥6/M output isn't the actual bill.

Pitfall 4: DeepSeek posted a price-hike warning - don't model long-term costs on today's prices The pricing page explicitly says a large near-term price increase is planned. The current low window (Pro output ¥6/M, Flash ¥2/M, cache-hit ¥0.025/M) may narrow. Fix: push cache-hit rates now (high reuse of system prompts and code context makes cache-hit price negligible); don't bet on it staying cheap if you depend heavily - watch for official price-change notices.

Pitfall 5: Windows env vars only apply to the current PowerShell session Vars set with $env:VAR="..." are gone when you close PowerShell - next terminal you have to set them again, and forgetting falls back to official Anthropic (errors or burning money). Fix: either persist them in a PowerShell Profile, set them permanently as system environment variables (System Properties -> Environment Variables), or use a .env file with a launch script. For production, prefer system env vars - don't rely on a temporary session.


Common Questions

Q1: What's the minimum set of vars to hook Claude Code into DeepSeek? A1: The core two: ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic and ANTHROPIC_AUTH_TOKEN=<DeepSeek key>. The rest (ANTHROPIC_MODEL=deepseek-v4-pro[1m], Flash for subtasks, etc.) are recommended additions to select the 1M-context variant and control cost. Note Claude Code reads ANTHROPIC_AUTH_TOKEN, not ANTHROPIC_API_KEY.

Q2: What is the [1m] in deepseek-v4-pro[1m]? A2: The 1M-context variant marker. DeepSeek-V4-Pro has 1M context and 384K max output; the [1m] suffix selects the 1M-context variant. Without it you may get the default tier. The official guide uses deepseek-v4-pro[1m] when configuring Claude Code.

Q3: What's the difference between Cline and Claude Code for hooking into DeepSeek? A3: The config entry differs. Claude Code (terminal CLI) uses env vars; Cline (VS Code extension) sets the Anthropic provider in settings, checks custom base URL, and fills in https://api.deepseek.com/anthropic. Both point at the same DeepSeek compatibility endpoint underneath. Pick Claude Code for terminal flow, Cline for visual operation in the editor.

Q4: After connecting, how do I confirm it's really on DeepSeek and not Anthropic? A4: Two methods. One, leave only the DeepSeek ANTHROPIC_AUTH_TOKEN set (no official Anthropic key) - if it runs, it's going through DeepSeek. Two, after sending a query, check whether the DeepSeek Platform dashboard shows token usage increasing. Confirm before starting real tasks to avoid accidentally burning money on the official service.

Q5: Does thinking mode being on by default cost more? A5: Yes. Thinking mode emits reasoning tokens before answering, and they're billed; CLAUDE_CODE_EFFORT_LEVEL=max pushes reasoning depth further. Long tasks consume more than the headline unit price. To save, lower the effort or switch to non-thinking mode, and use deepseek-v4-flash for subtasks to control cost. Measure the actual bill on real tasks - don't just look at the ¥6/M headline.


References

This article is AI-assisted and human-edited. Last updated: 2026-08-13

FAQ

What's the minimum set of vars to hook Claude Code into DeepSeek?
The core two: `ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic` and `ANTHROPIC_AUTH_TOKEN=<DeepSeek key>`. The rest (`ANTHROPIC_MODEL=deepseek-v4-pro[1m]`, Flash for subtasks, etc.) are recommended additions to select the 1M-context variant and control cost. Note Claude Code reads `ANTHROPIC_AUTH_TOKEN`, not `ANTHROPIC_API_KEY`.
What is the [1m] in `deepseek-v4-pro[1m]`?
The 1M-context variant marker. DeepSeek-V4-Pro has 1M context and 384K max output; the `[1m]` suffix selects the 1M-context variant. Without it you may get the default tier. The official guide uses `deepseek-v4-pro[1m]` when configuring Claude Code.
What's the difference between Cline and Claude Code for hooking into DeepSeek?
The config entry differs. Claude Code (terminal CLI) uses env vars; Cline (VS Code extension) sets the Anthropic provider in settings, checks custom base URL, and fills in `https://api.deepseek.com/anthropic`. Both point at the same DeepSeek compatibility endpoint underneath. Pick Claude Code for terminal flow, Cline for visual operation in the editor.
After connecting, how do I confirm it's really on DeepSeek and not Anthropic?
Two methods. One, leave only the DeepSeek `ANTHROPIC_AUTH_TOKEN` set (no official Anthropic key) - if it runs, it's going through DeepSeek. Two, after sending a query, check whether the DeepSeek Platform dashboard shows token usage increasing. Confirm before starting real tasks to avoid accidentally burning money on the official service.
Does thinking mode being on by default cost more?
Yes. Thinking mode emits reasoning tokens before answering, and they're billed; `CLAUDE_CODE_EFFORT_LEVEL=max` pushes reasoning depth further. Long tasks consume more than the headline unit price. To save, lower the effort or switch to non-thinking mode, and use `deepseek-v4-flash` for subtasks to control cost. Measure the actual bill on real tasks - don't just look at the ¥6/M headline.

Related

Field SOP

Build a Game Without Code: A 49-Agent AI Studio

Turn a single Claude Code session into a 49-agent game studio with Claude Code Game Studios (github.com/Donchitos/Claude-Code-Game-Studios, MIT, about 33,837 stars): three-tier directors/leads/specialists, 72 slash commands, and 12 hooks that catch hardcoded values and accidental pushes, with a protocol that keeps every decision in your hands. Includes a five-minute setup, a demo-trimmed workflow, third-party API options, and a fit checklist.

Nov 3, 20269 min read
Field SOP

Claude Code Sandboxing: Install It Without Giving Agents Root

Give your agent a sandbox, not root: a hands-on install guide for Anthropic's open-source sandboxing tool srt (anthropics/sandbox-runtime, Apache-2.0, 6,615 stars, repo created October 2025). Verbatim npm global install, the ~/.srt-settings.json config verbatim, platform primitive differences across macOS/Linux/Windows with three default-policy tiers, and the three-layer Windows truth stated as-is: the srt CLI is still Alpha, Schannel is a hard limitation with no workaround, and Claude Code on native Windows does not run the sandbox — use WSL2. The 84 percent interception rate is the official self-reported figure; an eight-item community pitfall list included (#139/#160/#122 fixed, Ubuntu 24.04 sysctl, and more).

Oct 26, 202611 min read
Field SOP

Claude Code DeepSeek Setup: Nine Env Vars, No Old Tutorials

A hands-on SOP for wiring Claude Code straight into DeepSeek, with every command and variable taken from the official guide (api-docs.deepseek.com/quick_start/agent_integrations/claude_code), reflecting the current configuration after the 1017 checkpoint. Primary search phrase: "Claude Code DeepSeek setup" (S1=3/S2=1/S3=2/S4=3). Migration path with nine environment variables: ANTHROPIC_BASE_URL to https://api.deepseek.com/anthropic, ANTHROPIC_AUTH_TOKEN with your DeepSeek API key, ANTHROPIC_MODEL=deepseek-flash[1m], DEFAULT_OPUS and DEFAULT_SONNET also deepseek-flash[1m], DEFAULT_HAIKU=deepseek-flash, CLAUDE_CODE_SUBAGENT_MODEL=deepseek-flash, CLAUDE_CODE_EFFORT_LEVEL=max, CLAUDE_CODE_AUTO_COMPACT_WINDOW=786432; both PowerShell and Linux/Mac variants are given. Install from scratch in four steps: Node.js 18+ (plus Git for Windows on Windows), npm install -g @anthropic-ai/claude-code, verify with claude --version, set the variables and run claude in your project directory. Model mapping: requests starting with claude-opus route to deepseek-v4-pro (billed at V4 Pro prices, pricier than Flash - a must-read reminder), claude-haiku and claude-sonnet route to deepseek-flash. Web Search works natively but bills on two lines: search requests per the Search API plus extra token costs for summarizing retrieved content. Pricing (official rate page): off-peak 0.15 dollars per million input tokens on cache miss, 0.003 on a hit (one fiftieth of the miss price), 0.60 output; peak (weekdays 01:00-04:00 and 06:00-10:00 UTC) doubles everything; weekends and Chinese public holidays count as off-peak. Five pitfalls: AUTH_TOKEN and API_KEY are not the same thing (mixing them equals no config), old and new variables coexisting can cause auth conflicts (keep only the new ones, per community guides), never commit keys via settings.json (persist them in ~/.bashrc, ~/.zshrc or system environment variables), validate the tool-calling chain with a minimal read-one-file-then-edit-one-file task before real work, and check the live model with /status. Older tutorials still reference retired names like deepseek-chat. Division of labor: deepseek-v4-pro-claude-code-sop is the V4-Pro-0813-era two-variable minimal setup (2026-09), while this piece is the full current official configuration after 1017; for the Harness itself see deepseek-harness-quickstart-sop.

Oct 19, 202610 min read