LLM Inference Cost Calculation and Plan Selection: A Practical Guide
Why a lower per-token price does not always mean a lower bill, how to build a reusable cost model that accounts for cache hit rate, token mix, and peak-hour pricing, how to convert subscription plans into equivalent API credit, and a practical checklist for choosing between pay-as-you-go and subscription plans.
1. The Starting Problem: Why a Lower Unit Price Does Not Mean a Lower Bill
As large model applications move into large-scale production, inference cost has overtaken model quality as the metric most often questioned during architecture reviews. A typical debate looks like this: one platform charges roughly CNY 0.115 per million tokens for cache reads, while another charges about CNY 0.05 during off-peak hours, making the first one look more than twice as expensive. Drawing a conclusion from that comparison alone usually leads to a judgment that contradicts the actual bill.
The reason is that real spending is not determined by a single unit price but by four variables working together: the cache hit rate, the ratio of input to output tokens, the time distribution of requests, and the billing granularity and settlement cycle. Unit price is only one of the multipliers.
2. Building a Reusable Cost Model
Let T be the total token volume in a measurement period, h the cache hit ratio, i the share of input tokens that miss the cache, and o the share of output tokens, with h + i + o = 1. Let p_cache, p_in, and p_out be the unit prices for cache reads, uncached input, and output respectively. Then:
Cost = T * (h * p_cache + i * p_in + o * p_out)
Using 100 million tokens as the measurement unit and plugging in two typical parameter sets (98% cache hit, 1.5% input, 0.5% output) and (95% cache hit, with the remaining shares in the same proportion), two different conclusions emerge:
- High hit rate scenario (98%): the two sides cost roughly CNY 12.57 and CNY 9.40, so the side with the cheaper cache price wins.
- Medium hit rate scenario (95%): the two sides cost roughly CNY 14.92 and CNY 18.25, so the side with the more expensive cache price but the better overall structure is actually cheaper.
This reversal shows that the weight of the cache unit price is amplified or compressed by the hit rate. When the hit rate is extremely high, the bill is dominated almost entirely by the cache price. As the hit rate drops, uncached input and output prices start to take over the bill, and the relative relationship between the output price and the input price becomes the decisive factor. In engineering terms, “improving the hit rate” should be treated as an independent cost optimization workstream rather than a secondary metric.
3. Adding the Time Dimension: The Hidden Premium of Peak Hours
The second variable that is often overlooked is time. Some platforms apply higher rates during peak hours (for example, several consecutive hours on weekday afternoons) and offer discounts during off-peak hours. The length of the peak window directly determines the premium exposure: a narrow 4-hour daily window and a wide window covering the entire workday can differ by several times in their cost impact on the same workload.
The corrected model only needs a time weight:
Cost = Σ (T_k * rate_k), k ∈ {peak, off-peak}
where T_k is the token volume falling into the corresponding period. The practical recommendation is to systematically shift batch workloads (offline summarization, batch annotation, regression testing, log analysis) to off-peak hours through message queues and task scheduling, while keeping interactive traffic in peak hours, thereby reducing the average unit price without changing business logic.
4. How to Convert Subscription Plans
Subscription plans (monthly-billed coding assistant plans) cannot be measured by unit price and must be converted into “equivalent API credit.” The conversion steps are:
- Read the plan’s advertised weekly token allowance at a given hit rate;
- Multiply by 4.33 to get the monthly allowance;
- Multiply that allowance by the pay-as-you-go blended unit price to get the equivalent list price;
- Divide the plan price by the equivalent list price to get the discount factor.
Using this method, the equivalent list prices of the three tiers are roughly CNY 160, CNY 955, and CNY 2,229 per month, and the plan prices are about 50%–70% of the equivalent list price. A discount factor in that range means a subscription is essentially a purchasing model that “trades a usage commitment for a discount”: the closer usage gets to the allowance ceiling, the better the value; if usage is far below the allowance, you are effectively paying for idle capacity.
5. A Selection Checklist
- Measure before deciding: use real traffic sampling to measure
h,i,o, and the time distribution, rather than the hit rate advertised by the vendor; - Watch the output price: once the output share exceeds 1%, its impact on the bill quickly surpasses the difference in cache prices;
- Use the break-even point to judge plans: set
plan price = estimated monthly token volume * blended unit priceand solve for the critical usage level; below that value, choose pay-as-you-go; - Keep an elastic channel: reserve pay-as-you-go as a fallback for burst traffic so requests are not throttled after the plan allowance is exhausted;
- Build cost observability: use log services and monitoring alerts to break down token consumption by business line, model, and time period, producing a weekly cost report.
6. A General Approach to Running This on the Cloud
If you use the relevant capabilities of Baidu AI Cloud, you can combine object storage to hold samples and results, a message queue for peak shaving and time-based scheduling, a container platform to host the inference gateway, and log services plus monitoring alerts for usage attribution, turning the cost model from a one-off spreadsheet into a continuously running accounting pipeline. The core principle is that cost optimization must rest on an engineering foundation that is measurable, attributable, and rollback-capable; any unit price comparison detached from the real traffic distribution has no decision-making value.
