LLM Inference Cost Modeling: Cache Billing, Token Mix, and Subscription Plans

    This article presents a reusable framework for estimating large language model inference costs across cache billing, pay-as-you-go pricing, and monthly subscription plans. It explains why comparing cache unit prices alone is misleading, derives a cost formula based on token composition, analyzes cache-hit-rate sensitivity, evaluates the effective cost of subscription plans, and provides an engineering checklist and pseudocode for ongoing cost review.

    LLM Inference Cost Modeling: Cache Billing, Token Mix, and Subscription Plans

    When selecting a large language model inference service, cache-hit unit prices are often compared directly. But a lower unit price does not necessarily mean a lower real cost. Real cost is determined by the token composition of the business workload: cache-hit share, input share, output share, peak and off-peak distribution, and subscription quota utilization all change the final bill. This article does not focus on any specific product. Instead, it abstracts “cache billing + pay-as-you-go billing + monthly subscription plans” into a general cost model to help readers build a reusable accounting method.

    1. Why Cache Unit Price Alone Is Not Enough

    A cache-hit price usually covers only the “repeated context” portion. The tokens in one inference request are often composed of three parts: prefix tokens that hit the cache, input tokens that miss the cache, and output tokens generated by the model. If the cache hit rate is high, the cache unit price carries more weight in total cost. If the hit rate drops, input and output unit prices quickly become dominant. As a result, one option may be cheaper at a 98% hit rate, while the conclusion may reverse at a 95% hit rate.

    This means that at least two things are needed during selection. First, build a cost formula that includes all three token types. Second, perform sensitivity analysis on the cache hit rate instead of comparing only one cache unit price.

    2. Building a Comparable Cost Model

    Let total tokens be T (in millions), the cache-hit ratio be h, the cache-miss input ratio be i, and the output ratio be o, where h + i + o = 1. Let the cache unit price be p_c, the input unit price be p_i, and the output unit price be p_o. The total cost can be written as:

    C = T × (h × p_c + i × p_i + o × p_o)

    If subscription or billing rules also include cache writes, cache storage, tiered discounts, or peak/off-peak differences, those fees should be added to the model as separate items. In practice, it is better to calculate h, i, and o separately for each business line rather than using a site-wide average.

    The following anonymized example is used only to illustrate sensitivity analysis and does not constitute any real quote. Suppose two billing plans, A and B, are available for a type of inference service. Under a token composition of 98% cache hits, 1.5% input, and 0.5% output, the total cost per 100 million tokens is CNY 12.57 for Plan A and CNY 9.40 for Plan B. When the cache hit rate drops to 95%, the total costs become CNY 14.92 and CNY 18.25, respectively. Plan B is lower at a 98% hit rate but higher at a 95% hit rate. The reason is not the cache unit price itself, but the increased weight of input and output tokens in low-hit scenarios, which amplifies the impact of Plan B’s non-cache unit prices.

    Scenario Plan A cost per 100M tokens Plan B cost per 100M tokens Observation
    98% cache hit CNY 12.57 CNY 9.40 B is lower
    95% cache hit CNY 14.92 CNY 18.25 A is lower

    Therefore, any selection conclusion must be tied to the business’s hit-rate range. If the business cache hit rate is stable above 98%, cache unit price carries more weight. If the hit rate fluctuates widely, or if input and output shares are relatively high, the comparison should focus on input and output unit prices and subscription overage costs.

    3. Sensitivity Analysis of Cache Hit Rate

    Cache hit rate does not affect total cost linearly. The higher the hit rate, the larger the share of cache unit price in total cost. When the hit rate falls, cache-miss input tokens and output tokens increase quickly. From an engineering perspective, the hit rate should be monitored across multiple dimensions: by business line, by request type, by context length, by time window, and by model version. Looking only at a global average hit rate can easily hide the high cost of long-tail requests.

    Common ways to improve hit rate include: keeping the prompt prefix stable by placing system instructions, fixed knowledge, and tool descriptions at the front; avoiding volatile content such as timestamps, random numbers, and session IDs in the prefix; applying layered truncation to long contexts and prioritizing reuse of stable segments; designing interpretable cache keys so that requests with the same semantics hit the same cache as much as possible; and using canary observation for cache invalidation and version switches. Caching is not a set-and-forget feature; hit rates require ongoing load testing and regression checks.

    4. Effective Cost Accounting for Monthly Subscription Plans

    Subscription plan evaluation should not look only at the monthly fee. Effective cost should be written as:

    Effective unit price = (monthly fee + overage fee + opportunity cost of unused quota) / actual tokens consumed

    The overage fee is the pay-as-you-go charge incurred after exceeding the subscription quota. The opportunity cost of unused quota is the waste caused by unused subscription quota. Whether a subscription plan is cost-effective depends on three conditions: whether the quota can be consumed steadily, whether peak-period restrictions match business traffic peaks, and whether the overage probability is controllable.

    Anonymized example: the low-tier plan costs CNY 118 per month, the mid-tier plan CNY 538, and the high-tier plan CNY 1,078. Under off-peak conditions and a 98% cache hit rate, the weekly quotas are approximately 317 million, 1.900 billion, and 4.433 billion tokens, respectively. Their equivalent pay-as-you-go value is approximately CNY 160, CNY 955, and CNY 2,229, and the plan unit price is approximately 50%–70% of the pay-as-you-go price. At the same time, the peak-period restriction is weekdays from 14:00 to 18:00, about 4 hours per day. For businesses that can schedule batch tasks to off-peak periods, subscription utilization will be higher. For online businesses with concentrated peak traffic that cannot be shifted, overage cost and rate-limiting risk should be evaluated carefully.

    5. Engineering Optimization and Decision Checklist

    The following checklist is recommended:

    1. Collect monthly total tokens, cache hit rate, and input/output ratios, and split them by business line.
    2. Use the cost formula to build sensitivity tables for multiple hit rates such as 90%, 95%, and 98%.
    3. When comparing pay-as-you-go plans with subscription plans, include peak-period share, overage probability, and quota utilization.
    4. Sample high-cost long-tail requests separately to check for issues such as unstable prefixes and repeated context concatenation.
    5. After launch, continuously monitor hit rate, effective unit price, subscription balance, and overage alerts.

    Illustrative pseudocode is as follows:

    1. def estimate_cost(total_million_tokens, cache_ratio, input_ratio, output_ratio,
    2. cache_price, input_price, output_price):
    3. cache_tokens = total_million_tokens * cache_ratio
    4. input_tokens = total_million_tokens * input_ratio
    5. output_tokens = total_million_tokens * output_ratio
    6. return (cache_tokens * cache_price +
    7. input_tokens * input_price +
    8. output_tokens * output_price)
    9. # Pass measured ratios and unit-price parameters for each business line,
    10. # then scan cache_ratio at levels such as 0.90, 0.95, and 0.98,
    11. # and output a sensitivity table instead of calculating only one total cost.

    6. Conclusion

    Cache unit price is only one parameter in the cost model. Real cost equals the price table multiplied by the business workload profile: the higher the hit rate, the greater the weight of cache price; the lower the hit rate, the more important input and output prices and subscription overage costs become. For subscription plans, the effective unit price should be calculated based on quota, peak periods, utilization, and overage probability. Teams should turn the cost model into a recalculable spreadsheet or script and update it continuously by business line, rather than making decisions based on a single price quote.