Claude Code with DeepSeek: One Config Block and What It Costs

Claude Code DeepSeek setup: run V4.1 Flash or V4 Pro with one config block. Model IDs, a 2-hour session from $0.97, and the peak-hour price trap.

Agent integrations·Published ·By RouterPlex·7 min

One API key for every model on RouterPlex: vendor list price, $0 top-up fee, from $5.

Create a key

To run Claude Code with DeepSeek, set ANTHROPIC_BASE_URL to https://api.routerplex.com, put your RouterPlex key in ANTHROPIC_AUTH_TOKEN, and set ANTHROPIC_MODEL to deepseek-v4.1-flash or deepseek-v4-pro. RouterPlex bills DeepSeek V4.1 Flash at a flat $0.18 input and $0.73 output per 1M tokens. A 2-hour session costs about $0.97 to $1.52.

This DeepSeek Claude Code guide gives you one config block, the model ids for each Claude Code slot, and a dated cost table. You keep the Claude Code app and its tools. Only the model behind it changes.

Checked 29 October 2026: DeepSeek pricing, DeepSeek Claude Code guide, RouterPlex catalog, Claude Code settings. DeepSeek prices and the RouterPlex catalog re-checked 10 November 2026. Rates change. Read the checkout before a large purchase.

RouterPlex publishes this guide and sells the prepaid wallet described below.

The Claude Code DeepSeek config block

Create a RouterPlex key, export it as ROUTERPLEX_API_KEY, then run this in the same terminal (macOS or Linux):

bash
export ANTHROPIC_BASE_URL="https://api.routerplex.com"
export ANTHROPIC_AUTH_TOKEN="$ROUTERPLEX_API_KEY"
export ANTHROPIC_API_KEY=""
export ANTHROPIC_MODEL="deepseek-v4.1-flash"
export ANTHROPIC_DEFAULT_OPUS_MODEL="deepseek-v4-pro"
export ANTHROPIC_DEFAULT_SONNET_MODEL="deepseek-v4.1-flash"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="deepseek-v4.1-flash"
export CLAUDE_CODE_MAX_CONTEXT_TOKENS="616000"
claude

The base URL has no /v1. Claude Code adds /v1/messages itself. ANTHROPIC_API_KEY is set to empty so an old Anthropic key cannot take over. The context cap is DeepSeek's 1M window minus its 384K max output, as the RouterPlex Claude Code docs describe.

On Windows PowerShell:

powershell
$env:ANTHROPIC_BASE_URL = "https://api.routerplex.com"
$env:ANTHROPIC_AUTH_TOKEN = $env:ROUTERPLEX_API_KEY
$env:ANTHROPIC_API_KEY = ""
$env:ANTHROPIC_MODEL = "deepseek-v4.1-flash"
$env:ANTHROPIC_DEFAULT_OPUS_MODEL = "deepseek-v4-pro"
$env:ANTHROPIC_DEFAULT_SONNET_MODEL = "deepseek-v4.1-flash"
$env:ANTHROPIC_DEFAULT_HAIKU_MODEL = "deepseek-v4.1-flash"
$env:CLAUDE_CODE_MAX_CONTEXT_TOKENS = "616000"
claude

To keep the setting for every session, add an env block to ~/.claude/settings.json (on Windows, %USERPROFILE%\.claude\settings.json). Settings files cannot read shell variables, so paste the key there. Never put it in a project's .claude/settings.json, because that file is usually committed.

json
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.routerplex.com",
"ANTHROPIC_AUTH_TOKEN": "paste-your-routerplex-key-here",
"ANTHROPIC_API_KEY": "",
"ANTHROPIC_MODEL": "deepseek-v4.1-flash",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "deepseek-v4-pro",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "deepseek-v4.1-flash",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "deepseek-v4.1-flash",
"CLAUDE_CODE_MAX_CONTEXT_TOKENS": "616000"
}
}

Before you give it a real repository, send one test call with the exact model id:

bash
curl https://api.routerplex.com/v1/messages \
-H "Authorization: Bearer $ROUTERPLEX_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model": "deepseek-v4.1-flash", "max_tokens": 64, "messages": [{"role": "user", "content": "Say ok."}]}'

Then run /status inside Claude Code. It should show the RouterPlex base URL.

Which DeepSeek model for each Claude Code slot

Claude Code has a main model and three named slots. The Haiku slot runs background work such as titles and short summaries. The Opus slot is what you get when you pick Opus in /model. DeepSeek's own guide maps Opus requests to V4 Pro and everything else to Flash, and the block above does the same.

