Decoding Cache-Based Pricing Behind LLM API Price Increases

    This article breaks down why a headline "across-the-board" LLM API price increase can mean very different real costs depending on how you call the model. It explains the shift in pricing weight toward cache reuse, the engineering reason behind it (prefill/decode separation and prefix reuse), and a simple formula using hit rate and input-to-output ratio to calculate effective unit cost. It also includes a comparison workflow, a Python example, and a practical cost-optimization checklist.

    1. Start With the List Price: Breaking Down an “Across-the-Board” Increase

    A next-generation model from an AI coding tool published new pricing: output at 100 per million tokens, uncached input at 20, and cached input at 2. The previous generation of the same product line was roughly 27 for output, about 6.5 for uncached input, and about 1.1 for cached input.

    Taken at face value, output is nearly 4x and input is about 3x, which does look like an across-the-board increase. But stopping at this layer leads to a wrong conclusion: that every caller’s cost went up by 3x to 4x.

    What actually matters is not the absolute price but the ratio between tiers:

    Ratio Previous generation New generation
    Uncached input / cached input ~6x ~10x
    Output / cached input ~25x ~50x

    Both ratios widened at the same time, which means the pricing system has shifted from “roughly even distribution” to “strong incentive to reuse.” The cached-input tier rose relatively modestly, while output rose the most. This is not a simple price hike but a reallocation of pricing weight.

    2. Why Vendors Can Price This Way: Disaggregated Inference and Prefix Reuse

    This pricing works only if the engineering side can actually push cache hit rates high. A common industry approach is to split inference into two stages: a prefill stage that processes the long input, and a decode stage that generates token by token. Placing them in separate resource pools and scheduling them independently lets a frequently reused prefix be computed once and stay resident, pushing hit rates very high (public technical talks mention enterprise coding scenarios reaching over 90%).

    The takeaway for users is direct: your bill is no longer determined only by how many tokens you send, but by how many of them are repeated.

    3. A Quantitative Model: Three Variables Determine Your Real Unit Price

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

    1. Effective input price = cached price × h + uncached price × (1 - h)
    2. Blended unit cost = (r × effective input price + output price) / (r + 1)

    Scenario A: enterprise long-context coding assistant, r≈20, h≈0.9

    1. Input ≈ 2×0.9 + 20×0.1 = 3.8 per million tokens
    2. Blended ≈ (20×3.8 + 100) / 21 ≈ 8.4 per million tokens

    Scenario B: light individual developer, r≈5, h≈0.2, every prompt is different

    1. Input ≈ 2×0.2 + 20×0.8 = 16.4 per million tokens
    2. Blended ≈ (5×16.4 + 100) / 6 ≈ 30.3 per million tokens

    For the same model, the former’s unit cost is about one third of the latter’s. The so-called “price increase” is close to a discount for stable, high-reuse, long-context workloads, and close to list price or even a premium for low-reuse calls with highly scattered prompts.

    4. Upgrade How You Compare: From Unit Price to Effective Cost

    The traditional habit of looking at “how much per million tokens” will badly misjudge things under the new pricing structure. A three-step approach is recommended:

    1. Sample real traffic and measure the distribution of h and r, rather than taking a single-point average;
    2. Plug the values into the formula above to compute effective unit cost, then compare models side by side;
    3. Watch marginal changes: raising the hit rate from 0.8 to 0.9 and cutting the output price by 20% have completely different magnitudes of impact on the bill.

    Illustrative implementation:

    1. def effective_cost(hit_price, miss_price, out_price, hit_rate, io_ratio):
    2. in_price = hit_price * hit_rate + miss_price * (1 - hit_rate)
    3. return (io_ratio * in_price + out_price) / (io_ratio + 1)
    4. # High-reuse long-context workload
    5. print(effective_cost(2, 20, 100, 0.90, 20)) # ≈ 8.4
    6. # Low-reuse short-interaction workload
    7. print(effective_cost(2, 20, 100, 0.20, 5)) # ≈ 30.3

    5. Cost-Optimization Checklist

    • Stable prefix: Keep system prompts, tool definitions, and few-shot examples fixed at the very front of the request, and avoid putting volatile content such as timestamps or random IDs in the prefix, since such fields invalidate the entire prefix cache.
    • Converge prompt variants: Generate prompts from templates to reduce “different every time” free text.
    • Control output length: Output is the tier with the largest increase, so limiting maximum generation length and requiring concise structured output gives the most direct benefit.
    • Split requests: Instead of stuffing a long document in all at once, break it into reusable segments to raise prefix repetition.
    • Observability: Instrument logging services and monitoring alerts to track hit rate, input-to-output ratio, and cache invalidation reasons, so cost can be attributed to specific business flows.

    6. Conclusion

    The essence of this price adjustment is shifting cost pressure from “cache-friendly workloads” to “cache-unfriendly workloads.” When evaluating models, developers should treat hit rate and input-to-output ratio as first-class metrics; on the enterprise side, workloads with a stable system prefix and long-context characteristics may see actual unit costs well below what the list price suggests. If you need elastic compute along with supporting data storage, logging, and monitoring capabilities to enable the optimizations above, you can design the architecture using the relevant general cloud product capabilities from Baidu AI Cloud.