Guide
Claude Code DeepSeek Setup: How to Switch the Model
If you want to run Claude Code with DeepSeek, you have two real routes. You can point Claude Code at an Anthropic-compatible DeepSeek endpoint yourself, or launch it through a router that handles the model swap for you. Both work. The difference is how much configuration you maintain and how you pay.
This guide covers both. It also explains what changes (and what doesn't) once Claude Code stops talking to Anthropic's models, and it digs into the details that trip people up: environment variables, model names, token limits, and checking that the switch actually took effect.
Full disclosure: we make dl.new.
Why switch Claude Code to DeepSeek at all?
Claude Code is a terminal-based coding agent. It reads your repo, edits files, runs commands, and keeps looping until the task is done. That loop eats tokens. A single "fix this failing test suite" request can trigger dozens of model calls, each carrying a large context.
On proprietary models under per-token billing, that adds up quickly. Open-weight models like DeepSeek are cheaper to serve, and for a lot of everyday work (refactors, test writing, boilerplate, bug fixes in a codebase you know) they're good enough that the price gap matters more than the quality gap.
The tradeoff is real, though. You give up some reliability on the hardest tasks: long multi-file architectural changes, ambiguous specs, and tricky debugging. Many developers end up splitting the work. DeepSeek handles the bulk of it, and a stronger proprietary model steps in when a task genuinely needs it.
How Claude Code decides which model to call
Claude Code doesn't hardcode a connection to one server. It reads its configuration from environment variables and settings files, and that's what makes switching possible.
The variables that matter:
ANTHROPIC_BASE_URL: the API endpoint Claude Code sends requests to. Change this and your traffic goes somewhere else.ANTHROPIC_AUTH_TOKEN(orANTHROPIC_API_KEY): the credential sent with each request.ANTHROPIC_MODEL: the model name to request.ANTHROPIC_DEFAULT_HAIKU_MODEL(older versions:ANTHROPIC_SMALL_FAST_MODEL): the lighter model Claude Code uses for quick background jobs like summarizing and naming.
One requirement to keep in mind: the endpoint you point at has to speak the Anthropic Messages API format, because that's what Claude Code sends. A plain OpenAI-style endpoint won't work unless something translates in between.
Method 1: Point Claude Code at a DeepSeek endpoint yourself
If a provider exposes an Anthropic-compatible endpoint for DeepSeek, setup is mostly a matter of exporting variables.
Step 1: Get an API key and base URL
Sign up with a provider that serves DeepSeek through an Anthropic-compatible API and copy two things: the base URL and your key. Check the provider's docs for the exact path. It varies, and getting it wrong is the most common reason a first run fails.
Step 2: Export the environment variables
In your shell:
export ANTHROPIC_BASE_URL="https://your-provider.example/anthropic"
export ANTHROPIC_AUTH_TOKEN="your-api-key"
export ANTHROPIC_MODEL="deepseek-model-name"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="deepseek-model-name"
# older Claude Code versions: export ANTHROPIC_SMALL_FAST_MODEL="deepseek-model-name"
Use the exact model identifier your provider documents. Names differ between providers even for the same underlying model, and a typo gets you a model-not-found error rather than a quiet fallback.
Step 3: Make it persistent (optional)
Exports disappear when you close the terminal. To keep the setup, add the lines to your shell profile (~/.zshrc or ~/.bashrc), or define the variables in Claude Code's settings file under an env block so they apply per project or per user.
A per-project settings file is the cleaner choice if you only want DeepSeek on certain repos and Anthropic's models everywhere else.
Step 4: Launch and verify
Run claude in your project directory, then use the /model command inside the session to see which model is active. Ask it something trivial and watch your provider's usage dashboard. If the requests show up there, the switch worked. If they land on your Anthropic account instead, a variable isn't being read, usually because the shell you exported in isn't the one you launched from.
Method 2: Launch Claude Code through a router
Managing keys, base URLs, and model names by hand works, but it gets tedious when you want several models or use more than one coding tool. A router takes that configuration out of your shell.
With dl.new, you create a key, install with curl -fsSL https://dl.new | sh, then run dl claude (or just dl in a project folder). dl routes requests to open-weight models across multiple providers, so you aren't hand-editing environment variables or keeping track of which provider serves which model.
dl starts Claude Code, OpenCode, Codex, Pi and T3 Code with one command (dl claude, dl opencode, ...). Grok Build (formerly Cursor), Cline and Zed connect with a dl API key and the base URL https://api.dl.new/anthropic or https://api.dl.new/v1.
Billing works differently too. Instead of per-token charges, plans come with weekly token allowances. An agent that loops for forty calls doesn't produce a surprise invoice. It draws down an allowance that resets weekly.
What the plans include
| Plan | Price |
|---|---|
| Starter | $7/mo |
| Plus | $20/mo |
| Max | $60/mo |
Plans start at $7/month. Each plan's weekly allowance is on pricing. Every token figure on dl.new is quoted with 95.5% caching applied. That matters for agent workloads, since Claude Code resends large, mostly unchanged context on every call.
Each model has a hard weekly limit that resets every Monday at 00:00 UTC. At your Kimi limit, requests fall back to DeepSeek automatically. At your DeepSeek limit, requests pause until the reset. We never charge overage.
Which method should you pick?
Go direct (Method 1) if you already have a provider account you like, you want full control over the endpoint, and you don't mind maintaining a few environment variables.
Use a router (Method 2) if you switch between tools, want predictable weekly allowances instead of metered billing, or don't want to debug base URLs and model identifiers every time a provider changes something.
Common problems and fixes
"Model not found" or 404 errors. The model name doesn't match what the endpoint expects, or the base URL path is wrong. Check both against the provider's docs, character by character.
Requests still going to Anthropic. Your variables aren't set in the shell that launched Claude Code. Run echo $ANTHROPIC_BASE_URL in that exact terminal. If it prints nothing, the export didn't carry over.
Authentication failures. Some endpoints expect ANTHROPIC_AUTH_TOKEN, others ANTHROPIC_API_KEY. Setting the wrong one gives you a 401 even with a valid key. If the first fails, try the other.
Tool use behaves oddly. Claude Code leans heavily on structured tool calls for file edits and shell commands. A model or endpoint with weaker tool-call handling can produce malformed edits or stall mid-task. If the agent keeps failing on the same step, simplify the task or retry on a stronger model.
Quality dips on large changes. That's the expected tradeoff, not a bug. Break big tasks into smaller, well-scoped ones, and give the agent clear acceptance criteria, such as a test that must pass.
Tips for getting good results from DeepSeek in Claude Code
- Be specific. Open-weight models forgive vague prompts less than frontier ones do. Name the file, the function, and the behavior you expect.
- Lean on tests. A failing test is the best instruction you can hand an agent, because it defines "done" without ambiguity.
- Keep context lean. Put project conventions in a
CLAUDE.mdfile instead of re-explaining them every session. Less repeated context also stretches your token allowance. - Commit often. Agents wander. Frequent commits make it painless to roll back a bad run.
- Escalate selectively. Keep a stronger model within reach for the 10% of tasks where DeepSeek struggles, rather than defaulting everything to the most expensive option.
Frequently asked questions
Can Claude Code use DeepSeek instead of Claude models?
Yes. Claude Code reads its endpoint and model from environment variables, so you can point it at any Anthropic-compatible API serving DeepSeek. You can also launch it through a router like dl.new, which handles the routing for you.
Which environment variables do I need to switch the model?
At minimum, ANTHROPIC_BASE_URL, an auth variable (ANTHROPIC_AUTH_TOKEN or ANTHROPIC_API_KEY), and ANTHROPIC_MODEL. Setting ANTHROPIC_DEFAULT_HAIKU_MODEL (older versions: ANTHROPIC_SMALL_FAST_MODEL) as well keeps background tasks off the original Anthropic model.
How do I confirm Claude Code is really using DeepSeek?
Run /model inside the session to see the active model, then check that requests appear in your provider's usage dashboard. If they show up on your Anthropic account instead, your variables aren't being read.
Will DeepSeek be as good as Claude for coding?
For routine work like tests, refactors, boilerplate, and bug fixes in a familiar codebase, it's often good enough. On long, ambiguous, multi-file tasks, proprietary models still tend to be more reliable. Plan on a hybrid setup.
Do I need a separate tool to use Grok Build (formerly Cursor) or Cline?
dl starts Claude Code, OpenCode, Codex, Pi and T3 Code with one command (dl claude, dl opencode, ...). Grok Build, Cline and Zed connect with a dl API key and the base URL https://api.dl.new/anthropic or https://api.dl.new/v1.
What happens when I hit my weekly token limit on dl.new?
Each model has a hard weekly limit that resets every Monday at 00:00 UTC. At your Kimi limit, requests fall back to DeepSeek automatically. At your DeepSeek limit, requests pause until the reset. We never charge overage.
Can I switch back to Anthropic models later?
Yes. Unset the environment variables (or launch claude normally, without the router) and Claude Code goes back to its default behavior.
Conclusion
Switching Claude Code to DeepSeek comes down to one idea: Claude Code sends Anthropic-format requests to whatever endpoint you tell it to. Set the base URL, credential, and model name correctly, confirm with /model, and you're running on DeepSeek within minutes.
If you'd rather skip the variable juggling and get one flat bill instead of per-token billing, create your dl key, install the CLI, and launch Claude Code through it.