LLM Inference Cost Calculation and Plan Selection: A Practical Guide
Comparing per-million-token prices is the most common way to evaluate LLM inference services, but it often leads to the wrong conclusion. Real cost is a multi-variable function of cache hit rate, input-to-output ratio, and peak-hour traffic. This article breaks down those variables, walks through a quantitative example showing how a critical cache hit rate can reverse the ranking of two plans, explains how to convert subscription plans into equivalent API credit, and provides a decision checklist for choosing between pay-as-you-go and subscription options.
1. Why Comparing Unit Prices Almost Always Leads to the Wrong Conclusion
When evaluating LLM inference services, the most common approach is to place the “price per million tokens” of two options side by side and pick the lower one. The flaw in this method is that it treats the billing model as a single-variable function, when the real billing model is at least a three-variable function: cache hit rate, the ratio of input to output, and the time window in which requests occur.
The same service can cost several times more or less under different workload characteristics. So the right starting point for cost evaluation is not the price sheet, but a clear characterization of your own business workload.
2. Three Categories of Variables in the Cost Model
1. Tiered Pricing Driven by Cache Hits
Mainstream inference services generally offer context caching: when a request prefix matches previous content, those tokens are billed at a significantly lower price. This splits the input side into two segments:
Input cost = Cached tokens × Cache price + Uncached tokens × Standard input priceTotal cost = Input cost + Output tokens × Output price
The key point is that although the cache price is low, its ratio to the standard input price is not consistent across services. This leads to a counterintuitive conclusion: a service with a lower cache price is not necessarily cheaper in high-hit-rate scenarios.
2. Input-to-Output Ratio
Conversational applications have a high output share, while code completion and document understanding applications have an extremely high input share. When the input share exceeds 98%, small differences in input unit prices get amplified into the main difference on the bill. Conversely, in long-text generation scenarios, the output price is the dominant factor.
3. Peak Hours and Rate-Limit Windows
Some services apply different policies during “peak hours,” which may mean a price surcharge or a reduced quota. When evaluating, you must intersect your business traffic distribution with the peak windows rather than assuming uniform calls throughout the day.
3. A Quantitative Example: The Dividing Line Between High and Medium Hit Rates
Suppose that out of every 100 million tokens, 98% are cache hits, 1.5% are uncached input, and 0.5% is output, and that Plan A’s cache price is about twice that of Plan B. Plugging into the tiered formula gives roughly 12.6 yuan for A and 9.4 yuan for B, so B is better.
If the hit rate drops to 95%, the same formula gives about 14.9 yuan for A and 18.3 yuan for B, and the conclusion completely reverses.
These numbers show that there is a critical hit rate: above it, you should choose the service with the higher cache price but cheaper standard input; below it, the opposite holds. In engineering practice, you should measure your own business hit rate and solve for the critical point using the formula, rather than citing someone else’s conclusion.
4. How to Convert Subscription Plans
The cost-effectiveness of a monthly subscription plan should not be judged by “monthly fee ÷ however much I feel I can use,” but should be converted into equivalent pay-as-you-go API credit:
Equivalent credit = Token quota in the plan × Corresponding billing priceDiscount rate = Monthly fee / Equivalent credit
Based on common plan tiers (about 118, 538, and 1078 yuan per month) and quota estimates at a 98% hit rate, the discount rate falls roughly in the 50%–70% range. This means the value of a plan depends heavily on “whether the quota is actually used up”: if it is not fully used, the effective unit price quickly becomes worse than pay-as-you-go.
5. Decision Checklist
- First, sample real traffic to measure the cache hit rate, input-to-output ratio, and peak/valley distribution.
- Build a tiered pricing table and plug in two or three candidate options to solve for the critical hit rate.
- Intersect the peak windows with your business peaks to estimate the proportion of calls that will be rate-limited or surcharged.
- Consider a subscription plan only when step 3 shows stable high utilization, and keep pay-as-you-go as a fallback.
- After launch, continuously monitor the token consumption structure and re-run the calculation when the hit rate drifts.
6. Implementation Notes on Baidu AI Cloud
The method above does not depend on any specific vendor. If you use Baidu AI Cloud’s LLM services, you can collect call volume and token structure through monitoring alerts and log services, archive sampled data with object storage, and then re-calculate costs offline using the formulas in this article to form an auditable cost baseline, keeping procurement decisions from staying at the unit-price level.
