Updated 2026-05-01

How to Use DeepSeek in Claude Code — Official Setup That Actually Works

As of May 1, 2026, the documented official path is not "plug DeepSeek into claude.ai chat". The official path is to run Claude Code against DeepSeek's Anthropic-compatible endpoint. That means you keep the Claude Code interface, but the model requests go to DeepSeek by overriding the base URL and bearer token. This guide walks through the exact setup, verification steps, and the compatibility limits you should know before rolling it out across a team.

1. Understand the boundary first: this is Claude Code, not claude.ai web chat

DeepSeek now publishes an official Claude Code integration guide, and Anthropic documents the environment variables Claude Code uses for custom routing. That combination gives you a real, source-backed path for running DeepSeek behind the Claude Code terminal or desktop-code workflow.

The important boundary is that these environment-variable overrides are documented for Claude Code sessions, not for the consumer claude.ai chat product. So if the user intent is 'use DeepSeek inside Claude's coding agent workflow', this guide is the correct route. If the intent is 'switch the model inside the normal Claude chat website', that is not what the official docs describe.

Sources checked

2. Install Claude Code and confirm the binary is available

If Claude Code is already installed, you can skip straight to the environment variables. If not, install Node.js 18+ first, then install the official Claude Code package globally. The fastest smoke test is simply to print the version before touching any routing variables.

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

Sources checked

3. Export the DeepSeek routing variables exactly as documented

For Claude Code, DeepSeek's own guide currently uses the Anthropic-compatible endpoint at `https://api.deepseek.com/anthropic`, a bearer token passed through `ANTHROPIC_AUTH_TOKEN`, and explicit model pinning for the main session plus subagents. Use the official values first before you improvise.

Notice the difference between raw Anthropic SDK usage and Claude Code usage. DeepSeek's generic Anthropic API page shows `deepseek-v4-pro` in SDK examples, but the dedicated Claude Code integration guide currently pins `deepseek-v4-pro[1m]` for the main/default route. For Claude Code, follow the dedicated Claude Code page.

Official environment variables for Claude Code -> DeepSeek routing
VariableRecommended valueWhy it matters
ANTHROPIC_BASE_URLhttps://api.deepseek.com/anthropicSends Claude Code traffic to DeepSeek's Anthropic-compatible endpoint.
ANTHROPIC_AUTH_TOKEN<your DeepSeek API key>DeepSeek expects a bearer token on this route.
ANTHROPIC_MODELdeepseek-v4-pro[1m]Primary interactive model route from the official DeepSeek Claude Code guide.
ANTHROPIC_DEFAULT_OPUS_MODEL / ANTHROPIC_DEFAULT_SONNET_MODELdeepseek-v4-pro[1m]Prevents Claude Code aliases from drifting to an Anthropic model name.
ANTHROPIC_DEFAULT_HAIKU_MODEL / CLAUDE_CODE_SUBAGENT_MODELdeepseek-v4-flashKeeps lightweight or delegated work on the cheaper Flash route.
CLAUDE_CODE_EFFORT_LEVELmaxMatches DeepSeek's official example for harder coding and reasoning sessions.
export ANTHROPIC_BASE_URL="https://api.deepseek.com/anthropic"
export ANTHROPIC_AUTH_TOKEN="sk-..."
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"

claude

Sources checked

4. Verify the route before trusting the setup

Do not assume the override worked just because Claude Code launched. Open Claude Code inside your project, run `/status`, and confirm the active auth and model sources look like the DeepSeek-backed configuration you exported. This matters because a bad shell profile, stale login, or typo can silently leave you on a different provider.

One more easy-to-miss detail from DeepSeek's Anthropic API docs: when you pass an unsupported model name, the backend can automatically map it to `deepseek-v4-flash`. That is useful as a fallback, but it is also how people accidentally think they are on Pro when they are not. Exact model strings and `/status` checks are non-optional.

claude
/status

Sources checked

5. Make the configuration persistent, but treat CLI and Desktop as different validation targets

