LLM Inference Cost Estimation and Plan Selection: A Practical Methodology

    This article explains how to compare LLM inference costs using a vendor-neutral model that accounts for input and output tokens, cache hits, peak/off-peak pricing, and subscription quota utilization. It covers cache-hit sensitivity, time-weighted pricing, effective plan discounts, a reusable cost calculator, and engineering practices for monitoring and controlling inference spend.

    When evaluating LLM services, the most common mistake is treating the list price as the real unit price. Actual bills are typically driven by a combination of factors: input tokens, output tokens, discounted input from cache hits, time-weighted peak/off-peak pricing, and quota loss within subscription plans. To compare different billing models on the same basis, you first need a vendor-neutral unit-cost model and then apply your traffic shape, rather than comparing a promotional number directly.

    The discussion below does not target any specific product. All prices are illustrative only; formal decisions should rely on billing-console invoices, contract discounts, and real logs.

    1. First, break cost into calculable variables

    The cost of a request can be approximated as:

    Total cost = uncached input tokens × input unit price + cached input tokens × cache unit price + output tokens × output unit price.

    A more useful comparison metric is the effective input unit price. Let total input be I, total output be O, cache hit rate be h, input unit price be Pin, cache input unit price be Pcache, and output unit price be Pout. The blended cost per token C is:

    C = [I × ((1-h) × Pin + h × Pcache) + O × Pout] ÷ (I + O)

    This formula reveals two key conclusions. First, the higher the cache hit rate, the more valuable it is for long contexts, repeated prefixes, retrieval augmentation, and fixed system prompts. Second, the higher the output share, the more the model’s bargaining room is constrained by output pricing. Many teams focus only on input price, but in code generation, summarization and rewriting, and batch extraction, output tokens may account for 30–50% of usage. The final bill can therefore deviate completely from expectations.

    2. Cache hit rate is the inflection point of the cost curve

    Cache mechanisms suit three types of traffic: fixed system prompts, reused knowledge snippets, and stable historical prefixes in multi-turn conversations. If the workload is short Q&A, highly random prompts, or frequently changed templates, cache hits will drop quickly, and a low cache price is meaningless.

    Use sensitivity analysis instead of a gut feeling. For example, suppose Service A has a higher input price but a very low cache price, while Service B has a lower input price but a slightly higher cache price. When the hit rate falls from 98% to 95% and then to 90%, their relative advantage may flip. The reason is that a one-percentage-point drop in hit rate does not merely reduce savings by 1%; it moves tokens that were billed at the cache price back to the regular input price, and the marginal cost is amplified by the price gap.

    In engineering practice, treat hit rate as a monitoring metric, not a one-time assumption before launch. At minimum, record prompt template version, context length, cacheable prefix length, actual cached tokens, uncached tokens, and output tokens. Without these logs, any cost comparison is just static arithmetic.

    3. Convert peak/off-peak prices into time-weighted unit prices

    Many services offer off-peak discounts or peak surcharges. If the low-price window lasts only a few hours per day and the business peak falls during working hours, the impact of cheap off-peak pricing on total cost is limited. The correct approach is to count tokens by time window, not to average over a calendar day.

    Define the time-weighted unit price as:

    P_eff = Σ(T_t × P_t) ÷ ΣT_t

    where T_t is the tokens consumed in time window t and P_t is the unit price in that window. If enterprise load is concentrated during daytime office hours, move batch processing, evaluation replays, offline cleaning, and large-text preprocessing before document vectorization to low-price windows where possible. For online interactive traffic, reduce peak exposure through queue-based peak shaving, response length limits, and context trimming.

    Also note differences in peak definitions: some are segmented across the whole day, some cover only a few hours on workdays, and some meter concurrency rather than tokens. When comparing, normalize them into two ratios: the share of tokens that can be consumed at low price each week, and the share of peak load that cannot be migrated. Otherwise, operational flexibility can be mistaken for a price advantage.

    4. For subscription plans, look at effective quota, not nominal quota

    Subscription or resource packs commonly come in three tiers: lightweight, advanced, and team. The nominal price may look lower than pay-as-you-go, but the real discount rate depends on key parameters: included token volume, whether rate limits apply during peak periods, how overage is billed, and whether unused quota rolls over.

    The equivalent plan cost ratio can be estimated as:

    Equivalent plan cost ratio = monthly plan fee ÷ amount payable for the same tokens at list price

    If the list-price equivalent amount is 1,000 and the plan price is 600, the apparent cost ratio is 60%. But if the team can use only 70% of the quota’s list-price equivalent outside peak hours, the real cost ratio becomes 600 ÷ 700 ≈ 85.7%. Conversely, if the plan triggers rate limiting and forces fallback to higher-priced pay-as-you-go usage, the result can be “cheaper on paper, more expensive overall.”

    Therefore, subscription plans suit teams with stable usage, predictable peaks, and high context reuse. Exploration phases, campaign periods, and burst batch jobs are better served by pay-as-you-go plus budget alerts. A hybrid model is often more robust: base traffic on a plan, burst traffic on pay-as-you-go, and offline jobs queued for low-price windows.

    5. Build a recalculable estimator in code

    Turn the comparison logic into an internal tool. Input prices, hit rates, peak/off-peak distribution, and monthly token curves; output a budget range. An illustrative example:

    1. def blended_cost(tokens_in, tokens_out, hit_rate,
    2. p_in, p_cache, p_out):
    3. cached = tokens_in * hit_rate
    4. uncached = tokens_in - cached
    5. return uncached * p_in + cached * p_cache + tokens_out * p_out
    6. def monthly_estimate(profile, price_plan):
    7. total = 0
    8. for seg in profile:
    9. rate = seg["hit_rate"]
    10. p = price_plan[seg["window"]] # peak / offpeak
    11. total += blended_cost(seg["in"], seg["out"], rate,
    12. p["in"], p["cache"], p["out"])
    13. return total

    Further add Monte Carlo perturbation: let hit rate, output length, and daily peak concurrency fluctuate within reasonable ranges to obtain P50, P90, and P95 bills instead of a single-point result. This answers the questions management cares about most: how far the worst case may exceed budget, and whether a circuit breaker is needed when cache hit rate collapses or prompts bloat.

    6. Five engineering recommendations for implementation

    First, measure before optimizing. Connect a unified logging service and monitoring/alerting, and break down model calls by business line, template, user, and time window, so you do not see only a total at month-end. Second, control context bloat. Set length budgets for system prompts, retrieved snippets, and tool returns; use summary compression for long sessions instead of unlimited concatenation. Third, limit useless output. For classification, extraction, and scoring tasks, enforce structured short outputs; for generation tasks, set maximum output and stop conditions. Fourth, design for cache friendliness. Put stable prefixes at the front of the input and variable content later; when a template version changes, evaluate hit-rate regression. Fifth, set cost circuit breakers. When unit request cost, daily spend, or peak share exceeds a threshold, automatically degrade to a smaller context, shorter output, or asynchronous batch processing.

    If deployed in a general cloud environment such as Baidu AI Cloud, you can combine logging, monitoring and alerting, message queues, and container platforms for usage collection, peak shaving, and elastic scaling. The core, however, remains the billing model above, not reliance on a proprietary interface.

    Conclusion

    The essence of LLM selection is not finding the lowest unit price, but matching the price structure to the business structure. High cache hit rates, stable load, and migratable offline tasks fit committed plans and low-price windows. Online businesses with high randomness, high output, and strong peaks should be cautious about cache assumptions and nominal discounts. Put hit rate, output share, peak/off-peak distribution, and quota utilization into the same table, and cost debates turn from emotional judgment into an engineering problem.