Claude Code on DeepSeek — 95% Cheaper, Same Interface
A four-line .bat file that redirects the Claude Code CLI to DeepSeek’s API — keeping the familiar interface while cutting costs dramatically.
After getting Claude Code running against a local Ollama instance, the next natural experiment was pointing it at DeepSeek’s API instead. The goal: keep the polished Claude Code interface and agentic loop, but swap out the model for something dramatically cheaper — without touching any Claude Code internals.
Spoiler: it works, and it takes four lines of batch script.
Why DeepSeek?
DeepSeek offers an Anthropic-compatible API endpoint at https://api.deepseek.com/anthropic. Because it speaks the same Messages API format that Claude Code expects, no proxy, adapter, or patching is needed. You just point the CLI at a different base URL and hand it a DeepSeek API key.
The cost difference is significant:
For long coding sessions with large codebases — the exact use case Claude Code is built for — that difference adds up fast.
The batch file
The entire setup fits in a single .bat file. Save it anywhere on your PATH and call it instead of claude:
:: claude-deepseek.bat :: Launches Claude Code CLI pointed at DeepSeek's Anthropic-compatible API @echo off set ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic set ANTHROPIC_AUTH_TOKEN=YOUR_DEEPSEEK_API_KEY set ANTHROPIC_MODEL=deepseek-v3 set ANTHROPIC_DEFAULT_SONNET_MODEL=deepseek-v3 claude %*
Never commit this file to a public repository. The API key is stored in plain text. Add the filename to your .gitignore, or store the key in a Windows environment variable and reference it as %DEEPSEEK_API_KEY%.
The %* at the end passes any arguments through to Claude Code unchanged, so flags like --continue or --model still work as expected.
How it works
Claude Code reads three environment variables before making any API call:
| Variable | Purpose |
|---|---|
| ANTHROPIC_BASE_URL | Overrides the API endpoint. Any server speaking the Anthropic Messages API format works here. |
| ANTHROPIC_AUTH_TOKEN | The API key sent in the Authorization header. DeepSeek validates this against your account. |
| ANTHROPIC_MODEL | The model string forwarded in the request body. Must match a model name DeepSeek recognizes. |
| ANTHROPIC_DEFAULT_SONNET_MODEL | Claude Code internally defaults to a Sonnet-class model for many operations. This variable overrides that default. |
Setting these four variables before invoking claude is all that is needed. The CLI never knows it is not talking to Anthropic.
Model naming
DeepSeek’s model names on their Anthropic-compatible endpoint follow their own convention. At time of writing:
deepseek-v3 # general-purpose, fast deepseek-r1 # reasoning model, slower but stronger on complex tasks
Check DeepSeek’s documentation for the current list — model names can change between API versions.
Limitations to be aware of
This approach works well for routine coding tasks, but there are a few things to keep in mind:
- Context window — DeepSeek V3 supports up to 128k tokens, which is sufficient for most projects but smaller than Claude’s 200k limit.
- Tool use fidelity — Claude Code relies heavily on tool/function calling. DeepSeek is generally reliable here, but edge cases exist with complex nested tool calls.
- Model updates — DeepSeek updates their models more frequently than Anthropic. A model string that works today may behave differently after a silent update.
- Data privacy — Unlike the fully local Ollama setup, your code is still sent to an external API. Factor this in for sensitive or proprietary projects.
Keep both setups — a claude-deepseek.bat for cloud-backed sessions and a claude-local.bat pointing at Ollama on 192.168.1.10. Use DeepSeek for complex multi-file work, local Ollama for anything sensitive or offline.
Getting a DeepSeek API key
Create an account at platform.deepseek.com, navigate to API keys, and generate a new key. Top up credit as needed — the rates are low enough that a small amount goes a long way for coding sessions.
That is genuinely all there is to it. Four environment variables, one .bat file, and Claude Code works exactly as you would expect — file editing, multi-step reasoning, shell commands — just billed at a fraction of the usual cost.
// tested on Windows 11 · Claude Code CLI 1.x · DeepSeek V4 via api.deepseek.com/anthropic