Wiring Claude Code to DeepSeek got substantially easier and substantially different on October 17, 2026, when DeepSeek shipped the V4.1-Flash-1017 checkpoint and overhauled its official integration guide. The recommended model name is now deepseek-flash, the configuration has grown from two core variables to nine environment variables, and Claude Code's Web Search tool is natively supported. The good news: the official direct-connect path is clearer than ever. The bad news: plenty of tutorials still teach the old setup — some reference retired model names, others mix up ANTHROPIC_AUTH_TOKEN with ANTHROPIC_API_KEY, and if you copy them verbatim, you will configure nothing.
First, a division of labor. Our September 2026 post, the minimal Claude Code DeepSeek setup SOP, documented the "two environment variables" minimal approach from the V4-Pro-0813 era — the fastest route to a working session. This article is the full, current official configuration after the 1017 checkpoint landed: all nine environment variables, the model mapping, Web Search billing, and the effort and auto-compact settings in one place. The two posts complement each other: use the old one for a quick feasibility check, and this one when you intend to run DeepSeek behind Claude Code long-term. One more warning: many older tutorials still use deepseek-chat and other retired model names, so check everything against Section 2 before copying. All commands and variable names here follow the current DeepSeek official guide for Claude Code (api-docs.deepseek.com/quick_start/agent_integrations/claude_code, fetched and verified by this site); prices follow the official pricing page, not independently retested.
Three Facts to Internalize Before You Touch Anything
First, deepseek-flash now refers to DeepSeek-V4.1-Flash-1017 — the Flash generation released on October 17. DeepSeek's news page names it as the current production model, and the nine-variable official configuration uses it as the main model.
Second, model names retire gracefully. deepseek-v4-flash and deepseek-v4-flash-vision-exp are retired, but the API still accepts those names and bills them at Flash prices — which is precisely why old tutorials appear to keep working: nothing throws an error, you are just running last generation's configuration. Names like deepseek-chat belong to an even earlier era; do not write them into a fresh setup.
Third, the configuration surface has grown. Two variables — a base URL plus an auth token — genuinely did work before, but the official recommendation is now nine: the main model, explicit opus/sonnet/haiku mappings, a subagent model, an effort level, and an auto-compact window. Skipping some will not fail loudly. Instead, you pay in two quiet ways: the default mapping routes expensive models onto your bill (Section 4 covers this), and long conversations get compacted earlier than they should, chipping away at your cache. In short, the official road is fully paved, and nearly all remaining risk comes from following an outdated map.
Migration Path: Nine Environment Variables
If you already have a working Claude Code installation, migration requires no reinstallation — just set the environment variables below. These are the nine variables exactly as the official guide lists them, first for Linux and macOS:
export ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic
export ANTHROPIC_AUTH_TOKEN=<DeepSeek API Key>
export ANTHROPIC_MODEL=deepseek-flash[1m]
export ANTHROPIC_DEFAULT_OPUS_MODEL=deepseek-flash[1m]
export ANTHROPIC_DEFAULT_SONNET_MODEL=deepseek-flash[1m]
export ANTHROPIC_DEFAULT_HAIKU_MODEL=deepseek-flash
export CLAUDE_CODE_SUBAGENT_MODEL=deepseek-flash
export CLAUDE_CODE_EFFORT_LEVEL=max
export CLAUDE_CODE_AUTO_COMPACT_WINDOW=786432And the Windows PowerShell equivalents, with identical variable names:
$env:ANTHROPIC_BASE_URL="https://api.deepseek.com/anthropic"
$env:ANTHROPIC_AUTH_TOKEN="<DeepSeek API Key>"
$env:ANTHROPIC_MODEL="deepseek-flash[1m]"
$env:ANTHROPIC_DEFAULT_OPUS_MODEL="deepseek-flash[1m]"
$env:ANTHROPIC_DEFAULT_SONNET_MODEL="deepseek-flash[1m]"
$env:ANTHROPIC_DEFAULT_HAIKU_MODEL="deepseek-flash"
$env:CLAUDE_CODE_SUBAGENT_MODEL="deepseek-flash"
$env:CLAUDE_CODE_EFFORT_LEVEL="max"
$env:CLAUDE_CODE_AUTO_COMPACT_WINDOW="786432"Now, one line on what each variable does. ANTHROPIC_BASE_URL points Claude Code at DeepSeek's Anthropic-compatible endpoint, copied verbatim. ANTHROPIC_AUTH_TOKEN carries your DeepSeek API key; note the name is AUTH_TOKEN, not API_KEY, and Section 7 explains why that matters. ANTHROPIC_MODEL sets the main model to deepseek-flash[1m]; the [1m] suffix is exactly how the official guide writes it. ANTHROPIC_DEFAULT_OPUS_MODEL and ANTHROPIC_DEFAULT_SONNET_MODEL are both pinned to deepseek-flash[1m] — this decides which model actually answers when you pick the opus or sonnet tier, and at which price, making it the most important cost lever in the setup. ANTHROPIC_DEFAULT_HAIKU_MODEL and CLAUDE_CODE_SUBAGENT_MODEL use deepseek-flash without the [1m] suffix, since lightweight tasks and background subagents do not need the long-context tier. CLAUDE_CODE_EFFORT_LEVEL=max pushes reasoning effort to the top, the officially recommended value. Finally, CLAUDE_CODE_AUTO_COMPACT_WINDOW=786432 — roughly 750,000 tokens — enlarges the auto-compact window.
Once the variables are set, start from your project directory:
cd your-project && claudeOne caveat on persistence: whether you use export or $env assignments, the values live only in the current terminal session and vanish when the window closes. Validate with temporary variables first, then persist the nine variables into your shell profile or system environment (Section 7, pitfall three) — otherwise you risk baking a broken configuration into your daily environment.
Clean Install in Four Steps
If Claude Code is not on your machine yet, walk through four steps. Step one, prepare the runtime: Node.js 18 or newer, plus Git for Windows if you are on Windows — prerequisites straight from the official guide. Step two, install Claude Code globally:
npm install -g @anthropic-ai/claude-codeStep three, verify the installation:
claude --versionIf a version number prints out, the CLI itself is ready.
Step four, get a key, set the variables, and launch. Create your API key on the DeepSeek open platform (platform.deepseek.com/api_keys); it is displayed only once at creation time, so copy and store it immediately. Then configure the nine environment variables from the previous section, and start a session by running claude inside your project directory.
Model Mapping: Opus Defaults to deepseek-v4-pro, Billed at Pro Prices
This section affects your bill more than any other. According to the official documentation, on the Anthropic-compatible endpoint, requests for the claude-opus family are mapped to deepseek-v4-pro and billed at V4 Pro prices — which are higher than Flash. If you never touch the mapping, every call from the opus tier bills at the expensive rate. The claude-haiku and claude-sonnet families map to deepseek-flash by default, so those tiers carry no surprise.
This is exactly why the migration configuration pins ANTHROPIC_DEFAULT_OPUS_MODEL and ANTHROPIC_DEFAULT_SONNET_MODEL to deepseek-flash[1m]: an explicit mapping is your cost brake. That said, if your workload genuinely needs the Pro ceiling, leaving the default mapping is legitimate — as long as you understand the billing implication. One more capability worth knowing: the official guide mentions that Claude Desktop's developer mode lets you change the base_url and api_key, bypassing the app's built-in model name restrictions to connect it to DeepSeek. That is officially documented, but the same mapping and billing rules apply: whatever maps to Pro still bills at Pro prices.
How should you choose? For everyday coding, bug fixing, and test writing, Flash at effort=max — the official guide's own main-model pick — should be your default. Heavy reasoning work, such as the design phase of a large refactor or cross-module architectural decisions, is where routing opus to Pro earns its premium. A middle path also works: keep the tiers pinned to Flash for daily driving, temporarily restore the default mapping for the occasional heavy task, then switch back.
Web Search Works, but Search Is Billed Separately
DeepSeek's API natively supports Claude Code's Web Search tool — no extra search plugin required. But the official documentation is explicit about the billing, and there are two lines on the invoice: the search requests themselves are billed through the Search API, and summarizing the retrieved content generates additional LLM token charges. The two stack, so the more your agent searches, the faster the bill grows. Two habits help: watch your billing curve, and constrain when the agent is allowed to search — turning "search on a whim" into "search when confirmed necessary." Left ungoverned, web search has a way of becoming the largest fixed line item in an otherwise cheap setup.
Pricing: Off-Peak and Peak
Per the official pricing page (not independently retested), deepseek-flash off-peak rates are: 0.15 dollars per million input tokens on cache miss, 0.003 dollars per million tokens on cache hit, and 0.60 dollars per million output tokens. Peak hours are 01:00 to 04:00 UTC and 06:00 to 10:00 UTC on weekdays, when prices double; weekends and Chinese public holidays count as off-peak all day.
Agent workloads are unusually sensitive to caching. Every turn of a Claude Code session re-sends large repeated prefixes, and the gap between a cache hit and a cache miss is fifty-fold — identical context, two different prices. Enlarging AUTO_COMPACT_WINDOW to 786432 is, at its core, a way to reduce how often long sessions get fragmented and cache prefixes invalidated. Run batch jobs during off-peak hours and the same workload bills at half the peak rate. A quick back-of-the-envelope: one million input tokens at off-peak cost 0.15 dollars on a cache miss but just 0.003 dollars on a cache hit — fifty times cheaper. Multiply that across dozens of turns, each re-sending the full context, and you have the concrete number at the bottom of your monthly invoice.
Common Pitfalls: Five Traps in Config and Verification
Pitfall one: AUTH_TOKEN and API_KEY are not the same thing. Claude Code expects ANTHROPIC_AUTH_TOKEN; ANTHROPIC_API_KEY is the variable for Anthropic SDK development scenarios. Put the key into the wrong variable and the client will not tell you the name is wrong — it will simply fail authentication. This site verified that lesson the hard way in an earlier post, and it remains the most common cause of "I configured everything and nothing happens."
Pitfall two: stale and new environment variables can conflict on authentication. If you previously connected Claude Code to a different Anthropic-compatible service, your shell profile may still carry old ANTHROPIC variables, and whichever one the client picks up wins — leaving you connected to the old endpoint while believing you configured the new one. Keep only the new variables and scrub the old ones (community tutorial consensus, a secondhand source).
Pitfall three: never let your key enter git. Writing the key into a project's settings.json and committing it is a real and recurring leak path — public repositories get scraped within minutes. Persist it in ~/.bashrc or ~/.zshrc on Linux and macOS, or in system environment variables on Windows.
Pitfall four: run a minimal task before real work. Tool-calling capability varies across models, and jumping straight into a serious task entangles "the model is not up to it" with "the configuration is broken" into one undiagnosable mess. Instead, ask the agent to read one file and then modify one file, confirming that Write, Bash, and Read tool calls all succeed before you hand over real work.
Pitfall five: use /status to confirm the effective model. Never trust the configuration on faith. Run /status once inside the session and confirm the effective model is in the deepseek-flash family — it takes seconds and eliminates the entire genre of "but I did set it" debugging.
With the five pitfalls covered, a closing checklist — clear all five before calling the integration done: /status shows a deepseek-flash-family model; the minimal task exercised Write, Bash, and Read successfully; no stale ANTHROPIC variables remain in your shell profiles; the key appears in no file that git tracks; and the billing page confirms the billed model and price tier match your mapping expectations.
FAQ
Q1: What is the actual difference between ANTHROPIC_AUTH_TOKEN and ANTHROPIC_API_KEY?
A: Claude Code recognizes ANTHROPIC_AUTH_TOKEN, which is also what the DeepSeek official guide uses; ANTHROPIC_API_KEY is primarily for Anthropic SDK development scenarios. The two follow different authentication paths, and mixing them up is the number one cause of a silent, unresponsive setup.
Q2: Can I still use model names like deepseek-chat or deepseek-v4-flash from older tutorials?
A: deepseek-v4-flash and deepseek-v4-flash-vision-exp are retired, but the API still accepts them and bills at Flash prices, so old configurations will not error out right away. Names like deepseek-chat are leftovers from even older tutorials and should not go into a new setup; follow the current official guide and write deepseek-flash.
Q3: What happens if I do not set ANTHROPIC_DEFAULT_OPUS_MODEL?
A: You fall back to the official default mapping: opus-family requests route to deepseek-v4-pro and bill at V4 Pro prices, which are higher than Flash. To control costs, pin opus and sonnet to deepseek-flash[1m] as shown in Section 2; if you genuinely need Pro capability, keeping the default mapping is fine — just understand the billing tier you are opting into.
Q4: How is Web Search inside Claude Code billed?
A: Two charges stack: the search requests themselves are billed through the Search API, and summarizing the retrieved content generates additional LLM token fees. The more your agent searches, the more the two lines add up.
Q5: Where should I persist my API key long-term?
A: Not in a settings.json that gets committed to git. On Linux and macOS, persist it in ~/.bashrc or ~/.zshrc; on Windows, use system environment variables. While you are at it, remove any leftover ANTHROPIC variables from other services to avoid authentication conflicts.
Related reading
- DeepSeek Weights Are Free, Yet Agent Task Bills Fall 60 Percent: DeepSeek Weights Are Free, Yet Agent Task Bills Fall 60 Percent
- Hands-on SOP: One npx Line to Run DeepSeek Harness - Install, Four Modes, Trajectory Replay, and Your First Plugin: DeepSeek Harness quickstart: your first command
- ## Test Background and Method: Claude Code vs Cursor vs Codex: three lanes, compared