Claude Code on DeepSeek V4.1-Flash-1017: Setup, Opus Trap, Real Cost

Run Claude Code on DeepSeek V4.1-Flash-1017: the env vars, why an unset Opus slot bills at V4 Pro rates, and a 24-run test of Flash-1017 vs V4 Pro with hidden-test grading and real token cost.

Claude Code on DeepSeek V4.1-Flash-1017 cover; editorial artwork of a terminal agent, not a benchmark chart

A setup tip making the rounds on X this week fits in one line: point Claude Code at DeepSeek’s Anthropic endpoint “and set EVERY model name to deepseek-flash. skip one and ‘opus’ quietly goes to V4 Pro.” The tip is right; DeepSeek’s docs describe the same mapping. The same thread of posts also quotes cost numbers you can’t check from a screenshot: “ONE PAYS $10. THE OTHER PAYS $0.20,” “about 50x less per task,” and a one-shot demo billed as 120x cheaper than Opus 5.5.

So I ran it. On October 21, 2026, I gave Claude Code the same six Python repository tasks we used in our October 3 Claude Code model test, two runs each, on DeepSeek-V4.1-Flash-1017 and on DeepSeek V4 Pro, with hidden tests deciding pass or fail. This post gives the setup, the Opus mapping trap, and what those 24 runs actually cost. The scope is narrow: six small Python tasks, one harness, one day, through SandBase. It is a sanity check, not a leaderboard.

Key takeaway

  • DeepSeek’s Claude Code guide sets every model slot to deepseek-flash. On DeepSeek’s Anthropic endpoint, any claude-opus* name maps to deepseek-v4-pro and bills at V4 Pro rates, which are 4.4x Flash on input and 3.3x on output.
  • In our run, Flash-1017 passed 12 of 12 hidden-test runs. V4 Pro passed 10 of 12, failing the same refactor task both times.
  • Flash-1017 finished faster: a median of 39.6 seconds per task against 83.5 seconds for V4 Pro.
  • It was not cheaper per task on this route. At SandBase list price, Flash cost a median $0.054 per task and V4 Pro $0.050, because the usage Claude Code reported for Flash showed zero cache-read tokens.
  • Claude Code’s own cost readout was not the bill: $12.40 for the Flash runs against a $0.73 list-price estimate.

The setup DeepSeek documents

DeepSeek’s Integrate with AI Tools guide gives the Claude Code configuration as a block of environment variables. Every slot points at Flash, and effort is set to max:

DeepSeek API docs Claude Code integration page showing environment variables ANTHROPIC_BASE_URL set to api.deepseek.com/anthropic and the Opus, Sonnet, Haiku, and subagent model variables all set to deepseek-flash DeepSeek’s guide points the main, Opus, Sonnet, Haiku, and subagent slots all at deepseek-flash; the [1m] suffix on three of them requests the 1M-token context window (captured 2026-10-21).

export ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic
export ANTHROPIC_AUTH_TOKEN="$DEEPSEEK_API_KEY"   # never hard-code the 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
cd /path/to/project && claude

Quote the [1m] values in zsh, or the brackets get read as a glob. Since October 17, deepseek-flash serves DeepSeek-V4.1-Flash-1017, per the change log, so this block needs no edit for the new checkpoint. What changed in 1017 is covered in the update explainer.

The Opus mapping trap

Claude Code doesn’t only use your main model. It picks Opus, Sonnet, or Haiku for different jobs and sends a Claude model name for any slot you leave unset. DeepSeek’s Anthropic API guide says what happens to those names:

DeepSeek Anthropic API guide stating that claude-opus model names map to deepseek-v4-pro billed at the V4 Pro price, claude-haiku and claude-sonnet names map to deepseek-flash, and unsupported names not starting with claude return a 400 error DeepSeek’s mapping rule: claude-opus* goes to deepseek-v4-pro at the V4 Pro price, other claude* names go to deepseek-flash, and anything else returns a 400 (captured 2026-10-21).

  • Names starting with claude-opus map to deepseek-v4-pro, “billed at the V4 Pro price.”
  • Names starting with claude-haiku or claude-sonnet map to deepseek-flash.
  • Unsupported names that don’t start with claude return a 400 error.

