LLM Inference Cost Estimation and Plan Selection: A Practical Guide

    Comparing per-million-token prices is a common but misleading way to evaluate LLM inference services, because the real bill depends on several billing dimensions at once: cache hit vs. cache miss input pricing, output pricing, the cache hit rate, peak vs. off-peak pricing, and the purchase model (pay-as-you-go vs. a monthly plan). This article builds a reusable cost model, shows how the cache hit rate and peak-hour share act as the decisive multipliers, explains how to convert a subscription plan into an equivalent API unit price, and closes with a selection checklist and common pitfalls. Readers get a repeatable engineering method for turning traffic characteristics into a reproducible cost decision.

    1. Why “Unit Price Comparison” Often Leads to the Wrong Conclusion

    When evaluating LLM inference services, the most common approach is to put the “price per million tokens” of two options side by side. The flaw in this approach is that a real bill is not determined by any single unit price, but by several billing dimensions working together. At minimum, these include:

    • Cached input, uncached input, and output tokens often carry different unit prices;
    • The cache hit rate is itself a variable that depends on how repetitive the workload is;
    • Some services distinguish peak-hour pricing from discounted off-peak pricing;
    • The purchase model (pay-as-you-go vs. a monthly plan) changes the effective unit price.

    So the right approach is to build a cost model first, plug in the real parameters of your own workload, and only then ask “which one is cheaper.” Below is a general method.

    2. Building a Reusable Cost Model

    Let the total token volume be T, the cache hit rate be h, the input share be i, and the output share be o (i + o = 1), with cache unit price p_cache, uncached input unit price p_in, and output unit price p_out. Then:

    1. Cost = T * [ h * p_cache + (i - h) * p_in + o * p_out ]

    Note one constraint that is easy to overlook: h ≤ i. Cached tokens are necessarily a subset of input tokens, so the hit rate can never exceed the input share.

    Example code:

    1. def cost_per_100m(hit, in_ratio, out_ratio, p_cache, p_in, p_out):
    2. assert hit <= in_ratio, "The cache hit rate cannot exceed the input share"
    3. return 1e8 * (hit * p_cache
    4. + (in_ratio - hit) * p_in
    5. + out_ratio * p_out)

    3. Cache Hit Rate: The Dividing Line of Cost Structure

    Plugging two typical pricing structures into the model (numbers are for demonstration only): in structure A, the cache unit price is about 2.3x the input unit price; in structure B, the cache unit price is about half the input unit price.

    • With h = 0.98, i = 0.015, o = 0.005, structure A is clearly better;
    • When h drops to around 0.95, the conclusion flips and structure B becomes the better deal.

    The reason is intuitive: at a high hit rate, the bill is dominated almost entirely by the cache unit price, and the difference between input and output unit prices is pushed to the margins. Once the hit rate slips, the uncached input portion gets amplified, and that portion is relatively expensive under structure A.

    Engineering takeaway: do not budget with a single static hit rate. Estimate costs at both P50 and P95 hit rates, and keep a stress scenario for “a sudden drop in hit rate.”

    4. Peak Hours: The Underrated Multiplier

    Beyond caching, time-of-day pricing is the second variable. Platforms define peak hours very differently: some count only a few hours per day, others cover the entire workday. The share of peak duration directly determines how much of the discounted price you can actually capture.

    Let the peak duration share be q and the peak price be k times the off-peak price. The cost amplification factor from time-of-day pricing is roughly 1 + q * (k - 1). If peak covers only 4 hours a day (q ≈ 0.024), the impact is limited; if it covers the entire workday (q ≈ 0.6 or more), cost can double. In capacity planning, schedule non-real-time work such as batch jobs, offline evaluation, and code completion into off-peak windows as much as possible.

    5. Converting a Monthly Plan into an Effective Unit Price

    The core of plan selection is converting the “plan price” into an “equivalent API unit price” and comparing it against pay-as-you-go:

    1. Equivalent unit price = Monthly plan fee / Available tokens per month
    2. Discount rate = Equivalent unit price / Original API unit price

    Take a three-tier coding plan as an example (numbers for demonstration only): after conversion, the discount rate lands roughly in the 50%–70% range, meaning the plan is equivalent to half price up to 70% of the original API price. This implies:

    1. As long as your actual usage consumes most of the plan quota, the plan is almost always the better option;
    2. If usage fluctuates heavily and the plan sits idle for most of the month, pay-as-you-go is actually cheaper;
    3. Plan quotas are usually settled per cycle (for example, weekly), so watch out for waste caused by quota expiration.

    6. Selection Decision Checklist

    • Measure the input/output ratio and the distribution of cache hit rates over the last 30 days;
    • Use the model above to compute the monthly cost of both pay-as-you-go and the plan;
    • Add the peak duration share for a sensitivity analysis;
    • Schedule non-real-time workloads into off-peak windows to lower the peak share;
    • Recheck the hit rate every two weeks, and recompute the budget whenever hit rate drift exceeds 3 percentage points.

    7. Common Pitfalls

    • Looking only at the cache unit price: a low cache unit price only holds up at a high hit rate;
    • Ignoring the output share: output unit price is usually the highest, and a rising output share quickly eats up the advantage from caching;
    • Treating the peak as the average: capacity planning should use P95, not the average;
    • Overlooking the quota cycle: when the plan’s settlement cycle does not match your workload’s peaks and troughs, the effective discount shrinks substantially.

    Summary: the key to cost optimization is not hunting for the “cheapest unit price,” but quantifying your own traffic characteristics (hit rate, input/output ratio, time-of-day distribution) and feeding them into a unified model. Once you do that, selection turns from an intuitive judgment into a reproducible engineering decision.