Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,11 @@ deepseek usage --entries --json # individual calls
deepseek pricing --json # the schedule and the billing period right now
```

Pricing is time-of-day from 2026-08-16 16:00 UTC: peak hours 01:00–04:00
and 06:00–10:00 UTC bill at twice the off-peak rate. `pricing` computes
the current period locally — no network, nothing spent — from the same
schedule the cost estimates use.
Pricing has been time-of-day since 2026-08-16 16:00 UTC: peak hours
01:00–04:00 and 06:00–10:00 UTC bill at twice the off-peak rate. Never
quote a DeepSeek price without saying which period it is — `pricing`
computes the current one locally, no network, nothing spent, from the
same schedule the cost estimates use.

### Documentation, offline

Expand Down Expand Up @@ -264,9 +265,11 @@ Every call prints a usage line to stderr and appends to
for a quiet run.
- Costs are estimates from the published USD rate card, not billed
amounts. Token counts are exact.
- Cached input tokens cost 50× less than uncached ones. Put the stable
part of a prompt first — the same system prompt and files across calls
— and `deepseek usage` will show the saving.
- Cached input tokens cost about 30× less than uncached ones. Put the
stable part of a prompt first — the same system prompt and files across
calls — and `deepseek usage` will show the saving. Prompt structure is
still the biggest lever on a bill; the hour of the day comes second,
and it is worth at most 2×.

## Cautions

Expand Down
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,25 @@ cover-gate:
# page by page and extracts the FAQ out of its JS bundle. A sibling
# checkout is used when there is one — that is the loop while working on
# both — and otherwise it is fetched, so CI and a bare clone both work.
#
# The mirror also tracks dsh, DeepSeek's agent harness, in en/dsh — 112
# pages of a different product. This binary carries the API reference, so
# that subtree is excluded: it would quadruple the payload and it out-ranks
# the API pages on shared words like "tool" and "session".
CORPUS=internal/docs/corpus.tar.gz
CORPUS_EXCLUDE=--exclude=en/dsh
DOCS_REPO=https://github.com/thevibeworks/deepseek-docs

.PHONY: corpus
corpus:
@if [ -d ../deepseek-docs/content/en ]; then \
echo "packing from ../deepseek-docs"; \
tar -C ../deepseek-docs/content -czf $(CORPUS) en; \
tar -C ../deepseek-docs/content $(CORPUS_EXCLUDE) -czf $(CORPUS) en; \
else \
echo "fetching from $(DOCS_REPO)"; \
tmp=$$(mktemp -d); \
curl -sSL $(DOCS_REPO)/archive/refs/heads/main.tar.gz | tar -xz -C $$tmp --strip-components=1; \
tar -C $$tmp/content -czf $(CORPUS) en; \
tar -C $$tmp/content $(CORPUS_EXCLUDE) -czf $(CORPUS) en; \
rm -rf $$tmp; \
fi
@echo "$(CORPUS): $$(du -h $(CORPUS) | cut -f1), $$(tar tzf $(CORPUS) | grep -c '\.md$$') pages"
Expand Down
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ It also does three things `curl` will not:
on every later request. `--continue` handles that; without tools it
strips the same field, because replaying it there just burns tokens.
- **Prices every call.** DeepSeek's disk KV-cache makes a cached input
token **50× cheaper** than an uncached one. That split is invisible
unless something reads `prompt_cache_hit_tokens` and does the
arithmetic. This does, on every call, and keeps a local ledger.
token **~30× cheaper** than an uncached one, and since 2026-08-16 the
hour of the day doubles the bill on top. Both splits are invisible
unless something reads `prompt_cache_hit_tokens`, knows the schedule
and does the arithmetic. This does, on every call, and keeps a local
ledger.
- **Carries the manual.** `deepseek docs ask "..."` answers questions
about the DeepSeek API from DeepSeek's own documentation, offline, with
a citation per claim. The tool that talks to an API should be able to
Expand Down Expand Up @@ -374,9 +376,10 @@ context cache saved ~$0.23 (1.7M of 2.2M prompt tokens replayed)
costs are estimates from the published USD rate card, not billed amounts
```

That last line is the point. Cached input costs $0.0028/M against
$0.14/M for a miss — structuring prompts so the stable part comes first
is worth real money, and this is how you see whether it worked.
That last line is the point. Cached input costs $0.007/M against
$0.22/M for a miss in an off-peak hour — structuring prompts so the
stable part comes first is worth real money, and this is how you see
whether it worked.

