With 8 environment variables, you can point Claude Code (and Claude Desktop Developer Mode) to DeepSeek, unlock a 1M context window with deepseek-v4-pro[1m], use deepseek-v4-flash for subagents, set the main model's effort to max, and set the automatic compaction window to 786432.
Suitable tasks: Coding-agent scenarios that need to connect V4-Pro to an existing Claude Code workflow at low cost and require a 1M long context window (for large codebases or long documents); switching the underlying model in Claude Desktop Developer Mode.
Unsuitable tasks: Scenarios with custom requirements for tool-call formats (Claude Code's harness rewrites the tool protocol, so model behavior differs from direct API access); tasks that require vision capabilities (the official V4 series is text-only).
Supported model versions: deepseek-v4-pro (the official integration also supports deepseek-v4-flash; the [1m] suffix unlocks a 1M context window).
Supported clients, agents, or APIs: Claude Code CLI and the Claude Desktop app (Developer Mode); the integration uses DeepSeek's Anthropic-compatible endpoint, https://api.deepseek.com/anthropic.
Recommended reasoning tier and parameters: The official example sets CLAUDE_CODE_EFFORT_LEVEL=max; subagents use deepseek-v4-flash without high effort. For direct API access, choose from the official low/high/max effort tiers.
Configuration for migration or a fresh installation, as provided by the official documentation (store the API key in secure secret management; do not write it to Git or logs):
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=786432Equivalent Windows PowerShell syntax (verbatim from the official documentation):
$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"Then enter the project directory and run claude. For a fresh installation, first run npm install -g @anthropic-ai/claude-code (requires Node.js 18+).
If Claude Code is already installed, back up your environment variables and configuration first. For a fresh installation, install @anthropic-ai/claude-code and confirm that claude --version returns a version number.
Set the environment variables above. Inject the API key through an environment variable rather than writing it in plaintext to your shell history (the official example uses <your DeepSeek API Key> as a placeholder).
Enter the project directory and run claude. Start with read-only tasks (reading files, grep, and planning) and confirm that the banner shows the model as deepseek-v4-pro and that tool calls work correctly.
Long-conversation test: with CLAUDE_CODE_AUTO_COMPACT_WINDOW=786432 (about 768K tokens), observe whether context compaction behaves as expected. Use the 1M context only when needed; ordinary tasks do not need the [1m] suffix.
When network retrieval is needed, DeepSeek API natively supports Claude Code's Web Search tool, which the model invokes automatically when it determines that search is necessary. Triggering retrieval incurs an additional LLM summarization-request charge, so include it in the cost budget.
Record the model name, effort, compaction window, tool trace, and token cost after the test, and compare them with other backends on the same task set.
The official integration maps Claude model names to DeepSeek: claude-opus* → deepseek-v4-pro, and claude-haiku* / claude-sonnet* → deepseek-v4-flash. This mapping allows Claude Desktop Developer Mode to bypass model-name restrictions by changing the base URL and API key.
The official documentation states that Claude Code's Web Search is natively supported by the DeepSeek API and is invoked automatically when the model decides it is needed; the summarization request incurs additional token costs.
The [1m] suffix (deepseek-v4-pro[1m]) unlocks a 1M context window; the official pricing page confirms a 1M context window and a maximum output of 384K for V4-Pro.
This is a configuration workflow, not a model-quality benchmark. Claude Code's built-in tool protocol and system prompt change model behavior, and the client determines the long-context compaction strategy.
The official documentation provides only an environment-variable example. Secret handling, network egress, and cost limits are the user's responsibility; the official documentation does not provide guardrails.
Model-mapping rules may change with client versions. After upgrading Claude Code, recheck the mapping and whether [1m] is still accepted by the API.
CLAUDE_CODE_EFFORT_LEVEL=max is the value used in the official example. For simple tasks, it can be lowered to high/low to reduce latency and cost; use measurements on the target task to determine the appropriate setting.
Official source text: “Models starting with claude-opus are mapped to deepseek-v4-pro; Models starting with claude-haiku or claude-sonnet are mapped to deepseek-v4-flash”.
DeepSeek V4 Pro