AI Tools
●11 min read●November 30, 2026●Updated November 30, 2026

Claude Code with DeepSeek: Setup and the Real Cost

Claude Code with DeepSeek: the 9 settings, a cost readout 42x too high and a budget cap that stopped a 0.4 cent job. A managed settings fix, tested.

Paras Tiwari
Paras TiwariFounder, Spectrum AI Labs
Claude Code with DeepSeek: Setup and the Real Cost

Get weekly AI tool reviews

We test tools so you don't have to. No spam.

TL;DR

Claude Code runs on DeepSeek's API with 9 environment variables from DeepSeek's docs. On my Linux server, Claude Code's own cost readout showed $0.2659 for a job that cost $0.0063 off-peak, 42 times too much, by my math. The same wrong prices drive --max-budget-usd, so a $0.05 cap stopped a job after 1 turn when it had really spent $0.004. A modelPricing row in the managed settings file made the readout match DeepSeek's prices in 3 of 3 runs, and with the row in place the same $0.05 cap let the job finish. DeepSeek bills the tokens, so only the displayed number and the cap are wrong.

On November 30, 2026 I ran Claude Code 2.1.310 on deepseek-flash on my own Linux server. I used the same coding task as in my DeepSeek Harness vs Claude Code test, five more times, and read both Claude Code's cost figure and the token counts. Every off-peak dollar figure in this post is my own math: the token counts priced at DeepSeek's list prices, not a bill.

Claude Code with DeepSeek: the 9 settings

You need 9 environment variables. They come from DeepSeek's Claude Code page, and the base URL is https://api.deepseek.com/anthropic. Keep them in a file that only you can read, so the key never lands in your shell history.

install -m 600 /dev/null ~/.claude-deepseek.env
nano ~/.claude-deepseek.env

Put these lines in the file and replace the key placeholder with your own DeepSeek API key.

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=786432

Then load the file in your shell, go to your project and start Claude Code.

source ~/.claude-deepseek.env
cd your-project
claude

That is the Linux and macOS form. DeepSeek's page also gives the same 9 values as PowerShell $env:NAME="value" lines for Windows. I only tested Linux.

For the install, Anthropic's setup page gives a native installer for macOS, Linux and WSL: curl -fsSL https://claude.ai/install.sh | bash. DeepSeek's page says to use Node.js 18 or newer and npm install -g @anthropic-ai/claude-code, then check with claude --version. Anthropic's page now says the npm package needs Node.js 22 or later. Either route gives you the claude command. My server had version 2.1.310.

My first test in the earlier post used 8 of these 9 settings. The runs below all used all 9.

What a Claude Code job really costs on DeepSeek

A small coding job cost between $0.0034 and $0.0063 off-peak across my four finished runs. Claude Code's own figure for the same runs went from $0.0034 to $0.2659, depending on the setup.

The task was the same csvstats.py job as before: build a standard library Python tool for CSV statistics, with its own tests, graded by 5 hidden checks. I ran it headless with claude -p, --output-format json and --dangerously-skip-permissions in a fresh folder each time. All runs were off-peak, from about 16:22 to 17:00 UTC.

Claude Code on deepseek-flash: its own figure against DeepSeek's prices

RunSetupClaude Code showedOff-peak cost, my mathResult
1No fix$0.265918$0.006268Success, 5 turns, 5 of 5 checks
2No fix, --max-budget-usd 0.05$0.152895$0.004002Stopped after 1 turn, no files written
3modelPricing row for deepseek-flash[1m]$0.004485$0.004485Success, 6 turns, 5 of 5 checks
4modelPricing row for deepseek-flash$0.005775$0.005775Success, 5 turns, 5 of 5 checks
5Row for deepseek-flash, --max-budget-usd 0.05$0.003413$0.003413Success, 5 turns, 5 of 5 checks
Earlier test, 6 runsNo fix$0.2388 to $0.5132$0.0057 to $0.0111All 6 passed every hidden check