So the failure is silent. Leave ANTHROPIC_DEFAULT_OPUS_MODEL unset, and every task Claude Code routes to Opus runs on V4 Pro, with no error and no warning. Here is what that does to the rate, from DeepSeek’s pricing page at peak hours:

Per 1M tokens (peak)deepseek-flash (V4.1-Flash-1017)deepseek-v4-pro (V4-Pro-0813)Pro ÷ Flash
Input, cache hit$0.006$0.0447.3x
Input, cache miss$0.30$1.324.4x
Output$1.20$3.963.3x

Off-peak rates are half. DeepSeek defines peak as 01:00–04:00 and 06:00–10:00 UTC on weekdays, excluding Chinese public holidays; everything else, weekends included, is off-peak. So the trap costs a few times more per token, not 50x. The posts that quote “50x” credit it to a DeepSeek chart comparing Flash with Claude Opus 5 (77.0 vs 74.0 on DeepSWE, about $0.20 vs $10 per task). That is a different comparison from Flash vs V4 Pro, and I haven’t verified those per-task costs.

I could not test the mapping directly because I have no DeepSeek API key, so the mapping rule above rests on DeepSeek’s documentation. The claim that Claude Code sends a Claude model name for an unset slot is Claude Code’s behavior, not something DeepSeek documents. What I could check is that a fully set config uses one model. Claude Code’s JSON output has a modelUsage field keyed by model name. In all 24 of my runs, it listed exactly one model: the one set in every ANTHROPIC_* variable. That is the check to run on your own setup:

claude -p "say ok" --output-format json | python3 -c \
  'import json,sys; print(list(json.load(sys.stdin)["modelUsage"]))'

If more than one name comes back, a slot is falling through to a default.

The test: 24 Claude Code runs, hidden-test grading

Since I had no DeepSeek key, I ran Claude Code through SandBase’s Anthropic-compatible endpoint. The two models were deepseek/deepseek-v4.1-flash and deepseek/deepseek-v4-pro, listed on October 21 at the same rates as DeepSeek’s peak prices. Both are third-party models reached through SandBase’s gateway. One caveat on the label: the responses carried no version string, so calling these runs “1017” is an inference from DeepSeek’s change log, which says deepseek-flash has served 1017 since October 17.

The method is the one from our October 3 test, unchanged:

  • Tasks. Six small Python repos: pagination, date ranges, an LRU cache, a counter, a refactor with a rounding bug, and CSV parsing. Each has a README spec and visible tests.
  • Prompt. “Read README.md. Run the tests with python3 -m pytest -q, change the code so it meets the spec in README.md and the tests pass, then rerun the tests. Do not edit files under tests/.”
  • Grading. After the run, the original visible tests are restored and hidden tests added in a clean copy. A run passes only if every test passes. I also checked whether the agent edited the visible tests; none did.
  • Harness. Claude Code 2.1.156, headless (claude -p), an isolated config directory per run, 40-turn and 600-second caps, two runs per task. Every ANTHROPIC_* model variable was set to the model under test. I left effort, the [1m] context suffix, and the subagent variable at Claude Code defaults, so this is not DeepSeek’s exact recommended config.
  • Cost. SandBase list price multiplied by the token usage Claude Code reported.
env -u ANTHROPIC_API_KEY \
  CLAUDE_CONFIG_DIR="$CFG" \
  ANTHROPIC_BASE_URL="https://api.sandbase.ai" \
  ANTHROPIC_AUTH_TOKEN="$SANDBASE_API_KEY" \
  ANTHROPIC_MODEL="$MODEL" ANTHROPIC_SMALL_FAST_MODEL="$MODEL" \
  ANTHROPIC_DEFAULT_HAIKU_MODEL="$MODEL" ANTHROPIC_DEFAULT_SONNET_MODEL="$MODEL" \
  ANTHROPIC_DEFAULT_OPUS_MODEL="$MODEL" \
  claude -p "$PROMPT" --model "$MODEL" --output-format json --max-turns 40 \
    --dangerously-skip-permissions