Honest limits:

Expand Down
27 changes: 18 additions & 9 deletions gateway/DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,20 +280,29 @@ scarce operation and gets the conservative boundary.

## Limits, and why these numbers

Worst-case cost per anonymous user per day, at flash rates
($0.14/M input, $0.28/M output):
Worst-case cost per anonymous user per day, at flash off-peak rates
($0.22/M input, $0.66/M output):

```
60,000 input × $0.14/M = $0.0084
20,000 output × $0.28/M = $0.0056
60,000 input × $0.22/M = $0.0132
20,000 output × $0.66/M = $0.0132
-------
$0.014 / user / day at full burn
$0.0264 / user / day at full burn, off-peak
$0.0528 / user / day at full burn, peak
```

So a $1/day budget serves ~70 users burning *everything*, or several
hundred normal ones — a normal turn is a few hundred input and a few
hundred output tokens, about $0.0003. Roughly **3,300 ordinary turns per
dollar.**
So a $1/day budget serves ~38 users burning *everything* off-peak, ~19 at
peak, or several hundred normal ones — a normal turn is a few hundred
input and a few hundred output tokens, about $0.0006. Roughly **1,700
ordinary turns per dollar off-peak, 850 at peak.**

These are the numbers of the card that took effect 2026-08-16 16:00 UTC,
and they roughly halved the free tier's reach at an unchanged budget: the
old flat card ($0.14/$0.28) made the same worst case $0.014/user/day. The
quotas below have not been retuned for it — the budget breaker is what
actually bounds spend, and it does its job at any card — but the reach
per dollar is now a time-of-day figure, and the peak windows are the
expensive seven hours.

| setting | default | why |
|---|---|---|
Expand Down
17 changes: 12 additions & 5 deletions gateway/internal/meter/meter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ import (
"time"
)

// A fixed instant outside every peak window, for the tests that are about
// token attribution rather than about the schedule. Pricing them at
// time.Now() made them fail the moment the repricing landed, which told
// us nothing about the code under test.
var offPeakInstant = time.Date(2026, 8, 17, 12, 0, 0, 0, time.UTC)