Source: My own runs on November 30, 2026, Claude Code 2.1.310, deepseek-flash, all 9 settings for runs 1 to 5. The off-peak column is token counts priced at DeepSeek's list price, my math and not an invoice

Run 1 used 14,131 input tokens, 6,615 output tokens and 59,776 cache read tokens. At DeepSeek's off-peak prices that is $0.0063. Claude Code showed $0.2659, which is 42.4 times too much.

The earlier six runs showed the same gap, 42 to 48 times. In total the afternoon tests cost about 3 cents.

Why Claude Code shows the wrong cost with DeepSeek

Claude Code prices every token at list price, so its figure for a DeepSeek job is far too high. Anthropic's costs page says Claude Code "computes the dollar figure locally from token counts at list price, unless a modelPricing table is in effect." It also calls the figure an estimate.

In runs 1 and 2, the total matched my tokens priced at $5 per 1M input, $25 per 1M output and $0.50 per 1M cache reads, to the last digit. The JSON output labeled the cost basis "unknown".

DeepSeek's off-peak prices for deepseek-flash are $0.15 per 1M input tokens, $0.60 per 1M output tokens and $0.003 per 1M cache reads.

Terminal output of the Claude Code usage panel showing Total cost $0.0948 with the note that costs may be inaccurate due to usage of unknown models, followed by usage per model
Terminal output from my session, no fix in place. The panel reads $0.0948 and warns that costs may be inaccurate due to usage of unknown models.

The tokens in that panel cost about $0.0025 at DeepSeek's off-peak prices, working from the rounded counts on screen.

The budget cap uses the wrong prices too

--max-budget-usd counts the same wrong prices, so it stops a DeepSeek job far too early. In run 2 I set a cap of $0.05. Claude Code stopped after 1 turn with the result subtype error_max_budget_usd and the message "Reached maximum budget ($0.05)". No files were written.

Claude Code had counted $0.152895 at that point. The tokens were worth $0.004002 at DeepSeek's off-peak prices.

So the $0.05 cap ended a job that had cost less than half a cent.

Because of run 2, a pricing row is the first thing I would set up on a machine that runs DeepSeek jobs, before I put any budget cap on them.

The fix: a modelPricing row in managed settings

In runs 3 to 5, with a modelPricing row in the managed settings file, Claude Code's total equalled my tokens times the rates in the file, to the last digit. In run 5, the same $0.05 cap that stopped run 2 let the job finish.

The Anthropic settings reference describes modelPricing as a way to "report spend at the rates your organization pays instead of list price". It applies to the usage panel, the status line, the Agent SDK's total_cost_usd, the --max-budget-usd limit and OpenTelemetry. It needs Claude Code 2.1.242 or later.

This is the file I used in runs 4 and 5.

{
  "modelPricing": {
    "overrides": {
      "deepseek-flash": {
        "input": 0.15,
        "output": 0.60,
        "cacheRead": 0.003,
        "cacheWrite": 0.15
      }
    }
  }
}

Running coding agents on real work? Get a practical setup that wastes less of your limit.

Get the Claude Code setup

If the machine already has a managed settings file, add the modelPricing key to it and keep the rest. The rates are USD per 1M tokens. All four are required, or Claude Code drops the row. DeepSeek has no separate cache write price, so I put the cache miss input price in cacheWrite. My runs had zero cache write tokens, so that number never mattered.

Where the file goes depends on the system, according to Anthropic's docs.

Where the managed settings file lives

SystemLocation
Linux and WSL/etc/claude-code/managed-settings.json
macOS/Library/Application Support/ClaudeCode/managed-settings.json
WindowsC:\Program Files\ClaudeCode\managed-settings.json

Source: Anthropic's Claude Code settings documentation, checked November 30, 2026. I only tested the Linux path

Claude Code reads the file at startup and reloads it when the file changes.

To confirm it works, run /usage. The cost line should end with "at your organization's configured rates". In my interactive session with the row in place, the panel showed $0.0024, against $0.0948 in the earlier session without it.