For terminal usage, put the export block in `~/.zshrc`, `~/.bashrc`, or the equivalent shell profile you actually launch Claude Code from. That remains the cleanest, source-backed route because DeepSeek's official Claude Code guide is written around the terminal `claude` workflow.

Be more careful with Claude Code Desktop. Anthropic's desktop docs say the app has its own local environment editor and does not always inherit your full shell environment, while Anthropic's authentication docs separately say API-key-style auth variables such as `ANTHROPIC_AUTH_TOKEN` apply to terminal CLI sessions and Desktop uses OAuth. The safe operational rule is: treat the DeepSeek bearer-token route as CLI-first, and only document a Desktop path in your team if you have verified it with `/status` and a real request on the exact Desktop build you run.

If you still need a machine-local config file for CLI sessions, `~/.claude/settings.json` can carry an `env` block. Just do not overstate that as automatic proof that every Desktop surface will route the same way.

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.deepseek.com/anthropic",
    "ANTHROPIC_AUTH_TOKEN": "sk-...",
    "ANTHROPIC_MODEL": "deepseek-v4-pro[1m]",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "deepseek-v4-pro[1m]",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "deepseek-v4-pro[1m]",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "deepseek-v4-flash",
    "CLAUDE_CODE_SUBAGENT_MODEL": "deepseek-v4-flash",
    "CLAUDE_CODE_EFFORT_LEVEL": "max"
  }
}

Sources checked

6. Know the compatibility limits before you roll this out

DeepSeek's Anthropic API is intentionally compatibility-focused, not a perfect clone of every Anthropic feature. Tool definitions and text-based tool use are supported, but some Anthropic message content types are not. The current DeepSeek compatibility page marks image blocks, document blocks, search_result blocks, and several MCP-specific message/tool fields as unsupported or ignored.

Anthropic's own env-var docs add another operational caveat: when `ANTHROPIC_BASE_URL` points to a non-first-party host, MCP tool search is disabled by default. Only turn `ENABLE_TOOL_SEARCH=true` back on if your proxy or gateway really forwards the required `tool_reference` behavior. Do not assume every custom route preserves the full Claude Code feature surface.

The safe interpretation is simple: use this setup for coding, terminal workflows, text prompts, and ordinary tool-driven sessions. Validate advanced Anthropic-only features individually before you standardize them in team docs.

Sources checked

FAQ

Can I do this inside the normal claude.ai chat UI?

Not through the official environment-variable route described here. The official May 2026 documentation is for Claude Code sessions, not for swapping the model inside the standard claude.ai chat product.

Why use ANTHROPIC_AUTH_TOKEN instead of ANTHROPIC_API_KEY?

Because DeepSeek's Anthropic-compatible endpoint is documented as a bearer-token route for Claude Code. Anthropic's docs also define ANTHROPIC_AUTH_TOKEN as the custom Authorization header value.

Why did my session end up on Flash instead of Pro?

DeepSeek's Anthropic API docs say unsupported model names can auto-map to deepseek-v4-flash. Use the exact model strings from the official Claude Code guide and confirm them with /status.

Will every Claude Code feature behave exactly the same through DeepSeek?

No. Basic text and tool-use flows are the safe baseline, but DeepSeek's compatibility page explicitly marks some Anthropic content types and MCP-related fields as unsupported or ignored.

How do I switch back to official Anthropic models later?

Open a clean shell or remove the DeepSeek-specific environment variables from your session or settings file. The routing override is entirely configuration-driven.

The reliable May 1, 2026 answer to 'how do I connect DeepSeek to Claude?' is: use Claude Code, point `ANTHROPIC_BASE_URL` at DeepSeek's Anthropic endpoint, authenticate with `ANTHROPIC_AUTH_TOKEN`, pin the documented model IDs, and verify with `/status`. Treat it as a real integration path for coding workflows, but do not overstate it as a universal Claude-product model switch.

Related model comparisons

Continue from this guide into structured DeepSeek-first comparison pages with model tables, routing advice, and pricing context.