DeepSeek Cache Hit Rate: How to Audit Your API Bill

Calculate your DeepSeek cache hit rate, match cache reads and misses to provider charges, and use a worked CSV to reconcile a coding-agent bill.

Five parallel cache-read lines lead into three charges of different sizes.

A 93% DeepSeek cache hit rate means about 93 of every 100 input tokens came from cache. You still pay the applicable cache-read rate on those tokens, the uncached rate on the rest, and the output rate on generated tokens. To explain a bill, start with the requests that cost the most and identify which provider served them.

How do I calculate my DeepSeek cache hit rate?

Divide the sum of cached input tokens by the sum of all input tokens over the same billing window. Exclude output from both sums. Suppose one request reads 900 of 1,000 input tokens from cache and another reads 0 of 10. The combined hit rate is 900 ÷ 1,010, or 89.1%. Averaging 90% and 0% would give 45% and severely understate the share of tokens served from cache.

Where the request ranCached inputHow to identify uncached input
DeepSeek direct APIusage.prompt_cache_hit_tokensusage.prompt_cache_miss_tokens
OpenRouter Chat Completionsusage.prompt_tokens_details.cached_tokensSubtract cache reads from usage.prompt_tokens to find input outside the read cache. If there are cache writes, check which input bucket includes them and how the provider prices them before applying the ordinary uncached rate.

OpenRouter’s documented response has 10,339 prompt tokens, 10,318 cached tokens, zero cache writes and 60 completion tokens. That leaves 21 uncached input tokens. For DeepSeek direct, add hits and misses to recover total input. If a cache counter is missing, mark the request unknown and report coverage by both request count and input-token volume. Calculate the hit rate only for requests with known counts. If total input is also missing, token coverage for the whole export is unknown. DeepSeek context caching · OpenRouter prompt caching

OpenRouter’s sample reports 10,339 prompt tokens, including 10,318 cached tokens. That leaves 21 outside the cache. The 60 completion tokens are counted separately.

Ofox diagram based on the usage object in OpenRouter’s prompt caching guide. The 21-token remainder is calculated from the two published counters.

Why did a developer report $7.82 at a 93.45% hit rate?

A developer reported 1,175 DeepSeek V4 Flash 0423 requests with 115.75 million cached tokens out of 123.86 million input tokens. Dividing those rounded totals gives a 93.45% hit rate and subtracting them leaves 8.11 million uncached tokens. The developer reported a $7.82 charge and estimated $2.78 for the same token mix at another provider’s rates. The second figure assumes the other provider could serve that workload and preserve its cache behavior. Developer’s account and calculation

At that volume, adding just $0.01 per million cache reads changes the estimate by 115.75 × $0.01, or $1.16 rounded. This isolates one price difference. Explaining the full gap would require the historical rates and finalized charges for each route. Download the case sensitivity calculation (CSV)

How much can two routes cost at the same hit rate?

Take one million input tokens, of which 900,000 came from cache, and 50,000 output tokens. The rates below are invented to illustrate the calculation. All prices are in USD per million tokens, with no cache writes, tools, fees or credits in the example.

Example routeCache reads (USD/1M)Uncached input (USD/1M)Output (USD/1M)Charge (USD)
A$0.02$0.40$1.00$0.108
B$0.06$0.40$1.00$0.144

For A, the three charges are $0.018 for reads, $0.040 for misses and $0.050 for output. B costs $0.036 more entirely because its cache reads cost more. Both routes still have a 90% hit rate.

At a 90% hit rate, the example charges are $0.108 on route A and $0.144 on route B. Only the cache-read component changes.

Ofox worked example. Cache reads account for the entire $0.036 difference. Both routes use illustrative rates.

Download the editable two-route bill calculator (CSV). Open it in Excel or Google Sheets. Replace the token counts and the three rates with values from one provider and tariff period. If a rate, counter or charge is missing, leave the input blank. The affected result stays blank. Enter the finalized token charge in column J. Column K shows the billed amount minus the estimate in USD. A positive difference means the billed amount is higher.

What should I check when my estimate and invoice disagree?

  1. Match requests before comparing totals. Use request ID, precise model version, actual provider, currency and billing window. Within each provider, apply the tariff in effect when the request ran. For Ofox exports, start with the usage tracking guide.
  2. Inspect the largest unexplained difference. If the estimate exceeds the net invoice, check for double-counted input, discounts, credits and refunds. If the invoice exceeds the estimate, look for omitted output, separately billed cache writes, tools or fees. Record each adjustment on its own line.
  3. Trace retries to the original task. After a timeout, the next request may use another route. Match both IDs to finalized charges before counting either as billable. The DeepSeek error and fallback guide covers the request failures to look for.
  4. Decide whether a route trial is worthwhile. Divide total finalized spend, including billed retries, by the number of distinct tasks that met your acceptance criteria. If none passed, report the spend and zero accepted tasks. Cost per accepted task is undefined. For a trial, keep model version, request order, concurrency and acceptance criteria fixed. Compare this cost alongside failures and latency.

Once your baseline balances, the Ofox and OpenRouter comparison covers migration settings. Ofox publishes this guide. The historical case and the worked example do not measure savings from switching gateways.