Terminal output of the Claude Code usage panel showing Total cost $0.0024 followed by at your organization's configured rates, with usage per model
Terminal output from my session, with the modelPricing row in place. The panel reads $0.0024, at your organization's configured rates.
  1. It is machine wide. It applies to every Claude Code user on that computer. The row is keyed to a DeepSeek model name, and Anthropic's docs say a non-built-in key applies to that one ID only, so it shouldn't touch Claude models. I removed my file after testing.
  2. It is admin only. Claude Code ignores modelPricing in user, project and local settings, and in --settings. You need write access to the managed location.
  3. It is an off-label use. Anthropic documents modelPricing for organizations with contracted Anthropic rates. Using it for DeepSeek prices is my own use. Neither Anthropic nor DeepSeek documents it. It changes only what Claude Code reports. DeepSeek's bill stays the same.
  4. The rates are fixed numbers. DeepSeek's peak price is double its off-peak price. With off-peak rates in the file, the readout would show half the real cost during peak hours. I didn't test at peak. Peak is 01:00 to 04:00 and 06:00 to 10:00 UTC, Monday to Friday, except Chinese public holidays.
  5. One row covered both model names. The docs say a row applies to that one ID only. On 2.1.310, my deepseek-flash row also priced deepseek-flash[1m]. Run 3 used a deepseek-flash[1m] row, and run 4 showed that the shorter name matched the same model.

If I used the file for budgets, I would put the peak rates in it. Then the cap is right at peak and counts double off-peak, so it never counts too little.

The auto mode billing notice

In auto mode, Claude Code shows a notice that classifier requests are billed, because your requests go through api.deepseek.com. It held the first shell step until I pressed Enter. After that, auto mode kept working.

The notice on my screen began: "We're changing auto mode to no longer charge for classifier requests in Claude Code. However, this session isn't eligible because your requests go through api.deepseek.com, which isn't compatible with this update. Nothing breaks: auto mode keeps working, and its classifier requests are billed as before."

Terminal output of the Claude Code auto mode notice saying the session isn't eligible because requests go through api.deepseek.com
Terminal output from my session. The auto mode notice names api.deepseek.com.

Anthropic's auto mode classifier billing page explains it. In auto mode, a classifier checks actions such as shell commands before they run. When server side checks can't reach the session, for example when a gateway or proxy sits in the path, Claude Code makes its own classifier requests, and those count toward your token usage. On a Pro, Max, Ultra or Team plan you never see the notice.

The same page says that setting CLAUDE_CODE_AUTO_MODE_SERVER=0 makes Claude Code always use its own classifier requests, and the notice doesn't appear. I didn't test it. The docs call it a temporary setting that may be removed in a later release.

In my second session, with the pricing row in place, no notice appeared. The docs say Claude Code remembers an acknowledged notice that names a gateway for 24 hours on that machine. So I can't say the row had any effect on it.

The unrecognized model warning

Claude Code printed an unrecognized model warning in every run, then ran normally. This is the line that went to stderr.

[claude-code:unrecognized_model] {"model":"deepseek-flash[1m]","query_source":"sdk"}

Claude Code doesn't know the name deepseek-flash[1m], which matches the "unknown models" note in the first screenshot. In an earlier run, the JSON output listed deepseek-flash[1m] with a context window of 1,000,000 and a max output of 32,000 tokens.

V4 Pro: mapping and prices

I did not test V4 Pro. DeepSeek's page says model names that start with claude-opus map to deepseek-v4-pro, billed at the V4 Pro price. Names that start with claude-sonnet or claude-haiku map to deepseek-flash. In DeepSeek's 9 settings the Opus name is set to deepseek-flash[1m], so a default setup stays on flash.

DeepSeek API prices per 1M tokens, off-peak and peak

ModelCache hitCache missOutput
deepseek-flash$0.003 / $0.006$0.15 / $0.30$0.60 / $1.20
deepseek-v4-pro$0.022 / $0.044$0.66 / $1.32$1.98 / $3.96

