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

Kimi Dual Protocol: One Config for Codex and Claude Code

Moonshot announced on 2026-09-02 that the Kimi API natively supports dual protocols: OpenAI Responses (api.moonshot.cn/v1) plus Anthropic Messages (api.moonshot.cn/anthropic), with kimi-k3 as the flagship model. Hands-on SOP: point Claude Code's ~/.claude/settings.json ANTHROPIC_BASE_URL to /anthropic with model kimi-k3[1m]; set Codex's ~/.codex/config.toml wire_api="responses". This turns Kimi into a unified model-routing gateway — switch the backend without touching client code. Boundaries: Responses is text+image only, kimi-k2.7-code forces thinking, and the old ANTHROPIC_API_KEY must be removed.

Sep 5, 202611 min read