Claude Code slotModel idContextMax outputInput / cached / output per 1M on RouterPlex
Main, Sonnet, Haikudeepseek-v4.1-flash1M384K$0.18 / $0.065 / $0.73
Opus (hard tasks)deepseek-v4-pro1M384K$0.80 / $0.21 / $2.39

Both ids support tool calling in the RouterPlex catalog. DeepSeek retired the old deepseek-v4-flash id, and it now serves V4.1 Flash at the same price, so use the v4.1 id. Model pages: DeepSeek V4.1 Flash and DeepSeek V4 Pro.

What a 2-hour Claude Code session costs on DeepSeek

Method: a 2-hour Claude Code session is modelled as 60 agent turns of 100K input and 10K output tokens. That is 6M input and 600K output in total. The cache column assumes 80% of input is read from cache (input the provider has already seen in an earlier turn). Cache hits depend on the upstream, so treat that column as "up to". These numbers are computed from catalog rates checked 29 October 2026, not measured.

Model and routeNo cache80% cache reads
deepseek-v4.1-flash on RouterPlex (flat)$1.52$0.97
deepseek-v4-pro on RouterPlex (flat)$6.23$3.40
DeepSeek Flash direct, off-peak$1.26$0.55
DeepSeek Flash direct, peak$2.52$1.11
DeepSeek V4 Pro direct, off-peak$5.15$2.09
DeepSeek V4 Pro direct, peak$10.30$4.17
Claude Sonnet 4.6, Anthropic list$27.00$14.04
Claude Opus 5.5, Anthropic list$36.00$17.76

Sources: RouterPlex catalog, DeepSeek pricing, Claude pricing, all checked 29 October 2026. Claude cache writes are left out, which flatters the Claude rows slightly.

Flash runs a long session for under $2. Pro costs about four times as much. Use it when Flash keeps failing the same task.

DeepSeek peak hours: why your Claude Code bill will not double at 9 a.m. UTC

DeepSeek charges double from 01:00 to 04:00 and 06:00 to 10:00 UTC, Monday to Friday, except Chinese public holidays. Off-peak, Flash costs $0.15 input and $0.60 output per 1M. At peak it costs $0.30 and $1.20. A European workday morning lands right in the peak window.

RouterPlex bills one flat, time-weighted rate instead. Peak covers 35 of the 168 hours in a week (about 21%). So the flat Flash rate is $0.18 input and $0.73 output at any hour, with 0% markup on that average. You pay less than DeepSeek during peak hours and about 21% more off-peak. The bill is the same whenever you work.

Cache reads are the exception. RouterPlex bills Flash cache reads at $0.065 per 1M, set by our upstream cost. DeepSeek lists $0.003 off-peak. On cache-heavy sessions, DeepSeek direct is cheaper, as the table above shows.

Using DeepSeek's own Anthropic endpoint instead

DeepSeek runs its own Anthropic-compatible endpoint at https://api.deepseek.com/anthropic and publishes a Claude Code guide. It uses the same variables with a DeepSeek Platform key and its own model names (deepseek-flash and deepseek-v4-pro). The Anthropic API guide lists what it ignores, such as cache_control and top_k. DeepSeek also says server-side web search through Claude Code bills $0.75 per 1,000 requests from 1 November 2026 (Beijing time).

If you only ever use DeepSeek and mostly work off-peak, the direct route is cheaper.

A RouterPlex key helps in other cases. One key switches between DeepSeek, Kimi, GLM, Qwen and other catalog models by changing one variable. Each key can carry a hard USD cap, so an agent loop stops at the number you set. The price is flat at any hour. Card or crypto top-ups carry a $0 fee, and the balance stops at $0 instead of going negative.

Claude Code DeepSeek troubleshooting

401 or a login prompt

Claude Code cannot find your key, or an old ANTHROPIC_API_KEY is taking precedence. Put the RouterPlex key in ANTHROPIC_AUTH_TOKEN and set ANTHROPIC_API_KEY to empty. Do not run /login. That signs in to Anthropic, not RouterPlex. If you see a warning about two credential sources, run /logout once.

404 or 400 model not found

The id is wrong. DeepSeek ids on RouterPlex use a dot in the version (deepseek-v4.1-flash), and DeepSeek's direct names such as deepseek-flash will not work here. Copy the id from the model catalog and check every model variable, including the Opus and Haiku slots.

