How to Calculate the Real Cost of LLM API Discounts and Cache Price Cuts
This guide explains why a lower per-token price does not always mean a lower bill for LLM inference. It covers how to normalize different pricing models into a common unit, build a per-request cost model with cache hit rate as an explicit variable, run sensitivity analysis, and solve for the break-even hit rate that determines whether a discount is worthwhile. It also outlines hidden costs, engineering constraints, and a one-week workflow for validating estimates against real traffic.
1. Why a Cheap Unit Price Often Means an Expensive Bill
Pricing for large model inference is evolving quickly. Limited-time discounts, cache hit discounts, and tiered credit packages are increasingly common. When choosing a provider, developers often make one mistake: comparing only the listed price per million tokens while ignoring their own input-to-output ratio, context length distribution, and repeated prefix ratio.
In a typical coding assistant or long-document Q&A request, input tokens are often about ten times the output tokens. The bill is therefore dominated by the input side, and the input side depends heavily on the cache hit rate. The real value of any discount has to be recalculated against your own request profile, not read off a promotional page.
Billing rules also differ widely across providers. Some charge in three segments: input, output, and cache hit. Some convert usage into virtual credits. Some charge by context length tiers. Before comparing across these systems, you must first convert everything to the same unit.
2. Normalize Pricing: Convert Every Quote to CNY per Million Tokens
Assume a promotion offers a generic quote like this (illustrative only, not any specific provider):
Discounted: cache hit 0.25 / cache miss 3 / output 6 (CNY per million tokens)Original: cache hit 1 / cache miss 12 / output 24Small model: cache hit 0.2 / cache miss 1 / output 2
Package products usually work differently: a fixed amount buys a fixed number of credits, which are then converted using a model coefficient, for example 1 token = 1 credit or 1 token = 2 credits. The conversion looks like this:
def credits_to_yuan_per_mtok(budget_yuan, total_credits, credit_per_token):# Implied price per token (CNY)yuan_per_token = budget_yuan / (total_credits / credit_per_token)return yuan_per_token * 1_000_000
The key point: a package has a fixed total quota, but how much you can actually use depends on the model coefficient and your cache structure. Pay-as-you-go has a fixed unit price, but the actual bill depends on your hit rate. Both must sit in the same table before you can compare them.
3. Per-Request Cost Model: Make the Hit Rate an Explicit Variable
Let I be input tokens, O output tokens, and h the cache hit rate for a single request:
cost = I*(1-h)*p_miss/1e6 + I*h*p_hit/1e6 + O*p_out/1e6
With I = 51,000, O = 5,100, and h = 56%, the input splits into 28,560 cached and 22,440 uncached tokens, 56,100 in total. Plugging in the different pricing schemes gives roughly: about 0.037 CNY for the small model, about 0.105 CNY for the discounted large model, and about 0.075 CNY for the large model with a 2x coefficient. A 40 CNY budget buys about 1,070, 381, and 535 calls respectively.
One counterintuitive result: at h = 56%, the discounted price and the package price are clearly apart, but as h approaches 80%, the two converge. The reason is simple. The discounted price pushes the cache hit price very low, so a higher hit rate increases the marginal advantage of the discount, while the package unit price does not depend on the hit rate at all.
4. Sensitivity Analysis: Hit Rate and Input/Output Ratio Are the Two Main Axes
def cost_per_call(I, O, h, p_hit, p_miss, p_out):return (I*(1-h)*p_miss + I*h*p_hit + O*p_out) / 1e6for h in (0.0, 0.3, 0.56, 0.8, 0.95):print(h, round(cost_per_call(51000, 5100, h, 0.25, 3, 6), 4))
Three things matter in practice:
- The cache hit rate is a property of your product, not of marketing. It depends on whether your framework reliably reuses the same prefix (system prompt, tool definitions, conversation history). Once the prefix becomes dynamic (timestamps, random IDs, changing retrieval results), the hit rate drops sharply.
- The input/output ratio determines discount sensitivity. The higher the output share, the more weight the output price carries, and the more the cache discount is diluted.
- Context limits and tiered pricing can change the conclusion. If a plan charges extra for very long contexts, long-document scenarios need to be modeled separately.
5. Convert the Discount into a Break-Even Hit Rate
Instead of comparing absolute prices, solve for the hit rate at which the two options break even:
def breakeven_hit(p_hit_a, p_miss_a, p_out_a, p_hit_b, p_miss_b, p_out_b, I, O):# Solve for h where the per-call cost of A and B are equalbase_a = (I*p_miss_a + O*p_out_a)/1e6base_b = (I*p_miss_b + O*p_out_b)/1e6slope_a = I*(p_hit_a - p_miss_a)/1e6slope_b = I*(p_hit_b - p_miss_b)/1e6return (base_b - base_a) / (slope_a - slope_b)
If the break-even hit rate is higher than your measured value, the discount is not worth it; if it is lower, it is. This is far more reliable than a gut feeling about what looks cheap.
6. Don’t Ignore Hidden Costs and Engineering Constraints
- Rate limits and concurrency: cheaper tiers often come with stricter rate limits, and retries inflate the real cost.
- Billing granularity: rounding per token, minimum billable units, and whether failed requests are charged all affect small, high-frequency workloads.
- Data and compliance: log retention, redaction, and regional deployment requirements may change which options are available to you.
- Migration cost: switching providers means redoing prompt adaptation, evaluation set regression, and cache strategy validation.
7. A One-Week Workflow for a Trustworthy Estimate
- Sampling: pull 500 to 1,000 requests from real traffic and measure the I/O distribution and prefix repetition.
- Offline recomputation: run the model above on each request to compute the cost under each option, and report percentiles rather than averages.
- Small-scale load test: verify the actual hit rate, time to first token, and throughput, then calibrate the model error.
- Set guardrails: add a budget cap at the application layer, normalize cache prefixes, and fall back to the small model on failure.
- Re-evaluate regularly: when the discount expires, recompute the break-even point and turn the results into a selection dashboard.
8. Conclusion
Limited-time discounts and cache price cuts change the slope of the cost function, not the intercept. As long as developers stick to four steps, unifying the pricing unit, modeling the hit rate explicitly, deciding with the break-even point, and calibrating with real traffic, they can stay rational while prices fluctuate. If you need elastic compute along with supporting data, monitoring, and logging capabilities, you can evaluate general product combinations from compliant cloud platforms such as Baidu AI Cloud first, and keep the focus of your selection on verifiable engineering metrics.
