LLM Cache Billing and Subscription Plan Cost Analysis
This article explores how to accurately calculate the real cost of Large Language Model (LLM) services by analyzing cache hit rates, uncached input/output token pricing, and subscription plan economics. It provides a mathematical cost model, break-even analysis, and actionable strategies for optimizing LLM API expenses across different usage scenarios.
1. Why the “List Price” Doesn’t Equal the “True Cost”
Bills for LLM services are typically composed of multiple types of tokens: cache hit tokens, uncached input tokens, and output tokens. Many technical teams focus solely on the cache unit price during vendor selection, ignoring how costs can rapidly amplify from uncached input and output tokens when the cache hit rate drops. This is especially true in scenarios with high context repetition, such as long-context processing, multi-turn dialogue, code completion, and document Q&A, where the cache hit rate directly dictates the unit task cost. Therefore, true cost analysis cannot stop at “price per million tokens.” Instead, it requires building a reproducible cost model: first, profile the token structure of your business workload; second, apply different pricing schemes; and finally, conduct hit rate sensitivity analysis and peak/off-peak weighting.
The following values are hypothetical examples used to illustrate the calculation method and do not represent any specific service commitment. In this example, Plan A has a cache price of 0.115 CNY/million tokens, and Plan B has a cache price of 0.05 CNY/million tokens. With a 98% cache hit rate, 1.5% uncached input, and 0.5% output, the estimated cost per 100 million tokens is approximately 12.57 CNY and 9.40 CNY, respectively. If the cache hit rate drops to 95%, the estimated costs become roughly 14.92 CNY and 18.25 CNY. As demonstrated, the plan with the lower cache price has a clear advantage at high hit rates. However, when the hit rate drops and the proportion of uncached tokens rises, the unit prices for uncached input and output become the dominant factors, potentially reversing the cost ranking.
2. Building a Reproducible Cost Model
Let T be the total token volume (in millions of tokens), h be the cache hit rate, a be the proportion of uncached input, and b be the proportion of output among uncached tokens (where a + b = 1). Let the cache unit price be p_c, the uncached input price be p_i, and the output price be p_o, all in CNY/million tokens. The total cost C can be expressed as:
C = T × [ h × p_c + (1-h) × (a × p_i + b × p_o) ]
When the total token volume is 100 million, T = 100. If the cache hit rate is 98%, and 1.5% of the total tokens are uncached input while 0.5% are uncached output, the uncached portion totals 2%. Within this uncached portion, input accounts for 1.5/2 = 75%, and output accounts for 0.5/2 = 25%. Thus, a = 0.75 and b = 0.25. Substituting these into the formula yields the cost per 100 million tokens. If the cache hit rate changes to 95% while maintaining the same uncached structure, the uncached input share becomes 3.75% and output becomes 1.25%. In real-world applications, actual monitoring data should replace these assumptions.
The key to this model is that the cache unit price only affects the ‘h’ portion, while the uncached input and output prices affect the ‘(1-h)’ portion. In high hit-rate scenarios, the cache unit price carries more weight; in low hit-rate scenarios, the uncached unit prices carry more weight. Therefore, when comparing different plans, you cannot just look at the cache price—you must simultaneously collect p_c, p_i, p_o, and your business’s hit rate distribution.
3. Hit Rate Sensitivity: The Cost Crossover Point
By subtracting the cost of two plans, we obtain the cost difference function:
ΔC = T × { h × (p_cA - p_cB) + (1-h) × [a × (p_iA - p_iB) + b × (p_oA - p_oB)] }
Setting ΔC = 0 allows us to solve for the break-even hit rate, h. When the actual hit rate is higher than h, the plan with the lower cache price is more cost-effective; when it is lower than h*, the plan with better uncached pricing may take the lead. In the previous example, Plan B was cheaper at a 98% hit rate, but Plan A was cheaper at 95%, indicating the crossover point lies between them. Development teams should analyze hit rate distributions over the past 30 to 90 days rather than relying solely on averages. If hit rate fluctuations are significant, calculate based on P50 and P90 percentiles to prevent averages from masking high-cost long-tail requests.
4. Subscription Plan Conversion and Break-Even Analysis
The evaluation logic for subscription plans differs from pay-as-you-go billing. Assume a basic tier costs 118 CNY/month, a professional tier 538 CNY/month, and a flagship tier 1078 CNY/month. Under hypothetical off-peak quotas, the available weekly tokens are approximately 317 million, 1.9 billion, and 4.433 billion, respectively. Converted at the example unit prices, their equivalent pay-as-you-go original prices would be about 160 CNY, 955 CNY, and 2229 CNY, meaning the subscription unit price is roughly 50% to 70% of the pay-as-you-go API. However, this doesn’t mean all teams receive the same discount, as the plan’s value depends on quota utilization, peak-time proportion, and business stability.
The equivalent subscription discount can be written as: d = F / (Q_p × c_api), where F is the plan fee, Q_p is the available token volume covered by the plan, and c_api is the comprehensive pay-as-you-go unit price. If d < 1, fully utilizing the quota makes the subscription cheaper. If actual usage is only Q_u (where Q_u < Q_p), the actual effective cost becomes F / Q_u, worsening the discount. The simple condition for a subscription to be worthwhile is: the projected pay-as-you-go cost Q_u × c_api must be greater than the plan fee F. If usage exceeds the quota, overage pay-as-you-go costs must be added. The total cost then becomes F + (Q - Q_p) × c_api, which should be compared against the pure pay-as-you-go cost Q × c_api.
5. Peak/Off-Peak Periods and Workload Matching
Subscription plans usually distinguish between peak and off-peak hours. In the example, peak hours are Monday to Friday, 14:00 to 18:00, totaling 4 hours per day. Developers need to evaluate the time distribution of their business requests. If large batches of processing, offline indexing, or test generation can be shifted to off-peak times, the value of the plan’s off-peak quota increases. If online business peaks heavily overlap with the plan’s peak hours, you may encounter rate limiting, queuing, or increased latency, offsetting cost advantages with degraded user experience. It is recommended to track hourly request volumes, token consumption, and P95 latency to calculate the peak-time token proportion. For deferrable tasks, implement queuing and scheduling strategies to move non-urgent jobs to off-peak times. For online tasks, retain pay-as-you-go billing or a higher-tier plan as an elastic buffer.
6. Monitoring Metrics and Optimization Checklist
To continuously control costs, establish the following monitoring metrics: cache hit rate, uncached input/output ratio, average tokens per request, cost per 10,000 requests, peak-time request proportion, quota burn rate, and variance between estimated and actual bills. Optimization directions include stabilizing prompt prefixes and system instructions to improve cache reuse; reducing repetitive context and invalid historical messages; compressing output length and limiting maximum output tokens; segmenting and summarizing long documents for Q&A; batching deferrable tasks to off-peak times; and tiering model selection based on task complexity. It is important to emphasize that improving the cache hit rate is usually more effective than simply switching to a lower-priced plan, as it simultaneously reduces the weighted cost on both the cached and uncached sides.
7. Pseudocode Example: Cost and Break-Even Calculation
function cost(totalMillionTokens, hitRate, cachePrice, inputPrice, outputPrice, missInputShare):missShare = 1 - hitRatemissOutputShare = 1 - missInputSharereturn totalMillionTokens * (hitRate * cachePrice +missShare * (missInputShare * inputPrice + missOutputShare * outputPrice))function breakEvenHitRate(cacheA, inputA, outputA, cacheB, inputB, outputB, missInputShare):low = 0, high = 1repeat 60 times:mid = (low + high) / 2diff = mid * (cacheA - cacheB) +(1 - mid) * (missInputShare * (inputA - inputB) +(1 - missInputShare) * (outputA - outputB))if diff > 0: high = mid else low = midreturn (low + high) / 2
When using this, substitute the hit rate, uncached input proportion, and input/output unit prices derived from your business monitoring. If peak/off-peak weighting is needed, calculate the comprehensive unit price as “(peak token ratio × peak unit price) + (off-peak token ratio × off-peak unit price)” and plug it into the cost function. The final decision should weigh cost, latency, throughput stability, and quota wastage risk simultaneously, rather than comparing a single cache unit price.