402 payment required

Your balance or the key's budget is used up. Retrying will not help. The error message carries a billing link. Top up or raise the key budget, then rerun. Details are in the errors docs.

429 too many requests

You hit a rate limit or a rolling-window budget. Wait a few seconds and retry with backoff. Long agent loops with many parallel tool calls hit this first.

Tool calls or file edits fail

Some models follow Claude Code's tool format less reliably than Claude. If edits keep failing, move the main model to deepseek-v4-pro and keep the Haiku slot on Flash. Run a small read-only task first to check the round trip.

Context length errors

Set CLAUDE_CODE_MAX_CONTEXT_TOKENS to 616000 so Claude Code compacts before it overruns the 1M window. Run /compact by hand on very long sessions.

Set a hard budget on the Claude Code key

An agent left running overnight can make hundreds of calls. Give Claude Code its own RouterPlex key and set a hard lifetime budget on it, such as $5 for a first test. When the key reaches that number, requests stop with a 402 and nothing more is charged. Your account balance also stops at $0, so a runaway loop cannot push you into debt. Set the budget in the dashboard when you create the key. The keys and budgets docs show how. Use one key per tool or repository so you can see which agent spent what.

Try DeepSeek in Claude Code with $1 of test credit, no card. Compare models on the DeepSeek V4.1 Flash page or see how RouterPlex compares on fees at /vs/openrouter.

Common questions

Frequently asked questions

Can Claude Code use DeepSeek?

Yes. Claude Code sends Anthropic Messages requests to whatever ANTHROPIC_BASE_URL points at, and it accepts a non-Claude model id in ANTHROPIC_MODEL. Point it at https://api.routerplex.com with your RouterPlex key in ANTHROPIC_AUTH_TOKEN, then set the model variables to deepseek-v4.1-flash or deepseek-v4-pro. DeepSeek also runs its own Anthropic-compatible endpoint at https://api.deepseek.com/anthropic with a Claude Code guide in its API docs. Either route keeps the Claude Code app, its tools and its workflow. Only the model behind it changes. Checked 29 October 2026.

Which DeepSeek model is best for Claude Code?

Start with deepseek-v4.1-flash in every slot. It has a 1M-token context, 384K max output and tool calling, and on RouterPlex it costs a flat $0.18 input and $0.73 output per 1M tokens. Move the main or Opus slot to deepseek-v4-pro ($0.80 input, $2.39 output on RouterPlex) for hard multi-file work, and keep the Haiku slot on Flash so background tasks stay cheap. The old id deepseek-v4-flash is retired by DeepSeek and now serves V4.1 Flash at the same price, so use the v4.1 id. Prices checked 29 October 2026 in the RouterPlex catalog at https://routerplex.com/api/models.

How much does Claude Code cost with DeepSeek?

A 2-hour session, modelled as 60 turns of 100K input and 10K output tokens, costs $1.52 on deepseek-v4.1-flash through RouterPlex with no cache hits. With 80% of input read from cache it drops to about $0.97. The same session on deepseek-v4-pro costs $6.23 with no cache and $3.40 with cache. For scale, Anthropic lists Claude Sonnet 4.6 at $3 input and $15 output, which makes the same session $27.00 without cache. These figures are computed from catalog rates checked 29 October 2026, not measured from a live session.

Do I need a DeepSeek account to use DeepSeek in Claude Code?

No, not through RouterPlex. One RouterPlex key reaches DeepSeek and the other providers in the catalog, so you need no DeepSeek Platform account. You top up a prepaid USD balance by card or crypto with a $0 top-up fee and a $5 minimum. The balance stops at $0 and never goes negative. If you prefer to pay DeepSeek directly, create a key on the DeepSeek Platform and use their endpoint at https://api.deepseek.com/anthropic instead. Checked 29 October 2026.

How do I switch Claude Code back to Claude models?

Unset the variables you exported, or delete the env block from ~/.claude/settings.json, then restart claude. With no ANTHROPIC_BASE_URL set, Claude Code goes back to Anthropic and asks you to log in with a Claude plan or an Anthropic API key. To use Claude through RouterPlex instead, keep the base URL and key and set the model variables to a Claude id from the catalog, such as claude-sonnet-4-6.

Run the smallest paid test.

Add $5, cap the key, and verify the result with your own workload. No subscription, and credit never expires — a first top-up of $25+ is matched with $25 extra.