How to Calculate the Real Cost Behind LLM API Price Increases

    This article breaks down why a higher list price on a new-generation LLM API does not translate directly into a higher bill. Using a three-tier pricing model (cache-hit input, cache-miss input, output), it derives a simple cost formula driven by two variables: the input-to-output ratio (r) and the cache hit rate (h). It shows how the same model and price sheet can produce roughly 3.6x difference in effective unit cost across workloads, explains why cache hit rate is the first optimization lever, and lists practical steps such as stable prefix layout, context control, output compression, batching, and observability, plus selection and governance advice.

    1. The Phenomenon: List Price Growth Is Not Bill Growth

    A recent pricing announcement for a new-generation LLM triggered debate: compared with the previous generation, the output-side unit price rose by roughly 4x, the input side (cache miss) by roughly 3x, while the cache-hit tier increased more moderately. Looking at list prices alone, the conclusion seems to be “costs multiplied several times over.” But a real bill is a weighted result of three price tiers applied to your call mix, so there is no equals sign between list-price growth and bill growth.

    First, abstract the three tiers into symbols for the derivation that follows:

    • P_in_miss: input cache-miss unit price
    • P_in_hit: input cache-hit unit price
    • P_out: output unit price

    The previous generation’s typical magnitudes were about 6.5 / 1.1 / 27, and the new generation’s are about 20 / 2 / 100 (unit: CNY per million tokens). What deserves attention is not the absolute values but the shift in the ratio structure:

    Ratio Previous gen New gen Change
    Miss input / hit input ≈6x ≈10x Widened
    Output / hit input ≈25x ≈50x Widened
    Output / miss input ≈4x 5x Slight rise

    The core signal in this table is that the pricing strategy is shifting cost pressure away from “cache hits” and onto “missed input” and “output.” In effect, price is being used as a lever to push callers toward higher context reuse, leaner ineffective input, and tighter control of verbose output.

    2. The Cost Model: Two Variables Decide Your Real Unit Price

    Let the input-to-output ratio be r (input tokens / output tokens) and the cache hit rate be h. Then:

    1. effective input unit price = P_in_hit * h + P_in_miss * (1 - h)
    2. blended unit price = (r * effective input unit price + P_out) / (r + 1)

    Plugging in the new-generation prices, consider two typical workloads:

    Scenario A: enterprise-grade long-context AI coding workload, r = 20, h = 0.9

    1. input side ≈ 2*0.9 + 20*0.1 = 3.8
    2. blended ≈ (20*3.8 + 100) / 21 ≈ 8.4 CNY per million tokens

    Scenario B: low-frequency retail calls where context never repeats, r = 5, h = 0.2

    1. input side ≈ 2*0.2 + 20*0.8 = 16.4
    2. blended ≈ (5*16.4 + 100) / 6 ≈ 30.3 CNY per million tokens

    Same model, same price sheet, and the unit cost differs by about 3.6x. The gap is fully attributable to r and h: Scenario A’s effective input unit price is only 19% of the listed miss price, while Scenario B’s is as high as 82%.

    An easily overlooked implication: because the output unit price is 50x the hit-input price, the marginal cost of output tokens is far higher than that of input. In short-input, long-output workloads with small r, the bill is almost entirely dominated by output, and any input-side optimization yields very limited benefit.

    3. Why the Cache Hit Rate Is the First Lever

    Mainstream inference services generally adopt a disaggregated deployment approach: splitting context prefill and token-by-token decode into separate resource pools, combined with prefix KV cache reuse, so repeated prefixes need not be recomputed. In engineering practice, this architecture can push the hit rate for stable prefixes—system prompts, tool definitions, code repository context—to very high levels.

    The hit rate’s effect on the bill is non-linear. Using the new-generation prices:

    1. h = 0.0 → input side 20.0
    2. h = 0.5 → input side 11.0
    3. h = 0.9 → input side 3.8
    4. h = 0.99 → input side 2.2

    Going from 0.9 to 0.99 cuts the input side by another 42%; going from 0.5 to 0.9 cuts it by 65%. This means optimization effort should be directed first at the “no cache to stable cache” stage.

    4. An Actionable Optimization Checklist

    1. Stable prefix layout: put invariant content (system instructions, output format constraints, tool/function signatures, glossaries) at the very front of the prompt, and place request-varying content afterward. Once the prefix order changes or a variable field is inserted, all subsequent cache is invalidated.
    2. Control context bloat: for long-repository or long-document scenarios, use retrieval plus layered summarization, injecting only fragments relevant to the current task, which both raises h and cuts the ineffective portion of r.
    3. Compress output: explicitly constrain output format and length, keep reasoning traces and redundant explanations out of billed output; structured output (such as strict JSON) is usually cheaper than free text.
    4. Batch and go asynchronous: group parallelizable offline tasks and reuse the same prefix to significantly lift the hit rate.
    5. Build observability: use logging services and monitoring alerts to track the three token categories (input / output / hit) and converted cost per business dimension, forming a “unit cost per request type” dashboard, then locate high-consumption call chains.

    Illustrative accounting formula:

    1. cost_per_request =
    2. in_hit * P_in_hit
    3. + in_miss * P_in_miss
    4. + out * P_out

    5. Selection and Governance Recommendations

    • Select by workload structure, not list price: long-context, high-reuse workloads are sensitive to caching capability; short-input, long-output workloads should compare output unit price and generation quality.
    • Set budgets and quotas: apply rate limiting and degradation to high-consumption chains on the container platform side to avoid abnormal retries inflating the bill.
    • Tiered routing: send simple requests to lightweight models or rule-based paths, and escalate only complex requests, lowering the overall weighted average unit price.
    • Regression validation: any change to prompt structure or retrieval strategy must be validated against a fixed evaluation set to confirm quality has not regressed, preventing “saved tokens, lost results.”

    6. Conclusion

    The essence of the new price system is turning “context reuse capability” and “output restraint capability” into priceable economic signals. For enterprise-grade high-reuse scenarios, the blended cost can still stay in a low range; for low-frequency, low-reuse scenarios, cost pressure rises noticeably. Bringing r and h into everyday architecture design and cost dashboards is more practically valuable than arguing about list-price growth.