DeepSeek V4 with Claude Code

A provider-documented setup for routing Claude Code through DeepSeek's Anthropic-compatible API, with exact environment variables, a smoke test, and compatibility limits.

1M
documented Pro route
Pro + Flash
main and subagent mapping
Web Search
documented tool support

Provider boundary: Claude Code is made by Anthropic. DeepSeek documents a compatible routing configuration and explicitly says the third-party agent is listed for reference without an effectiveness or security guarantee. Your API key and model usage are with DeepSeek Platform, not this website.

How the routing works

Claude Code client, DeepSeek model backend

Claude Code normally speaks the Anthropic Messages format. Setting ANTHROPIC_BASE_URL redirects those requests to DeepSeek’s Anthropic-format endpoint, while ANTHROPIC_AUTH_TOKEN supplies a DeepSeek Platform key. Compatibility lets many text and tool workflows run, but it does not make the two providers’ APIs identical.

Claude Code roleConfigured valueDeepSeek route
Primary / OpusANTHROPIC_MODEL and ANTHROPIC_DEFAULT_OPUS_MODELdeepseek-v4-pro[1m]
Sonnet defaultANTHROPIC_DEFAULT_SONNET_MODELdeepseek-v4-pro[1m]
Haiku / subagentsANTHROPIC_DEFAULT_HAIKU_MODEL and CLAUDE_CODE_SUBAGENT_MODELdeepseek-v4-flash

DeepSeek’s general Anthropic compatibility page also describes fallback mapping: Claude Opus names map to Pro, while Haiku and Sonnet names map to Flash. The explicit Claude Code variables above take precedence for the documented setup and make routing easier to audit.

Requirements

Claude Code

A current Claude Code installation verified with claude --version

Current release

API Provider

A DeepSeek Platform API key kept outside source control

Required

System Requirements

A supported OS and terminal; npm installs currently require Node.js 22+

Node.js 22+ for npm

Use DeepSeek with Claude Code: setup guide

Configuration Reference

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"

Source: DeepSeek's official Claude Code integration guide, checked July 22, 2026. Keep the key out of Git and shared project files.

DeepSeek Claude Code guide · Anthropic API compatibility table · OpenRouter alternative setup

Troubleshooting

API Authentication Failed

Confirm ANTHROPIC_AUTH_TOKEN contains an active DeepSeek Platform key and ANTHROPIC_BASE_URL is exactly https://api.deepseek.com/anthropic.

Slow Response Times

Check DeepSeek service status and account rate limits. Compare Flash for faster tasks and Pro for tasks that need the larger model.

Model Not Available

Use the publisher-documented IDs deepseek-v4-pro[1m] and deepseek-v4-flash. Re-open the live DeepSeek guide if an ID or alias changes.

Unexpected Output Format

DeepSeek's Anthropic compatibility is not complete: image, document, MCP, container, and several cache-control fields are unsupported or ignored. Check the compatibility table before relying on a Claude feature.

Compatibility limits

What works—and what needs a fallback

DeepSeek publishes a field-level Anthropic API compatibility table. Review it before assuming a Claude Code feature will work through the alternate backend, especially for multimodal content, MCP, containers, prompt caching controls, or code execution.

Text messages and streaming

Supported by the Anthropic-format endpoint.

Tool definitions and tool use

Core names, schemas, calls, and results are supported; some cache and parallel-control fields are ignored.

Thinking content

Supported, but budget_tokens is ignored; output_config supports effort only.

Images and documents

Image and document message blocks are not supported by the compatibility table.

MCP request fields

mcp_servers, mcp_tool_use, and mcp_tool_result fields are ignored or unsupported.

Container/code execution results

Container and code_execution_tool_result fields are not supported.

Secure the coding-agent workflow

A coding agent can read source, execute tools, and edit files. Routing to another provider changes where prompts and repository context are processed. Use a scoped test key, a disposable repository, least-privilege tool permissions, version control, and a review gate before enabling writes or commands in valuable projects.

  • Store the key in a user-level secret manager or shell environment, never Git.
  • Review Claude Code permissions and project instructions before launch.
  • Exclude production secrets, customer data, and unrelated repositories from context.
  • Inspect every diff and run tests before commit.
  • Rotate the key after a temporary evaluation or suspected exposure.

Understand model and tool cost

The documented setup uses a direct DeepSeek Platform key. V4 Pro and Flash have separate input/output rates, and web search can generate additional LLM requests to summarize results. Agent loops, subagents, retries, long repository context, and verbose diffs can consume more tokens than a single chat request.

Start with a small spending limit and representative tasks. Record the primary model, subagent model, cache behavior, tool calls, retries, accepted patches, and total usage. This site’s one-time token packs are unrelated to direct API billing.

Open the DeepSeek API pricing guide

Common Workflows

Code Review

Use DeepSeek V4 for intelligent code review and suggestions

  • Select code files
  • Ask specific review questions
  • Iterate on suggestions

Debugging Assistant

Leverage V4's reasoning capabilities for complex debugging

  • Describe the bug
  • Provide error context
  • Follow troubleshooting suggestions

Documentation Generation

Generate comprehensive documentation with V4's language understanding

  • Input code context
  • Specify documentation format
  • Review and refine output

Frequently Asked Questions

Is this an official Claude Code integration?

DeepSeek officially documents how to route the third-party Claude Code client to its Anthropic-format API, while warning that it cannot guarantee the third-party agent's effectiveness or security. It is not an Anthropic endorsement of DeepSeek as a first-party Claude backend.

Can I use other API providers?

Possibly, but provider endpoints are protocol-specific. For example, OpenRouter's documented Claude Code endpoint is https://openrouter.ai/api without /v1. Use that provider's current Claude Code guide rather than copying the DeepSeek endpoint or an OpenAI-compatible /api/v1 URL.

What are the costs?

With the endpoint shown here, DeepSeek Platform bills the V4 model tokens and additional tool requests. Claude Code itself may have separate licensing or account terms. Check both vendors' current documentation; this website's token packs do not fund the direct DeepSeek API key.

How do I switch between V4 Flash and Pro?

DeepSeek's published mapping uses deepseek-v4-pro[1m] for the main Opus/Sonnet roles and deepseek-v4-flash for Haiku and subagents. Update the role environment variables, restart the terminal session, and run a new smoke test.

Is DeepSeek a Claude Code alternative?

DeepSeek V4 is an alternative model backend, not a replacement for the Claude Code client. The setup keeps Claude Code's terminal agent interface and routes supported Anthropic-format requests to DeepSeek Platform.

Does the DeepSeek API support every Claude Code feature?

No. Core text, streaming, thinking, and tool fields are supported, but DeepSeek's compatibility table marks images, documents, MCP fields, containers, and code-execution result blocks as ignored or unsupported.