--dangerously-skip-permissions lets the agent run any shell command without asking. I used it only in throwaway copies of the task repos, with a low-limit key. All 24 runs ran in one window of about nine minutes, between 01:46 and 01:55 UTC on October 21.

Terminal summary of the October 21 2026 Claude Code test: deepseek-v4.1-flash passed 12 of 12 with median 39.6 seconds and $0.0542 per task; deepseek-v4-pro passed 10 of 12 with median 83.5 seconds and $0.0500 per task, with both t5_refactor runs failing two hidden tests Summary of all 24 runs, generated from the raw results file: pass counts, median turns and wall time, list-price cost, token usage, and the two failed runs (run 2026-10-21, 01:46–01:55 UTC).

Model (via SandBase)Hidden-test passMedian turnsMedian wall timeMedian cost/taskTotal for 12 runs
deepseek/deepseek-v4.1-flash (1017)12/129.539.6 s$0.054$0.73
deepseek/deepseek-v4-pro (0813)10/129.083.5 s$0.050$0.62

Quality: Flash-1017 cleared the task V4 Pro keeps missing

V4 Pro failed t5_refactor in both runs, with 2 of 22 tests failing each time. That is the same task it failed twice in our October 3 test, when it was listed as deepseek-v4-pro-0813. The task hides a rounding bug that the refactor must not copy forward: half-up rounding of tax on negative amounts. In both of today’s runs, the failing hidden tests were test_apply_tax_half_up[-200-25--1] and [-1000-25--3]. Flash-1017 passed it in both runs, needing 17 and 14 turns, more than it spent on any other task except one long counter run.

Six tasks is a small sample. One task separating the two models is a signal, not a ranking. But it is consistent with DeepSeek’s own claim that 1017 improved on agentic coding, and it means that running V4 Pro end to end bought nothing on these tasks. I didn’t test a mixed setup with only the Opus slot on V4 Pro.

Speed: about twice as fast

Flash-1017’s median wall time was 39.6 seconds against 83.5 seconds for V4 Pro, with similar turn counts (9.5 vs 9.0). Per turn, Flash simply answered faster. Its slowest run (t4_counter, run 2) took 109.7 seconds and 19 turns, still faster than V4 Pro’s slowest at 157.6 seconds. This fits DeepSeek’s claim of “faster task completion” for 1017 in its October 17 announcement. The measurement here is end-to-end through a gateway, in one nine-minute window.

Cost: the number that surprised me

I expected Flash to cost a fraction of V4 Pro. It didn’t. The median per task was $0.054 for Flash and $0.050 for V4 Pro. Counting only passing runs, it was $0.061 per pass for Flash and $0.062 for V4 Pro, effectively even.

The token usage explains why. Claude Code resends the whole conversation each turn, so input dominates. For V4 Pro, 1,424,384 of its 1,753,753 input tokens (81%) came back as cache reads, billed at about 3% of the input price. For Flash, Claude Code reported 2,310,517 input tokens and zero cache reads. Every turn was billed at the full $0.30 rate. Input alone accounts for about $0.69 of Flash’s $0.73 total.

That is an observation about this route on this day, from the usage fields Claude Code received. I have not confirmed whether SandBase’s billing ledger matches it, and I could not test whether DeepSeek’s direct endpoint returns cache hits for the same traffic. To show how much caching matters: if Flash’s input had hit the cache at V4 Pro’s 81% rate and been billed at $0.006, the same 12 runs would cost roughly $0.18 instead of $0.73. That figure is arithmetic, not a measurement.

