Cited source trail
How does DeepSeek v4 inference cost multiply with context window size (4k/16k/64k/256k/1M) and with turns (1/10/25/50/10
Original question
How does DeepSeek v4 inference cost multiply with context window size (4k/16k/64k/256k/1M) and with turns (1/10/25/50/100)? Use https://api-docs.deepseek.com/quick_start/pricing, /guides/kv_cache, and /guides/thinking_mode as primary sources. Produce: per-request cost multiplier per window size, total session cost table across turn counts, cache-hit vs cache-miss difference, thinking-token impact, and top-5 rules of thumb — every number cited to the page it came from.
I have everything I need from the three primary sources plus the Multi-round Conversation and Token & Token Usage pages. Here is the complete analysis.
---
# DeepSeek V4 Inference Cost: Scaling with Context & Turns
**Primary sources opened and cited throughout:**
- [Models & Pricing](https://api-docs.deepseek.com/quick_start/pricing) — prices, 1M context, billing rule
- [Context Caching (KV cache)](https://api-docs.deepseek.com/guides/kv_cache) — hit rules, multi-round example
- [Thinking Mode](https://api-docs.deepseek.com/guides/thinking_mode) — reasoning tokens, effort control
- Supporting: [Multi-round Conversation](https://api-docs.deepseek.com/guides/multi_round_chat), [Token & Token Usage](https://api-docs.deepseek.com/quick_start/token_usage)
**What the pricing page establishes** ([Models & Pricing](https://api-docs.deepseek.com/quick_start/pricing)): two v4 models — `deepseek-v4-flash` (DeepSeek-V4-Flash-0731) and `deepseek-v4-pro` (DeepSeek-V4-Pro-0813) — both with **1M context length** and max output 384K. Prices per 1M tokens, off-peak / peak:
| | Flash off-peak | Flash peak | Pro off-peak | Pro peak |
|---|---|---|---|---|
| Input, cache hit | $0.007 | $0.014 | $0.022 | $0.044 |
| Input, cache miss | $0.22 | $0.44 | $0.66 | $1.32 |
| Output | $0.66 | $1.32 | $1.98 | $3.96 |
And the billing rule is explicit: **"The expense = number of tokens × price."** Peak hours are 01:00–04:00 and 06:00–10:00 UTC; off-peak is exactly half of peak. The API is stateless — every turn re-sends the whole history ([Multi-round Conversation](https://api-docs.deepseek.com/guides/multi_round_chat)).
---
## 1. Per-request cost multiplier per window size
Because expense = tokens × price (linear, per the [pricing page's Deduction Rules](https://api-docs.deepseek.com/quick_start/pricing)), the multiplier is exactly the token-count ratio — **a 4× bigger window = 4× the input cost; 4k → 1M = 256×**.
Cost per request for an input that fills the window (`deepseek-v4-pro`, off-peak; peak = ×2, Flash ≈ ÷3):
| Window | Multiplier vs 4k | Pro cost, cache MISS | Pro cost, cache HIT |
|---|---|---|---|
| 4k | 1.0× | $0.00264 | $0.000088 |
| 16k | 4.0× | $0.01056 | $0.000352 |
| 64k | 16.0× | $0.04224 | $0.001408 |
| 256k | 64.0× | $0.16896 | $0.005632 |
| 1M | 256.0× | $0.66 | $0.022 |
(Derived from the $0.66 / $0.022 per-1M prices × tokens, per the linear billing rule. Output is separate: e.g., 1,000 output tokens = $0.00198 on Pro off-peak, $0.00066 on Flash.)
**Cross-link between the two axes** (derived from the 1M context claim at 4,000 new tokens/turn): a 4k window fits ~1 turn, 16k ≈ 4, 64k ≈ 16, 256k ≈ 64, 1M ≈ 250 turns before the history itself fills the window.
---
## 2. Total session cost across turns
**Modeling assumptions (stated, since the docs give prices, not session formulas):** Pro model, off-peak rates, each turn appends 4,000 new input tokens (history re-sent every turn per the [stateless API](https://api-docs.deepseek.com/guides/multi_round_chat)), 1,000 output tokens/turn, and — per [KV-cache Example 1](https://api-docs.deepseek.com/guides/kv_cache) — the prior-turn prefix hits the cache while only the newest 4,000 tokens are a miss. "No cache" = every token billed at miss rate.
| Turns | Cumulative input tokens | Session cost, NO cache (all miss) | Session cost, WITH cache (history hit) | Cache savings |
|---|---|---|---|---|
| 1 | 4,000 | $0.00264 | $0.00264 | — |
| 10 | 220,000 | $0.14520 | $0.03036 | 4.8× |
| 25 | 1,300,000 | $0.85800 | $0.09240 | 9.3× |
| 50 | 5,100,000 | $3.36600 | $0.23980 | 14.0× |
| 100 | 20,200,000 | $13.33200 | $0.69960 | 19.1× |
(Input only. Add output: 1,000 tokens × $1.98/1M = +$0.00198 per turn, Pro off-peak — e.g., ~+$0.20 over 100 turns.)
**The key mechanics:**
- **No caching:** turn *t* bills 4,000·*t* tokens at miss price → session cost grows **quadratically** (Σt = T(T+1)/2), hitting $13.33 at 100 turns.
- **With caching:** each turn pays only the newest 4,000 tokens at miss price ($0.00264) plus the growing history at hit price (≈$0.000088/turn of history) → session cost grows **roughly linearly**, ~$0.70 at 100 turns, and marginal per-turn cost stays ≤ ~$0.011 even at turn 100.
- The gap widens with turns (4.8× at 10 turns → 19.1× at 100 turns).
Caveat from the [KV-cache page](https://api-docs.deepseek.com/guides/kv_cache): hits are **best-effort, not guaranteed 100%**; a hit requires *fully matching a persisted cache prefix unit*, and caches are cleared "usually within a few hours to a few days."
---
## 3. Cache-hit vs cache-miss difference
| Model | Hit (off-peak) | Miss (off-peak) | Hit advantage | Hit (peak) | Miss (peak) |
|---|---|---|---|---|---|
| deepseek-v4-pro | $0.022 / 1M | $0.66 / 1M | **30.0× cheaper** | $0.044 | $1.32 |
| deepseek-v4-flash | $0.007 / 1M | $0.22 / 1M | **31.4× cheaper** | $0.014 | $0.44 |
In dollars (Pro, off-peak): a fully-cached 1M-token input costs $0.022 vs $0.66 uncached; a 4k input costs $0.000088 vs $0.00264. ([Models & Pricing](https://api-docs.deepseek.com/quick_start/pricing))
When does a hit happen? Per the [KV-cache guide](https://api-docs.deepseek.com/guides/kv_cache): caching is on by default; each request persists cache prefix units at the end of user input and model output; a later request hits only if it **fully matches a persisted unit**. In a multi-round conversation (their Example 1), the second request "can fully reuse the cache prefix unit from the first request, which will count as a 'cache hit'" — but a divergent prompt (their Example 2, A+C vs A+B) misses on the first divergence. Monitor via `prompt_cache_hit_tokens` / `prompt_cache_miss_tokens` in the usage object.
---
## 4. Thinking-token impact
- **Default ON with default effort "high"** ([Thinking Mode](https://api-docs.deepseek.com/guides/thinking_mode)) — every request emits chain-of-thought unless you disable it (`{"thinking": {"type": "disabled"}}`).
- **Reasoning tokens are billed as output tokens**: the pricing page bills by "the total number of input and output tokens," and the thinking guide states CoT is returned via `reasoning_content` "at the same level as content" — i.e., at the output rate ($1.98/1M Pro off-peak, $0.66/1M Flash). No separate reasoning-token rate is published.
- **Non-tool-call turns: thinking tokens are billed exactly once.** "If the model did not perform a tool call, the intermediate assistant's reasoning_content does not need to participate in the context concatenation. If passed to the API in subsequent turns, it will be ignored" — so they do **not** inflate later input bills or count against the context window.
- **Tool-call turns: thinking tokens are re-billed every turn.** "If the model performed a tool call, the intermediate assistant's reasoning_content must participate in the context concatenation and must be passed back to the API in all subsequent user interaction turns" (missing it returns a 400 error). Those reasoning tokens then recur as *input* in every later turn — at input prices, cache-hit rate if the prefix matches.
- **Effort control:** `reasoning_effort` = low / high / max (medium→high, xhigh→high; same mapping for both models). More effort ⇒ more reasoning output ⇒ higher output bill. The docs publish **no per-effort token counts or ratios**, so an exact "effort multiplier" is not derivable — it's an unpublished number.
- Side effects: thinking mode ignores temperature/top_p/presence_penalty/frequency_penalty. For cost control, the levers the docs actually give you are: disable thinking, set `reasoning_effort=low`, or use Flash (~3× cheaper output).
---
## 5. Top-5 rules of thumb
1. **Cost scales linearly with tokens — the multiplier table is just the token ratio.** "Expense = number of tokens × price" ([Models & Pricing](https://api-docs.deepseek.com/quick_start/pricing)); 4k→16k→64k→256k→1M multiplies per-request input cost 1×/4×/16×/64×/256×.
2. **Engineer for cache hits: they're ~30× cheaper than misses** — $0.022 vs $0.66 per 1M input tokens on Pro off-peak ([Models & Pricing](https://api-docs.deepseek.com/quick_start/pricing)). Keep multi-turn prefixes byte-identical (append-only history) so the full prior context is a cache hit ([Context Caching](https://api-docs.deepseek.com/guides/kv_cache)).
3. **Caching flips session cost from quadratic to ~linear growth**: a 100-turn session is ~$13.33 all-miss vs ~$0.70 with cached history (Pro, off-peak, 4k new tokens/turn) — a ~19× saving that grows with turns (derived from the linear price rule + KV-cache Example 1).
4. **Thinking mode is on by default and reasoning tokens are output-priced** — but without tool calls they're billed once and ignored afterward, so they don't compound across turns; with tool calls they must be re-sent (and re-billed) every turn ([Thinking Mode](https://api-docs.deepseek.com/guides/thinking_mode)). Cut cost via `reasoning_effort=low`, disabling thinking, or Flash.
5. **Every price doubles in peak hours (01:00–04:00 and 06:00–10:00 UTC)** — schedule batch/offline work in off-peak to halve cost ([Models & Pricing](https://api-docs.deepseek.com/quick_start/pricing)) — and never assume 100% hits: caching is best-effort, needs exact prefix-unit matches, and caches clear within hours–days ([Context Caching](https://api-docs.deepseek.com/guides/kv_cache)); watch `prompt_cache_hit_tokens`/`prompt_cache_miss_tokens`.
**Not published anywhere in these docs (so treat as unknown, not guessed):** per-effort reasoning-token counts, any non-linear input pricing, and per-model tokenization variance for your exact prompts (only rough ratios — 1 English char ≈ 0.3 token, 1 Chinese char ≈ 0.6 token — are given in [Token & Token Usage](https://api-docs.deepseek.com/quick_start/token_usage)).
1navigatehttps://api-docs.deepseek.com/quick_start/pricing
2navigatehttps://api-docs.deepseek.com/guides/kv_cache
3navigatehttps://api-docs.deepseek.com/guides/thinking_mode
4navigatehttps://api-docs.deepseek.com/quick_start/token_usage
5navigatehttps://api-docs.deepseek.com/guides/multi_round
6js_evalArray.from(document.querySelectorAll('a')).filter(a => /multi|round/i.test(a.tex
7js_evalArray.from(document.querySelectorAll('a')).filter(a => /Multi-round|round/i.test
8navigatehttps://api-docs.deepseek.com/guides/multi_round_chat
9navigatehttps://api-docs.deepseek.com/quick_start/pricing
10navigatehttps://api-docs.deepseek.com/guides/kv_cache
11navigatehttps://api-docs.deepseek.com/guides/thinking_mode
12navigatehttps://api-docs.deepseek.com/quick_start/token_usage