Source: DeepSeek API pricing page, checked November 30, 2026. Peak is 01:00 to 04:00 and 06:00 to 10:00 UTC Monday to Friday, except Chinese public holidays. DeepSeek has no separate cache write price

Pro costs 3.3 times as much per output token as flash. The AI API price index lists the rates for other models.

Claude Code on DeepSeek or DeepSeek Harness

In the earlier test both tools passed every hidden check in 6 of 6 runs: Claude Code at $0.0057 to $0.0111 per job, DeepSeek Harness at $0.0054 to $0.0123. With three runs per task, that gives no cost winner.

For DeepSeek jobs on my own server I'd keep using DeepSeek Harness. Its cost estimate under each answer showed about $0.0072 in one run I checked, the same as my math, with no admin file. If you already work in Claude Code every day, add the pricing row and stay there.

For the DeepSeek Harness side, see the DeepSeek Harness setup guide.

What I didn't test

My tests were five runs of one coding task and two short interactive sessions, on one model and one server. This is not a benchmark.

  • Windows and macOS.
  • deepseek-v4-pro.
  • Peak hours, so the peak price effect on the readout is my reasoning only.
  • Web search. DeepSeek's page says the API supports Claude Code's Web Search tool, that summarizing results costs extra model tokens, and that the search requests themselves aren't billed.
  • Subagents, long sessions and compaction.
  • The CLAUDE_CODE_AUTO_MODE_SERVER=0 setting.

Anthropic doesn't support this setup. Its LLM gateway page says Anthropic "doesn't support routing Claude Code to non-Claude models through any gateway." The setup is DeepSeek's.

Sources

All pages were checked on November 30, 2026. The test runs are mine, from one server on that day, and every dollar figure marked as my math is token counts priced at DeepSeek's list prices, not a bill.

FAQ

Can I use a DeepSeek API key in Claude Code?

Yes. Set the 9 environment variables from DeepSeek's Claude Code page, with ANTHROPIC_BASE_URL pointed at https://api.deepseek.com/anthropic and your DeepSeek key in ANTHROPIC_AUTH_TOKEN, then start claude. I ran it this way on a Linux server with version 2.1.310.

Why does Claude Code show the wrong cost with DeepSeek?

It prices the tokens locally at list price, not at DeepSeek's prices. DeepSeek's bill uses its own, much lower prices.

How much does a Claude Code job cost on DeepSeek?

My small coding job came to between $0.0034 and $0.0063 on deepseek-flash off-peak across four finished runs, by my own math. The six runs in my earlier test ranged from $0.0057 to $0.0111.

Does Claude Code work with DeepSeek V4 Pro?

DeepSeek says model names that start with claude-opus map to deepseek-v4-pro. I only tested deepseek-flash, so I can't say how Pro behaves.

Does Anthropic support Claude Code with DeepSeek?

No. Anthropic's gateway documentation says routing Claude Code to non-Claude models isn't supported. DeepSeek publishes the setup.

How do I stop --max-budget-usd ending a DeepSeek job too early?

Add a modelPricing row for your DeepSeek model to the managed settings file, so the cap counts DeepSeek's prices. With that row, a $0.05 cap let my job finish.

Can I put modelPricing in my own Claude Code settings?

No. Claude Code reads modelPricing only from managed settings and ignores it in user, project and local files. It also needs version 2.1.242 or later.

How do I hide the auto mode billing notice with DeepSeek?

Anthropic's docs say setting CLAUDE_CODE_AUTO_MODE_SERVER=0 hides it. I didn't test that setting.

Paras Tiwari
Written by
Paras Tiwari
Founder, Spectrum AI Labs

Founder of Spectrum AI Labs, testing AI tools and models, and writing up what actually ships.

More about Paras →

Stay ahead of the AI curve

We test new AI tools every week and share honest results. Join our newsletter.