Disclosure: I run HaryAI, one of the providers used below.
Claude Code talks to any backend that speaks Anthropic's Messages API. You point it somewhere else with a handful of environment variables, and it stops caring that the model behind them isn't Claude. DeepSeek publishes exactly that kind of endpoint, so you can run Claude Code on DeepSeek V4 without touching your Claude subscription at all.
Below is the setup against DeepSeek's own API, the one gotcha its guide doesn't mention, and, at the end, the same setup through HaryAI, a gateway I run that resells the same models at a discount.
The models
DeepSeek currently serves two models behind this endpoint:
| Model | Model ID | Served by | Context | Max output | Image input |
|---|---|---|---|---|---|
| DeepSeek V4.1 Flash | deepseek-flash |
DeepSeek-V4.1-Flash-1017 | 1,048,576 tokens | 384,000 tokens | Yes |
| DeepSeek V4 Pro | deepseek-v4-pro |
DeepSeek-V4-Pro-0813 | 1,048,576 tokens | 384,000 tokens | No |
deepseek-flash and deepseek-v4-pro are the model IDs DeepSeek itself publishes for its API, not a label some wrapper invented. Flash is the one to default to: it reads images, and it's built for everyday text and code work. Pro is for harder reasoning and review, text only.
(An older ID, deepseek-v4-flash, is accepted on the same endpoint for compatibility; DeepSeek now serves it with V4.1 Flash and bills it at the Flash price.)
Point Claude Code at DeepSeek
Claude Code's CLI and VS Code extension both read ~/.claude/settings.json. Back it up first, then add this to its env block (create the file with {} if it doesn't exist yet):
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.deepseek.com/anthropic",
"ANTHROPIC_AUTH_TOKEN": "<your DeepSeek API key>",
"ANTHROPIC_MODEL": "deepseek-flash[1m]",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "deepseek-flash[1m]",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "deepseek-flash[1m]",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "deepseek-flash",
"CLAUDE_CODE_SUBAGENT_MODEL": "deepseek-flash",
"CLAUDE_CODE_EFFORT_LEVEL": "max",
"CLAUDE_CODE_AUTO_COMPACT_WINDOW": "786432"
}
}
If the file already has an env block, add these entries to it and leave the rest alone. Start a new Claude Code session and send it a short message to confirm it answers.
What each entry does:
-
ANTHROPIC_BASE_URLsends Claude Code's requests to DeepSeek instead of Anthropic. -
ANTHROPIC_AUTH_TOKENis your DeepSeek key. No Claude account is involved. -
ANTHROPIC_MODELis the main model: V4.1 Flash with its full 1M-token context. The[1m]suffix is what tells Claude Code this model has that context window. -
ANTHROPIC_DEFAULT_OPUS_MODELandANTHROPIC_DEFAULT_SONNET_MODELcatch every place Claude Code would otherwise reach for Opus or Sonnet, so those also run on DeepSeek. -
ANTHROPIC_DEFAULT_HAIKU_MODELcovers small background jobs, like naming a session. -
CLAUDE_CODE_SUBAGENT_MODELputs subagents on DeepSeek too. -
CLAUDE_CODE_EFFORT_LEVEL=maxmakes it think as hard as it can on every task. -
CLAUDE_CODE_AUTO_COMPACT_WINDOW=786432delays the conversation summary until you're near 768K tokens instead of the default 200K, since you actually have the room now.
The gotcha: the Artifact tool
Add only the block above and your first request can fail with a 400, no matter which model you pick. The cause is Claude Code's Artifact tool: it's included in the tool list Claude Code sends on every request by default, and DeepSeek's endpoint rejects that tool definition outright. This isn't something DeepSeek's own integration guide mentions.
The fix is one more setting:
"CLAUDE_CODE_DISABLE_ARTIFACT": "1"
Add it to the same env block and start a new session.
Switching to V4 Pro
Change deepseek-flash to deepseek-v4-pro in the three main model entries (ANTHROPIC_MODEL, ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL) and keep the [1m] suffix. Pro reads text only, so anything you paste as a screenshot gets skipped rather than read.
Undoing it
Restore the .bak copy of ~/.claude/settings.json, or delete the entries you added from its env block, then start a new session. Your projects and sessions aren't touched either way, since nothing else in the file changes.
One thing that stays odd either way: Claude Code's UI keeps showing "Opus," "Sonnet" and "Haiku" as model names. Those are Claude Code's own labels for its internal roles, not a claim about which model answers. With this setup, every one of them is DeepSeek.
Running the same setup through HaryAI
Everything above works unchanged if you swap two values: the base URL and the key.
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.haryai.com",
"ANTHROPIC_AUTH_TOKEN": "<your HaryAI key>",
"ANTHROPIC_MODEL": "deepseek-flash[1m]",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "deepseek-flash[1m]",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "deepseek-flash[1m]",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "deepseek-flash",
"CLAUDE_CODE_SUBAGENT_MODEL": "deepseek-flash",
"CLAUDE_CODE_EFFORT_LEVEL": "max",
"CLAUDE_CODE_AUTO_COMPACT_WINDOW": "786432",
"CLAUDE_CODE_DISABLE_ARTIFACT": "1"
}
}
The model IDs are the same, because HaryAI is a gateway in front of DeepSeek (and other models), not a separate catalog with its own names. The reason to point here instead of at DeepSeek directly is price: HaryAI bills input and output at 45% of DeepSeek's peak list price around the clock, so it's 55% off during DeepSeek's peak hours and about 10% off during its off-peak hours. The CLAUDE_CODE_DISABLE_ARTIFACT fix applies here too, for the same reason.
If you'd rather not hand-edit JSON, CC Switch is a free app, installed from its GitHub releases page, that can import a provider's settings into Claude Code for you.
FAQ
Why does Claude Code still list Opus, Sonnet and Haiku?
Those are Claude Code's own labels. With either setup above, every one of them runs on DeepSeek.
Do my projects and sessions stay?
Yes. Only the env entries change; everything else in your setup stays as it is.
Sources: DeepSeek API Docs: Integrate with Claude Code, DeepSeek API Docs: Models & Pricing.
More on this setup: https://haryai.com/en/deepseek-claude-code
Top comments (0)