Most LLM cost estimates are wrong in the same three places. They multiply tokens by a single price, they forget that output costs 5× input, and they assume a cache hit on every call. The result is a spreadsheet that predicts $180 and an invoice for $475 — a gap large enough to make a product look unprofitable when it is not, or profitable when it is not.
The correct formula is not complicated. It has five terms, two conditional rules and one multiplier. Once you write it down, every provider's price sheet collapses into the same arithmetic, and the differences between models become obvious rather than intuitive.

For a single request, with all prices in USD per million tokens:
cost = ( uncached_in × P_in + cached_in × P_cache + cache_writes × P_write + out × P_out ) ÷ 1,000,000
Then apply two modifiers:
Every term is optional. Models without prompt caching have no P_cache or P_write; models without a tier never trigger the first modifier; DeepSeek has no batch, so the second never applies.
A support assistant handles 50,000 requests a month. Each request sends a 3,000-token prompt, of which 2,500 tokens are a stable block (system instructions plus the retrieved help-centre article), and receives an 800-token answer. The model is GPT-6 Sol at $2.00 input, $0.20 cached, $2.50 write and $10.00 output.
| Term | Tokens / month | Rate | Cost |
|---|---|---|---|
| Uncached input (500 × 50,000) | 25,000,000 | $2.00 | $50.00 |
| Cached input (2,500 × 49,999) | 124,997,500 | $0.20 | $25.00 |
| Cache writes (one per job) | 2,500 | $2.50 | $0.006 |
| Output (800 × 50,000) | 40,000,000 | $10.00 | $400.00 |
| Total | — | — | $475.01 |
Two numbers deserve attention. The first is the cache write: $0.006, because the 2,500-token block is written once and read 49,999 times. Teams often budget the write as if it happened on every call, which inflates the estimate by four orders of magnitude.
The second is the output share: $400 of $475 — 84% of the bill — comes from 40 million output tokens that represent 16% of the total token volume. Any cost model that treats input and output as interchangeable is wrong by a factor of five.
| Scenario | Cost / month | Difference |
|---|---|---|
| No caching | $700.00 | — |
| With caching | $475.01 | −32% |
| With caching + batch | $237.50 | −66% |
Caching alone removes $225 a month. Batch on top removes another $237. Neither changes the model, the prompt or the output — only when and how the request is sent. That is the cheapest 66% in this entire field.
| Model | Monthly cost | Output share |
|---|---|---|
| GPT-6 Luna | $23.75 | 84% |
| DeepSeek V4.1 Flash | $56.25 | 85% |
| Gemini 3.8 Flash | $178.12 | 84% |
| Claude Sonnet 5 | $475.01 | 84% |
| GPT-6 Sol | $475.01 | 84% |
The output share is constant because the token shape is constant — which is the point. Model choice changes the total by 20×, while the internal structure of the bill stays the same. Optimising the formula without changing the model caps out at about a 66% saving; changing the model can save 95%.
1. Multiplying total tokens by the input rate. On this workload that predicts $350 instead of $475 — a 26% underestimate, and the most common error in startup financial models.
2. Assuming every call is a cache hit. The first call writes; subsequent calls read. For low-volume products the write dominates, and caching can cost more than it saves. Cache only prefixes reused more than twice.
3. Ignoring the long-context tier. A 300,000-token prompt on GPT-6 Sol bills at $4.00, not $2.00, for all 300,000 tokens. The tier applies to the whole request.
4. Using average prompt length. Bills are driven by the tail, not the mean. A pipeline with a 3,000-token average and a 300,000-token p99 has a long-context problem hiding in its averages.
5. Forgetting retries and failed calls. A 5% retry rate is a 5% surcharge. Timeouts that were billed but returned nothing are worse — they are pure waste that appears in the token count with no output to show for it.
6. Counting cached tokens as free. Cached tokens still occupy the context window and still count against rate limits. They are cheaper, not invisible.
Columns: requests, input tokens, cached tokens, output tokens, model. Then:
If any row's input exceeds the tier threshold, swap the rates before multiplying. If the job is asynchronous, halve the result. That is the entire model — and it is what the free LLM cost calculator does behind the interface.
The formula shows where the money actually goes: 84% output, 5% uncached input, 5% cached input, and a rounding error for cache writes. A team that spends a month evaluating cheaper models to save 20% is optimising the 10% of the bill that is input. A team that cuts output length by 30% saves 25% of the total without changing models at all.
Both are worth doing. But the order matters: fix the shape of the request first, then pick the model. Doing it the other way round means re-running the evaluation after every prompt change.
Multiply uncached input tokens by the input rate, cached input by the cached rate, cache writes by the write rate and output tokens by the output rate, then divide by one million. Apply the long-context tier if the prompt exceeds the threshold, and halve the result for batch requests.
Output tokens are generated sequentially, one forward pass per token, while input tokens are processed in parallel. Every major provider prices output at 4–5× input to reflect that difference.
No. A prefix is written once and then read on subsequent calls, provided the prefix is identical and the cache has not expired. Budget one write per distinct prefix, not one per request.
On the workload above — 3,000 input and 800 output tokens — GPT-6 Luna costs $0.48 per 1,000 requests, Gemini 3.8 Flash $3.56, and GPT-6 Sol $9.50. The shape of the request matters more than the headline rate.
Run the numbers for your own traffic in the free LLM cost calculator, or read the full model ranking to see which tier fits your token shape.