LLM API True Cost Calculation and Plan Selection Guide

    This article explains why simple per-token price comparisons can lead to the wrong conclusion when evaluating LLM APIs. It presents a reusable framework for modeling real costs across cache hits, input/output ratios, time-based pricing, and subscription quotas, then provides a practical checklist for choosing between pay-as-you-go and subscription plans.

    LLM API True Cost Calculation and Plan Selection Guide

    As large language model services move into everyday development and production environments, “which API is cheaper” has become a central question in technical selection. However, simply comparing unit prices on official price lists often leads to the wrong conclusion. LLM billing involves multiple variables: cache hits, input/output ratios, peak and off-peak pricing, and quota conversion for subscription plans. Only a reusable calculation framework can reveal the true cost structure. This article uses a typical cost comparison scenario to explain how to calculate the real cost of LLM APIs and how to make plan selection decisions.

    1. Why You Cannot Rely on the Price List Alone

    Many teams evaluate costs by directly comparing the “price per million tokens” from two providers. This approach has three clear pitfalls.

    First, cached pricing and regular pricing are two different dimensions. Mainstream inference services commonly use prompt caching: when the input prefix of a request heavily overlaps with previous requests, tokens that hit the cache are billed at a rate far below the regular price. This means the cache hit rate directly determines the effective unit price. A service with a cached price that is twice as high may not produce a higher final bill if its overall pricing structure is different.

    Second, input and output tokens usually have different prices. Generating output tokens generally costs more computationally than processing input tokens, so most providers charge a higher unit price for output tokens. Input/output ratios vary widely by application: long-document question answering has a very high input share, while code generation has a significantly higher output share. Using the wrong ratio will seriously distort the conclusion.

    Third, some providers use time-based pricing for peak and off-peak periods. Some offer discounts at night or during low-load periods, while others apply peak pricing only for a few hours on weekday afternoons. If a team’s usage pattern falls mainly in off-peak periods, the off-peak price is the meaningful baseline.

    2. Building a True Cost Formula

    Assume a business scenario where every 100 million tokens are consumed as follows: 98% cache hits, 1.5% uncached input, and 0.5% output. The general formula for true cost is:

    1. Total cost = cached tokens × cached unit price
    2. + uncached input tokens × input unit price
    3. + output tokens × output unit price

    Using a scenario with a 98% cache hit rate and a set of publicly listed prices, the calculation gives approximately CNY 12.6 per 100 million tokens for Plan A and approximately CNY 9.4 per 100 million tokens for Plan B. In this case, Plan B wins because of its lower cached unit price.

    But if the cache hit rate drops to 95%—which is not uncommon in real business scenarios, such as long conversation turns, frequently changing system prompts, or highly dispersed user questions—the share of uncached input rises from 1.5% to 4.5%, and the cost weight of regular-priced input increases significantly. For the same 100 million tokens, Plan A becomes approximately CNY 14.9, while Plan B becomes approximately CNY 18.3, completely reversing the conclusion.

    This comparison reveals a key pattern: differences in cached unit price dominate at very high hit rates, while differences in regular input pricing rapidly expand when the hit rate falls. Every few percentage points of decline in cache hit rate can tip the cost balance entirely.

    3. How to Determine Your Business’s Cache Hit Rate

    Before modeling costs, you must first understand the hit-rate range of your own business. The following steps are recommended:

    1. Sample real traffic. Extract request samples from logs over several consecutive days and calculate the share of cached tokens rather than relying on intuition.
    2. Separate business modules. Multi-turn dialogue, RAG retrieval augmentation, and Agent tool calls can have very different hit rates. Measure them separately and then aggregate with weighting.
    3. Perform sensitivity analysis. Treat the hit rate as a variable in the model and calculate costs at 98%, 95%, 90%, and even 80% to see where the conclusion flips. Selection is robust only when the conclusion remains consistent across all reasonable ranges.

    4. Converting Subscription Plans and Pay-as-You-Go Pricing

    In addition to pay-as-you-go billing, subscription plans for high-frequency users—especially in coding assistance and automation script scenarios—are also common options. The core of evaluating whether a plan is worthwhile is a quota conversion:

    1. Effective plan unit price = monthly plan fee ÷ included token quota
    2. Pay-as-you-go reference price = cost of the same token volume at regular API prices
    3. Discount rate = effective plan unit price ÷ pay-as-you-go reference price

    Take common tiered plans as an example: an entry tier at approximately CNY 118 per month corresponds to about 300 million tokens per week, equivalent to approximately CNY 160 in pay-as-you-go charges; a mid tier at approximately CNY 538 per month corresponds to about 1.9 billion tokens per week, equivalent to approximately CNY 955 in pay-as-you-go charges; and a high tier at approximately CNY 1,078 per month corresponds to about 4.4 billion tokens per week, equivalent to approximately CNY 2,229 in pay-as-you-go charges. Overall discount rates generally fall in the 50%–70% range of pay-as-you-go prices.

    However, there is an easily overlooked detail: plan quotas are often tied to time periods. Some plans provide their full quota only during off-peak periods, while the quota is reduced to a fraction during peak periods. Providers also define “peak” differently—some apply it for several evening hours, while others apply peak pricing only for about four hours on weekday afternoons, which is clearly less restrictive for developers. Therefore, when converting quotas, you must estimate the share of usage during peak periods based on your own usage time distribution and adjust the quota before making comparisons.

    5. Decision Checklist for Plan Selection

    Based on the analysis above, here is a practical decision checklist:

    1. Measure the hit rate before discussing price. When the hit rate is above 97%, focus on comparing cached unit prices; when it is below 95%, focus on comparing regular input unit prices.
    2. Model with real input/output ratios. Do not use default ratios. Code generation, summarization, and question answering can have very different output shares.
    3. Check time-based pricing windows. Confirm whether your traffic distribution overlaps with the provider’s peak windows.
    4. Convert plans into effective pay-as-you-go prices. Subscription plans truly save money only for teams whose usage can consistently consume the full quota; for teams with highly variable usage, pay-as-you-go is often more flexible.
    5. Preserve migration flexibility. Abstract a unified calling interface at the code level to avoid deep lock-in with a single provider and to make migration easier as pricing strategies change. Platforms such as Baidu AI Cloud that offer standardized model services are often compatible with common interface protocols and can serve as an alternative access point in a multi-cloud strategy.

    Conclusion

    The cost of LLM APIs is essentially a multi-variable optimization problem, not a simple price comparison. Cache hit rate, input/output structure, time-based pricing, and plan quotas jointly determine the final bill. With the calculation framework in this article, teams can plug their own business data into the formulas and reach cost conclusions that reflect their actual situation, rather than being misled by “cheaper” claims based on any single dimension.