How to set up Claude Code with DeepSeek
Get a DeepSeek API key
Create one on platform.deepseek.com under API keys, and add balance to the account; usage is billed per token.
Install Claude Code if you haven't
DeepSeek's guide installs it with npm: Node.js 18 or later, Git for Windows on Windows, then
npm install -g @anthropic-ai/claude-codeandclaude --versionto check.Set the environment variables (macOS and Linux)
These point Claude Code at DeepSeek's Anthropic-compatible endpoint, use
deepseek-flashwith its 1M context for the main model and subagents, and raise the effort level and auto-compact window. Put them in your shell profile to keep them.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=786432Or on Windows (PowerShell)
The same settings as PowerShell environment variables for the current session.
$env:ANTHROPIC_BASE_URL="https://api.deepseek.com/anthropic" $env:ANTHROPIC_AUTH_TOKEN="<your DeepSeek API Key>" $env:ANTHROPIC_MODEL="deepseek-flash[1m]" $env:ANTHROPIC_DEFAULT_OPUS_MODEL="deepseek-flash[1m]" $env:ANTHROPIC_DEFAULT_SONNET_MODEL="deepseek-flash[1m]" $env:ANTHROPIC_DEFAULT_HAIKU_MODEL="deepseek-flash" $env:CLAUDE_CODE_SUBAGENT_MODEL="deepseek-flash" $env:CLAUDE_CODE_EFFORT_LEVEL="max" $env:CLAUDE_CODE_AUTO_COMPACT_WINDOW="786432"Start Claude Code in your project
Run
cdinto the project andclaude. Everything else, such as CLAUDE.md, skills, hooks and MCP servers, is configured as usual.
How Claude model names map to DeepSeek models
When Claude Code (or the Claude desktop app) sends a Claude model name to DeepSeek's endpoint, DeepSeek maps it like this. That's why the setup above sets every model variable to deepseek-flash: otherwise anything that asks for Opus is billed at V4 Pro prices.
| Model name Claude Code sends | DeepSeek model used | Notes |
|---|---|---|
claude-opus-* | deepseek-v4-pro | Billed at V4 Pro prices |
claude-sonnet-*, claude-haiku-* | deepseek-flash | DeepSeek-V4.1-Flash; accepts images |
deepseek-flash[1m] | deepseek-flash with a 1,048,576-token context | As set in DeepSeek's recommended variables |
What it costs
DeepSeek API prices in US dollars per million tokens on November 6, 2026. Off-peak rates (outside 01:00–04:00 and 06:00–10:00 UTC on weekdays) are half of peak. Web search in Claude Code also works against DeepSeek's API, but each search adds model tokens to summarize results and is billed under DeepSeek's Search API.
| Per 1M tokens | deepseek-flash, peak | deepseek-flash, off-peak | deepseek-v4-pro, peak | deepseek-v4-pro, off-peak |
|---|---|---|---|---|
| Input, cache hit | $0.006 | $0.003 | $0.044 | $0.022 |
| Input, cache miss | $0.30 | $0.15 | $1.32 | $0.66 |
| Output | $1.20 | $0.60 | $3.96 | $1.98 |
Using DeepSeek in Codex
DeepSeek also supports Codex, through the Responses API. Its guide offers a setup script that backs up ~/.codex/config.toml, writes a ~/.codex/models.json catalog with deepseek-flash and deepseek-v4-pro, and adds a DeepSeek provider; one configuration then covers the Codex CLI, the ChatGPT desktop app and the VS Code extension. Read the script before running it, or follow the manual steps in the same guide. Built-in web search is turned off by the script and is available only with deepseek-v4-pro. For Codex's own instruction files, see the Codex AGENTS.md guide.
Claude Code with DeepSeek vs DeepSeek Harness
- Claude Code with DeepSeek: you keep Claude Code's interface and habits, including CLAUDE.md, skills, hooks and plugins, and pay DeepSeek's per-token prices instead of a Claude plan.
- DeepSeek Harness: DeepSeek's own open-source agent app, built around plugins, with a desktop app and web UI; it can also run Claude Code or Codex as subagents. See the DeepSeek Harness guide.
- Either way, the models are the same
deepseek-flashanddeepseek-v4-pro, billed by DeepSeek. - To switch back to Anthropic's models, unset the variables (or open a new shell without them) and sign in to Claude Code as usual.
Cheap models, working all day
Running Claude Code or DeepSeek Harness on DeepSeek's prices makes it affordable to keep agents busy. Crewmark turns those sessions into AI employees with a role, a goal and working hours, and wakes each one on a heartbeat to take the next issue from a board.
Use the setup you already have
An employee runs in a Claude Code, Codex, DeepSeek Harness or OpenCode session on your machine, with your environment and keys.
Let the heartbeat start the work
During working hours it wakes every 15, 30 or 60 minutes in the same conversation and takes the next issue; see how to make Claude Code proactive.
Keep the bill in check
Working hours and one issue at a time keep usage predictable; see how to reduce Claude Code token usage.
Claude Code with DeepSeek FAQ
Can Claude Code use DeepSeek models?
Yes. DeepSeek's API is Anthropic-compatible at https://api.deepseek.com/anthropic. Set ANTHROPIC_BASE_URL to it and ANTHROPIC_AUTH_TOKEN to your DeepSeek API key, as DeepSeek's guide shows.
Which DeepSeek model should I use in Claude Code?
DeepSeek's guide sets deepseek-flash (DeepSeek-V4.1-Flash) with a 1M context for every role. deepseek-v4-pro is used when a request asks for an Opus model, at higher prices.
How much does Claude Code with DeepSeek cost?
Only DeepSeek API usage: for deepseek-flash, $0.30 per million input tokens on a cache miss and $1.20 per million output tokens at peak, half that off-peak, and much less for cached input.
Does web search work in Claude Code with DeepSeek?
Yes. DeepSeek supports Claude Code's web search tool; each search adds model tokens to summarize results and is billed under DeepSeek's Search API.
Do I need a Claude subscription?
No. With these variables, Claude Code sends requests to DeepSeek and bills your DeepSeek account instead of a Claude plan.
Can I use DeepSeek in Codex too?
Yes. DeepSeek documents a Codex setup through the Responses API, with a script or manual edits to ~/.codex/config.toml and ~/.codex/models.json.
Claude Code with DeepSeek or DeepSeek Harness?
If you like Claude Code's tools and workflow, keep it and switch the model. If you want DeepSeek's own plugin-based app with a desktop UI, try DeepSeek Harness.
Checked against DeepSeek's API docs (Claude Code and Codex integrations, pricing) on November 6, 2026.