DevTk.AI
DeepSeek V4Claude CodeAI AgentsCoding AgentDeepSeek API

How to Configure DeepSeek V4 in Claude Code

Step-by-step Claude Code setup for DeepSeek V4 Pro and V4 Flash using DeepSeek's Anthropic-compatible API. Includes environment variables, model choices, and cache-aware cost notes.

DevTk.AI 2026-04-28 Updated 2026-04-28 3 min read

DeepSeek V4 now exposes an Anthropic-compatible endpoint, so Claude Code can run against DeepSeek without an API proxy. This is useful when you want Claude Code’s terminal workflow but lower token costs, especially on cache-heavy repository work.

Official references: DeepSeek Coding Agents integration, DeepSeek Anthropic API, and DeepSeek V4 pricing.

RoleModelWhy
Main agentdeepseek-v4-pro[1m]Stronger long-horizon coding and 1M context
Default Sonnet / Opusdeepseek-v4-proMatches DeepSeek’s current Claude Code example
Cost-optimized subagentsdeepseek-v4-flashOptional cheaper setting for quick checks and side tasks
EffortmaxDeepSeek maps complex agent work to higher thinking effort

Use V4 Pro while the discount is active if quality matters. Use V4 Flash if you are doing high-volume simple edits or exploratory code search.

macOS / Linux Setup

Install Claude Code:

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

Set the DeepSeek endpoint and model variables:

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

For a lower-cost setup, change CLAUDE_CODE_SUBAGENT_MODEL to deepseek-v4-flash.

Then start Claude Code inside your repository:

cd /path/to/your-project
claude

Run /status after launch to confirm the base URL and model.

Windows PowerShell Setup

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

Then run:

claude

Cost Notes

DeepSeek V4 Flash is extremely cheap when cache hits are high: $0.0028/M cached input, $0.14/M cache-miss input, and $0.28/M output. V4 Pro is discounted to $0.003625/M cached input, $0.435/M cache-miss input, and $0.87/M output until 2026-05-31 15:59 UTC.

Claude Code repeatedly sends project instructions, tool context, and prior turns. That makes cache-hit rate the key cost variable. If your workflow reuses the same repository context, real bills can be far below a naive “all input is cache miss” estimate.

Troubleshooting

SymptomFix
Claude Code still uses AnthropicCheck that ANTHROPIC_BASE_URL is set in the same shell before running claude
Authentication failsUse ANTHROPIC_AUTH_TOKEN, not ANTHROPIC_API_KEY, for Claude Code
Quality is weaker than expectedUse deepseek-v4-pro[1m] for main agent and set CLAUDE_CODE_EFFORT_LEVEL=max
Cost is higher than expectedReduce large changing prefixes; stable prefixes are what generate cache hits

Related:

Related Posts