To calculate a DeepSeek API bill, multiply input tokens by the input rate and output tokens by the output rate, sum the two, then discount the input side by your cache hit rate. On V4-Flash that means input at $0.14 per million tokens, output at $0.28, and cached input at $0.0028. The mix of input to output, not the headline rate, decides most of what you pay.
The arithmetic is simple, but the order of operations is where budgets go wrong. Start with the two terms everyone knows, then add the one most people forget.
cost = (input_tokens × input_rate)
+ (output_tokens × output_rate)
with cache:
input_cost = (cached_input × cache_rate)
+ (uncached_input × input_rate)
According to DeepSeek API Docs, V4-Flash bills input at $0.14 per million tokens, output at $0.28, and input served from the prompt-prefix cache at $0.0028, which is 50 times cheaper than a cache miss. So the real formula has three rates, not two. The practical upshot is that you cannot budget a chat or RAG workload accurately until you estimate what fraction of your input will hit the cache, because that one number swings the input term by up to 50x.
| Token class | V4-Flash rate ($/1M) | What it covers |
|---|---|---|
| Input (cache miss) | $0.14 | New prompt text the model has not seen |
| Input (cache hit) | $0.0028 | Repeated prompt prefix served from cache |
| Output | $0.28 | Every token the model generates |
One caveat worth stating before you run any numbers. When you call the deepseek-chat alias, the API actually serves deepseek-v4-flash, which we confirmed on a live call. Budget against the V4-Flash rate card above, not the legacy V3 figures some pricing pages still list, because the name you send is not the model you are billed for.
Retrieval-augmented generation stuffs the prompt with retrieved context, so it is input-heavy. Take a single request that sends 800,000 input tokens and generates 200,000 output tokens, with no cache hits, to make the raw shape clear.
Input is 800,000 × $0.14 per million, which is $0.112. Output is 200,000 × $0.28 per million, which is $0.056. The total is $0.168. Notice that even though input outnumbers output four to one here, the cheaper input rate keeps the input term from dominating: input is two thirds of the bill, output one third. That balance flips the moment generation grows, which is the next example.
Now invert the ratio. A code-generation request often sends a short instruction and gets back a long file, so take 200,000 input tokens and 800,000 output tokens, again with no cache.
Input is 200,000 × $0.14 per million, which is $0.028. Output is 800,000 × $0.28 per million, which is $0.224. The total is $0.252. Same one-million-token budget as the RAG example, 50 percent more expensive, purely because the tokens moved to the output side where the rate is double. According to DeepSeek API Docs, output is priced at exactly twice the cache-miss input rate, so any workload that generates more than it reads will see output drive the bill. That is the part most buyers miss when they compare providers on input price alone.
| Workload | Input tokens | Output tokens | Input cost | Output cost | Total |
|---|---|---|---|---|---|
| RAG (input-heavy) | 800,000 | 200,000 | $0.112 | $0.056 | $0.168 |
| Code-gen (output-heavy) | 200,000 | 800,000 | $0.028 | $0.224 | $0.252 |
Worked examples are clean. We wanted to see the formula run against a real response, so we called the official endpoint and recorded the raw usage object. The full run lives in our evidence pack; here is the line that matters for budgeting.
In our live test, a single realistic call to deepseek-chat used 41 input tokens and generated 75 output tokens. Running the formula: 41 × $0.14 per million is $0.00000574, and 75 × $0.28 per million is $0.000021, for a total of $0.0000267. Output was 79 percent of that bill, even though output beat input by less than two to one in token count. That is the formula confirming itself: at a 2x output rate, output dominates the moment generation pulls anywhere near input volume.
The lesson from one tiny call scales directly. If 75 output tokens already eat four fifths of a 116-token request, then any production estimate that models input carefully and waves at output will undershoot. Weight your forecast toward the output term first.
Cache hit rate is the fraction of input tokens served from DeepSeek's prompt-prefix cache rather than processed fresh, and it is the single largest lever on an input-heavy bill. The effect compounds at scale in a way a single call cannot show.
Take a chat workload running a 3,000-token system prompt plus 200 tokens of user input per call, 500 output tokens, one million calls a month, at a 70 percent prefix cache hit rate. We worked this through in our cache-discount analysis: the prefix cache cut that workload's monthly input bill by roughly 69 percent, from $448 down to about $141, while the output bill stayed flat at $140. Same traffic, same model, a 69 percent input saving from one architectural choice. According to DeepSeek API Docs, the discount fires automatically on exact byte-identical leading prefixes, with no flag to set, so the only thing standing between you and that saving is prompt structure. Put stable content first, variable user input last.
To weight the formula, split your input estimate in two: the cached share bills at $0.0028 per million, the rest at $0.14. A 0 percent hit rate and a 90 percent hit rate on the same workload are nearly an order of magnitude apart on the input term, which is why "what is your cache hit rate" is the first question any honest DeepSeek estimate has to answer.
The formula is the same for every provider; only the rates change. According to Helicone's model pricing data, OpenAI GPT-4o bills input at $2.50 and output at $10.00 per million, while Anthropic Claude Sonnet 4.6 runs $3.00 and $15.00. Run the code-gen example through GPT-4o's card and the same 200K/800K request costs $8.50 against DeepSeek's $0.252, because the rate gap, not the token count, drives the difference.
Our own coding test makes the gap concrete. We sent one Fibonacci prompt to three models and recorded the billed cost. GPT-4o, called via OpenRouter, billed $0.000795; Claude Sonnet 4.6, also via OpenRouter, billed $0.001344; DeepSeek V4-Flash on its official endpoint returned a comparable answer at a fraction of either. The comparators were measured through OpenRouter, so their numbers carry that provider's billing, not the model vendors' list price.
What is the formula for DeepSeek API cost? Multiply input tokens by the input rate and output tokens by the output rate, then sum them. On V4-Flash that is input at $0.14 per million and output at $0.28. If your prompts repeat a stable prefix, split the input term so the cached share bills at $0.0028 per million and the rest at $0.14.
Why is output more expensive than input on DeepSeek? Output is priced at $0.28 per million, exactly twice the $0.14 cache-miss input rate. In our live test a 41-input, 75-output call put 79 percent of the bill on the output side, so any workload that generates more than it reads will see output dominate the total.
How much does cache change the estimate? A lot, on input-heavy workloads. At a 70 percent prefix cache hit rate, a sample chat workload's monthly input bill fell about 69 percent, from $448 to roughly $141, because cached input bills at $0.0028 per million instead of $0.14. Output is unaffected by cache.
What did a real DeepSeek call cost in your test?
A single realistic call to deepseek-chat used 41 input and 75 output tokens and cost $0.0000267 total. The alias was served by deepseek-v4-flash, so we budget against the V4-Flash rate card, not legacy V3 figures.
This is part of the DeepSeek API pricing hub. For the rate-by-rate breakdown, see the input vs output pricing article.
Author: Kevin Fan, Customer Success Manager at China LLM Directory, specializing in Chinese LLM ecosystem pricing. Last verified: 2026-05-13.
<!-- METADATA { "title": "How to Calculate DeepSeek API Costs (2026)", "slug": "deepseek-api-cost-calculator", "meta_description": "The DeepSeek cost formula, worked: RAG 800K/200K = $0.168, code-gen 200K/800K = $0.252, weighted by cache. A live call billed $0.0000267, output 79%. 2026-05.", "focus_keyword": "deepseek api cost calculator", "secondary_keywords": ["deepseek api cost formula", "calculate deepseek api cost", "deepseek token cost estimate", "deepseek blended cost"], "tags": ["DeepSeek", "API Pricing", "Cost Calculator"], "category": "Pricing", "cluster_id": "deepseek-api-pricing", "cluster_role": "micro", "hub_slug": "deepseek-api-pricing", "verified_until": "2026-08-11", "evidence_file": "clients/china-llm-aggregator/articles/deepseek-api-pricing-evidence.json", "author_name": "Kevin Fan", "author_title": "Customer Success Manager", "author_linkedin": "", "author_expertise": ["Chinese LLM ecosystem", "AI infrastructure pricing", "model benchmarking", "cross-border AI compliance"], "faq_pairs": [ {"q": "What is the formula for DeepSeek API cost?", "a": "Multiply input tokens by the input rate and output tokens by the output rate, then sum them. On V4-Flash that is input at $0.14 per million and output at $0.28. If your prompts repeat a stable prefix, split the input term so the cached share bills at $0.0028 per million and the rest at $0.14."}, {"q": "Why is output more expensive than input on DeepSeek?", "a": "Output is priced at $0.28 per million, exactly twice the $0.14 cache-miss input rate. In our live test a 41-input, 75-output call put 79 percent of the bill on the output side, so any workload that generates more than it reads will see output dominate the total."}, {"q": "How much does cache change the estimate?", "a": "A lot, on input-heavy workloads. At a 70 percent prefix cache hit rate, a sample chat workload's monthly input bill fell about 69 percent, from $448 to roughly $141, because cached input bills at $0.0028 per million instead of $0.14. Output is unaffected by cache."}, {"q": "What did a real DeepSeek call cost in your test?", "a": "A single realistic call to deepseek-chat used 41 input and 75 output tokens and cost $0.0000267 total. The alias was served by deepseek-v4-flash, so we budget against the V4-Flash rate card, not legacy V3 figures."} ], "external_links_used": [ {"url": "https://api-docs.deepseek.com/quick_start/pricing/", "source_name": "DeepSeek API Docs – Pricing", "claim": "V4-Flash input $0.14/M, output $0.28/M, cache hit $0.0028/M; cache fires automatically on byte-identical prefixes"}, {"url": "https://www.helicone.ai/llm-cost", "source_name": "Helicone LLM Cost", "claim": "GPT-4o input $2.50/M output $10.00/M; Claude Sonnet 4.6 input $3.00/M output $15.00/M"} ], "internal_links_used": [ {"url": "/blog/deepseek-api-pricing/", "anchor_text": "DeepSeek API pricing hub", "type": "hub"}, {"url": "/blog/deepseek-api-pricing/", "anchor_text": "evidence pack", "type": "hub"}, {"url": "/blog/deepseek-input-vs-output-pricing/", "anchor_text": "input vs output pricing article", "type": "sibling-micro"} ], "first_hand_evidence": { "source": "deepseek-api-pricing-evidence.json run label realistic_call + coding_comparison_same_prompt", "measured": "realistic_call: 41 input + 75 output tokens, total $0.0000267, output 79% of bill, deepseek-chat served deepseek-v4-flash; coding comparison: GPT-4o via OpenRouter billed $0.000795, Claude Sonnet 4.6 via OpenRouter billed $0.001344", "captured": "2026-05-13" }, "images_status": "spec-only (not generated; FAL_API_KEY unset)", "images": [ {"position": "featured", "type": "generated", "prompt": "Clean editorial diagram of the DeepSeek API cost formula: input tokens times input rate plus output tokens times output rate, with a cache-rate weighting branch on the input term. Two worked examples (RAG and code-gen) shown as small bar pairs. Blue and amber palette. Minimal background. 16:9.", "alt": "Diagram of the DeepSeek API cost formula showing input and output terms with a cache-rate weighting branch, plus RAG and code-generation worked examples"} ] } -->