The practical lesson is to check the cache fields before believing any cost comparison, including mine. Look at cache_read_input_tokens in Claude Code’s usage output. If it stays at zero across a long session, you are paying full input price on every turn.

Claude Code’s cost readout is not your bill

Claude Code prints a total_cost_usd in its JSON output. For these runs it said $12.40 for Flash and $3.15 for V4 Pro, against list-price estimates of $0.73 and $0.62. Claude Code doesn’t know DeepSeek’s prices. Both readouts match the same usage priced at $5 input, $0.50 cache read, and $25 output per million tokens, which are Claude-class rates. If you see a Claude Code dollar figure in a screenshot, check whether it is total_cost_usd before trusting it. For the real number, use your provider’s usage dashboard, or multiply token counts by the published rates.

What I’d do on Monday

SituationRecommendation
New Claude Code setup on DeepSeekCopy DeepSeek’s block exactly, all five model variables included, then run the modelUsage check
Existing setup with only ANTHROPIC_MODEL setAdd the Opus, Sonnet, Haiku, and subagent variables; an unset Opus slot runs on V4 Pro at V4 Pro prices
Want V4 Pro for planning on purposeSet ANTHROPIC_DEFAULT_OPUS_MODEL=deepseek-v4-pro explicitly, then measure whether it helps; end to end, V4 Pro didn’t beat Flash here
Comparing costsRead cache_read_input_tokens, not Claude Code’s dollar figure
Long batch jobs on DeepSeek directSchedule them off-peak (weekends, or outside 01:00–04:00 and 06:00–10:00 UTC on weekdays) for half price

FAQ

How do I use DeepSeek V4.1-Flash-1017 in Claude Code?

Set ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic, put your DeepSeek key in ANTHROPIC_AUTH_TOKEN, and set ANTHROPIC_MODEL, ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL, ANTHROPIC_DEFAULT_HAIKU_MODEL, and CLAUDE_CODE_SUBAGENT_MODEL to deepseek-flash. Since October 17, 2026 that name serves V4.1-Flash-1017.

What happens if I don’t set ANTHROPIC_DEFAULT_OPUS_MODEL?

Claude Code sends a claude-opus model name for Opus-tier work. DeepSeek’s Anthropic endpoint maps any claude-opus* name to deepseek-v4-pro and bills it at V4 Pro rates: $1.32 input and $3.96 output per million tokens at peak, against $0.30 and $1.20 for Flash.

Is V4.1-Flash-1017 good enough for Claude Code?

On our six small Python tasks, it passed 12 of 12 hidden-test runs, while V4 Pro passed 10 of 12, and it finished in about half the wall time. That is a small, single-day sample, so test it on your own repositories before relying on it.

Is Flash-1017 really 50x cheaper than Opus in Claude Code?

The posts quoting 50x credit it to a DeepSeek chart against Claude Opus 5, not to a Claude Code run, and I haven’t verified the per-task costs. Against V4 Pro in our runs, Flash cost about the same per task, because its usage showed no cache reads. Your real ratio depends heavily on caching.

Why does Claude Code show a much higher cost than I’m billed?

Claude Code’s total_cost_usd prices usage at its own Claude-class defaults, not DeepSeek’s rates. In our runs it reported $12.40 for work that came to $0.73 at list price.

Bottom line

The viral tip is right: set every Claude Code model slot to deepseek-flash, or Opus-tier work silently runs on V4 Pro at several times the price. In our 24 runs, that was also a quality call. Flash-1017 passed every hidden test, including the refactor V4 Pro has now failed four times, and it finished in about half the time. The cost story is less tidy. On this route Flash reported no cache reads and came out even with V4 Pro per task, so check your cache fields before believing any cost multiple, mine included. The harness script and raw results are simple to point at your own repos; both models take the same SandBase key: deepseek/deepseek-v4.1-flash and deepseek/deepseek-v4-pro. For calling Flash directly from code, see the Python tutorial.