Use DeepSeek models in Claude Code

Set ANTHROPIC_BASE_URL to https://api.deepseek.com/anthropic and ANTHROPIC_AUTH_TOKEN to your DeepSeek API key.

Official examples use deepseek-flash[1m] for the main Claude Code model slots and deepseek-flash for Haiku/subagent slots (see the Claude Code integration page for the full env block).

Claude model names are mapped server-side: claude-opus → deepseek-v4-pro; claude-haiku/claude-sonnet → deepseek-flash.

Checked on 26 Oct 2026 against Claude Code integration.

Official sources

Claude Code setup

Install Claude Code with npm install -g @anthropic-ai/claude-code (Node.js 18+), then point it at DeepSeek's Anthropic-compatible endpoint. Official env block (Linux/macOS):

Environment variables (from official docs)
export ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic
export ANTHROPIC_AUTH_TOKEN=<your 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=786432

Or persist the same keys under env in ~/.claude/settings.json (create the file if missing). Windows uses the $env: form on the integration page.

Codex and OpenCode

Codex (CLI, desktop, VS Code) uses ~/.codex/config.toml with base_url = "https://api.deepseek.com/" and wire_api = "responses". DeepSeek publishes a one-click setup script and manual models.json on the Codex integration page.

OpenCode: run opencode, type /connect, choose provider deepseek, enter your API key, and select DeepSeek-V4.1-Flash (OpenCode >= v1.14.24 recommended). See the OpenCode integration.

DeepSeek does not publish a separate Cline integration page in the same Agent Integrations menu; use the OpenAI or Anthropic base URLs with deepseek-flash / deepseek-v4-pro if your editor supports custom endpoints.

Fixing common HTTP errors

  • 400 / 422 — invalid body or parameters. Read the error message and compare against the error codes guide.
  • 401 — wrong API key in ANTHROPIC_AUTH_TOKEN.
  • 402 — no balance; top up on the platform.
  • Wrong host / 404-style failures — Claude Code must use https://api.deepseek.com/anthropic, not https://api.deepseek.com/v1 alone.

FAQ

https://api.deepseek.com/anthropic — not the OpenAI-style https://api.deepseek.com root alone.

Claude Code speaks the Anthropic API. DeepSeek documents ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic in the official Claude Code integration guide.

The integration guide exports ANTHROPIC_MODEL=deepseek-flash[1m] and maps Claude Opus/Sonnet/Haiku slots to deepseek-flash or deepseek-v4-pro.

Yes. Web Search triggers DeepSeek Search plus extra model tokens to summarize results.