// The payloads below are verbatim from the live API on 2026-08-05, one
// per wire format, captured with `deepseek raw`. Hand-written fixtures
// would only prove this package agrees with my memory of the shapes;
Expand Down Expand Up @@ -69,9 +75,10 @@ func TestAnthropicCacheReadsAreAddedToInput(t *testing.T) {
t.Errorf("cache hits = %d, want 900", u.CacheHitTokens)
}
// And the price must reflect that only 130 tokens were billed at the
// full rate.
want := 900*0.0028/1e6 + 130*0.14/1e6 + 7*0.28/1e6
if got := Cost("deepseek-v4-flash", u); math.Abs(got-want) > 1e-12 {
// full rate. Priced at a fixed off-peak instant: what is under test is
// which tokens land on which rate, not which card is in force today.
want := 900*0.007/1e6 + 130*0.22/1e6 + 7*0.66/1e6
if got := CostAt("deepseek-v4-flash", u, offPeakInstant); math.Abs(got-want) > 1e-12 {
t.Errorf("cost = %v, want %v", got, want)
}
}
Expand All @@ -82,8 +89,8 @@ func TestOpenAICacheHitsAreInsideInput(t *testing.T) {
if u.InputTokens != 1000 || u.CacheHitTokens != 960 {
t.Fatalf("in %d hit %d, want 1000/960", u.InputTokens, u.CacheHitTokens)
}
want := 960*0.0028/1e6 + 40*0.14/1e6 + 10*0.28/1e6
if got := Cost("deepseek-v4-flash", u); math.Abs(got-want) > 1e-12 {
want := 960*0.007/1e6 + 40*0.22/1e6 + 10*0.66/1e6
if got := CostAt("deepseek-v4-flash", u, offPeakInstant); math.Abs(got-want) > 1e-12 {
t.Errorf("cost = %v, want %v", got, want)
}
}
Expand Down
6 changes: 5 additions & 1 deletion internal/cli/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,11 @@ func TestModelsJoinsThePublishedRateCard(t *testing.T) {
if !strings.Contains(got.stdout, "deepseek-v4-flash") {
t.Errorf("stdout = %q", got.stdout)
}
if !strings.Contains(got.stdout, "0.14") {
// Which figure depends on the hour: flash cache-miss input is $0.22
// off-peak and $0.44 peak. Both are published numbers, so asserting
// on either keeps this a real check without making it a time bomb
// that fails whenever the suite runs inside a peak window.
if !strings.Contains(got.stdout, "0.22") && !strings.Contains(got.stdout, "0.44") {
t.Errorf("the price should sit next to the model, got %q", got.stdout)
}
}
Expand Down
13 changes: 11 additions & 2 deletions internal/deepseek/pricing.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,27 @@ type Price struct {
Output float64
}

// RepriceAt is when DeepSeek's dated repricing takes effect: 16:00 UTC
// on 2026-08-16 (midnight, Beijing), announced 2026-08-13 with the V4 GA
// RepriceAt is when DeepSeek's repricing took effect: 16:00 UTC on
// 2026-08-16 (midnight, Beijing), announced 2026-08-13 with the V4 GA
// release. From that instant the API bills peak/off-peak on a new,
// higher card, with off-peak at half the peak rate.
//
// This is live, and measured, not just read off the page: a 188,542
// cache-miss-token call to pro in the off-peak window on 2026-08-17
// settled at 0.84 CNY, i.e. 4.46 CNY/1M against the new card's 4.5 and
// the old card's 3.0.
//
// TASTE.md's rule against applying announced-but-undated numbers does
// not apply here — these numbers carry their date, so the switch is
// encoded and gated on it, exactly as that scar's expiry clause says.
// Source: https://api-docs.deepseek.com/quick_start/pricing (2026-08-13).
var RepriceAt = time.Date(2026, time.August, 16, 16, 0, 0, 0, time.UTC)

// pricesFlat is the card published 2026-08-02, in force before RepriceAt.
// That instant has passed, so nothing live prices against it any more; it
// stays because the ledger stores token counts rather than dollars, and a
// call made before the flip must still reprice under the card it was
// actually billed at.
var pricesFlat = map[string]Price{
ModelFlash: {CacheHitInput: 0.0028, CacheMissInput: 0.14, Output: 0.28},
ModelPro: {CacheHitInput: 0.003625, CacheMissInput: 0.435, Output: 0.87},
Expand Down
Binary file modified internal/docs/corpus.tar.gz
Binary file not shown.
42 changes: 27 additions & 15 deletions site/bench/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;700&display=swap" rel="stylesheet">
<script>try{var t=localStorage.getItem('theme');if(t==='dark'||t==='light')document.documentElement.dataset.theme=t}catch(e){}</script>
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"FAQPage","mainEntity":[{"@type":"Question","name":"How does DeepSeek-V4-Pro score against other models on agent benchmarks?","acceptedAnswer":{"@type":"Answer","text":"On DeepSeek's own launch-day chart (2026-08-12), V4-Pro-0813 scores Terminal-Bench 2.1 87.9, DeepSWE 62.7, Toolathlon-Verified 74.1, CyberGym 83.3, HLE-with-tools 60.0 and AutomationBench 31.8. It sits in the same cluster as Kimi K3, Claude Fable 5 and Opus 4.8: within a point of Fable 5 on Terminal-Bench (88.0) and CyberGym (83.1), ahead of Opus 4.8 on several execution suites, but behind Kimi K3 on Terminal-Bench, DeepSWE, Toolathlon and DSBench-Hard. These are vendor numbers from one harness and are not yet independently reproduced."}},{"@type":"Question","name":"What did the V4-Pro GA (0813) checkpoint change over the preview?","acceptedAnswer":{"@type":"Answer","text":"The model ID and the rate card did not change; the checkpoint did. Against the April V4-Pro preview, DeepSeek's chart shows large agentic gains: DeepSWE 12.8 to 62.7, DSBench-Hard 31.1 to 67.2, CyberGym 52.7 to 83.3, Terminal-Bench 2.1 72.1 to 87.9, Toolathlon 55.9 to 74.1. Jumps that size point to agent post-training and better tool-error handling rather than a new base model, and none of them are independently verified yet."}},{"@type":"Question","name":"What is the DeepSeek kill line (斩杀线)?","acceptedAnswer":{"@type":"Answer","text":"The kill line is a community idea that DeepSeek's price-to-capability ratio sets a threshold that removes the reason to exist for any model that is both weaker and more expensive. V4-Pro is roughly 11x cheaper than GPT-5.6 Sol on cache-miss input and 34x cheaper on output, and about 138x cheaper on cache-hit input. It does not kill the frontier: the strongest closed models still finish the hardest tasks in fewer turns. It kills the middle, where a model costs more and does less."}},{"@type":"Question","name":"Is DeepSeek-V4-Pro better than Claude or GPT for coding agents?","acceptedAnswer":{"@type":"Answer","text":"Per attempt, the strongest closed models remain more reliable on the hardest multi-step tasks and usually need less steering. Per dollar, V4-Pro changes the arithmetic: its cheap cached input makes repeated review, parallel workers and long tool loops affordable in a way per-token-stronger models are not. The practical answer is to route by role, run an internal bake-off, and measure successful-task cost, not per-token price."}}]}
{"@context":"https://schema.org","@type":"FAQPage","mainEntity":[{"@type":"Question","name":"How does DeepSeek-V4-Pro score against other models on agent benchmarks?","acceptedAnswer":{"@type":"Answer","text":"On DeepSeek's own launch-day chart (2026-08-12), V4-Pro-0813 scores Terminal-Bench 2.1 87.9, DeepSWE 62.7, Toolathlon-Verified 74.1, CyberGym 83.3, HLE-with-tools 60.0 and AutomationBench 31.8. It sits in the same cluster as Kimi K3, Claude Fable 5 and Opus 4.8: within a point of Fable 5 on Terminal-Bench (88.0) and CyberGym (83.1), ahead of Opus 4.8 on several execution suites, but behind Kimi K3 on Terminal-Bench, DeepSWE, Toolathlon and DSBench-Hard. These are vendor numbers from one harness and are not yet independently reproduced."}},{"@type":"Question","name":"What did the V4-Pro GA (0813) checkpoint change over the preview?","acceptedAnswer":{"@type":"Answer","text":"The model ID and the rate card did not change; the checkpoint did. Against the April V4-Pro preview, DeepSeek's chart shows large agentic gains: DeepSWE 12.8 to 62.7, DSBench-Hard 31.1 to 67.2, CyberGym 52.7 to 83.3, Terminal-Bench 2.1 72.1 to 87.9, Toolathlon 55.9 to 74.1. Jumps that size point to agent post-training and better tool-error handling rather than a new base model, and none of them are independently verified yet."}},{"@type":"Question","name":"What is the DeepSeek kill line (斩杀线)?","acceptedAnswer":{"@type":"Answer","text":"The kill line is a community idea that DeepSeek's price-to-capability ratio sets a threshold that removes the reason to exist for any model that is both weaker and more expensive. On the card in force since 2026-08-16, V4-Pro is 7.6x cheaper than GPT-5.6 Sol on cache-miss input off-peak (3.8x at peak), 15x cheaper on output (7.6x peak) and 23x cheaper on cache-hit input (11x peak). The repricing narrowed all three: on the flat card that ran until then the figures were 11.5x, 34.5x and 138x. It does not kill the frontier: the strongest closed models still finish the hardest tasks in fewer turns. It kills the middle, where a model costs more and does less."}},{"@type":"Question","name":"Is DeepSeek-V4-Pro better than Claude or GPT for coding agents?","acceptedAnswer":{"@type":"Answer","text":"Per attempt, the strongest closed models remain more reliable on the hardest multi-step tasks and usually need less steering. Per dollar, V4-Pro changes the arithmetic: its cheap cached input makes repeated review, parallel workers and long tool loops affordable in a way per-token-stronger models are not. The practical answer is to route by role, run an internal bake-off, and measure successful-task cost, not per-token price."}}]}
</script>
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"deepseek-cli","item":"https://thevibeworks.github.io/deepseek-cli/"},{"@type":"ListItem","position":2,"name":"bench","item":"https://thevibeworks.github.io/deepseek-cli/bench/"}]}
Expand Down Expand Up @@ -178,20 +178,27 @@ <h2 id="kill-line">The kill line (<span lang="zh">斩杀线</span>)</h2>
<table>
<thead><tr><th>Per 1M tokens</th><th class="num">v4-flash</th><th class="num">v4-pro</th><th class="num">GPT-5.6 Sol</th><th class="num">pro is cheaper by</th></tr></thead>
<tbody>
<tr><td>input, cache miss</td><td class="num">$0.14</td><td class="num">$0.435</td><td class="num">$5.00</td><td class="num">~11.5x</td></tr>
<tr><td>input, cache hit</td><td class="num">$0.0028</td><td class="num">$0.003625</td><td class="num">$0.50</td><td class="num">~138x</td></tr>
<tr><td>output</td><td class="num">$0.28</td><td class="num">$0.87</td><td class="num">$30.00</td><td class="num">~34.5x</td></tr>
<tr><td>input, cache miss</td><td class="num">$0.22 / $0.44</td><td class="num">$0.66 / $1.32</td><td class="num">$5.00</td><td class="num">7.6x / 3.8x</td></tr>
<tr><td>input, cache hit</td><td class="num">$0.007 / $0.014</td><td class="num">$0.022 / $0.044</td><td class="num">$0.50</td><td class="num">23x / 11x</td></tr>
<tr><td>output</td><td class="num">$0.66 / $1.32</td><td class="num">$1.98 / $3.96</td><td class="num">$30.00</td><td class="num">15x / 7.6x</td></tr>
</tbody>
</table>
</div>
<p class="small">DeepSeek prices are the published USD rate card of
2026-08-02, unchanged at GA; they are a conversion of the RMB card
(&yen;3 / &yen;0.025 / &yen;6 per 1M for pro) at one consistent rate. GPT-5.6
Sol prices are from OpenAI's own listing. From 2026-08-16 16:00 UTC DeepSeek
bills peak/off-peak on a higher card &ndash; the
<a href="../pricing/">pricing page</a> has the dated schedule. Even at
the new peak rate, pro stays ~3.8x cheaper than GPT-5.6 Sol on cache-miss
input and ~7.6x on output.</p>
<p class="small">DeepSeek cells read <strong>off-peak / peak</strong>, on the
card in force since 2026-08-16 16:00 UTC; they are a conversion of the RMB
card (pro: &yen;4.5 / &yen;0.15 / &yen;13.5 per 1M off-peak, double at peak)
at one consistent rate. GPT-5.6 Sol prices are from OpenAI's own listing.
The <a href="../pricing/">pricing page</a> has the full schedule.</p>
<div class="note warn">
<span class="tag">the repricing moved this line</span>
<p>These ratios were <strong>11.5x / 138x / 34.5x</strong> on the flat card
that ran until 2026-08-16. The cache-hit column is where the argument
lived &ndash; a 138x edge is what made replayed context, parallel reviewers
and long tool loops nearly free &ndash; and it is now 23x off-peak, 11x at
peak. That is still a large advantage. It is no longer a different
category, and any plan that was built on the old number should be
re-costed rather than assumed.</p>
</div>
<p>The sober version matters as much as the slogan. The kill line is real for
the <em>middle</em> of the market: a model that costs more than V4-Pro and
scores below it on the table above is hard to justify, and that is most of the
Expand All @@ -212,11 +219,16 @@ <h2 id="practice">What it means in practice</h2>
<code>ds chat -m deepseek-v4-pro</code> and the
<a href="../formats/">Anthropic remap</a> make the switch one flag.</li>
<li><strong>Structure prompts for the cache.</strong> A cached input token
costs about 1/50th of an uncached one. Keep the system prompt, tool schemas,
costs about 1/30th of an uncached one. Keep the system prompt, tool schemas,
repository map and durable instructions in an identical prefix and put the
volatile part last; <code>ds usage</code> reports what the cache saved so you
can see whether it is working. This is where the 138x cache-hit number turns
from a table cell into a bill.</li>
can see whether it is working. This is where the cache-hit column turns from
a table cell into a bill &ndash; and since the repricing hit that column
hardest, it is worth more attention now, not less.</li>
<li><strong>Schedule what can be scheduled.</strong> The same call costs
half as much outside 01:00&ndash;04:00 and 06:00&ndash;10:00 UTC. Batch
evaluation, bulk review and overnight agent runs are exactly the workloads
that can move; <code>ds pricing</code> says which period you are in.</li>
<li><strong>Measure successful-task cost, not per-token price.</strong> A
cheaper model that retries five times can cost more than a dearer one that lands
first. The <a href="../cost/#ledger">ledger</a> stores exact token counts
Expand Down
Loading