LLM API Billing: Why Bills Diverge Even When Unit Prices Match

    LLM API pricing is usually quoted per token across three dimensions—input, cached input (cache hits), and output—so teams comparing vendors often find nearly identical unit prices. Yet after a month of real traffic, bills can differ sharply, sometimes close to 2x. This article explains that the gap rarely comes from the headline price and almost always comes from the billing rules around it: cache hits and cache writes, batch inference discounts, subscription or resource-pack plans, off-peak discounts, free quotas, and model deprecation. It walks through each rule, shows how to fold them into a single cost-estimation function with a worked Python example, offers a vendor-selection framework, lists common costing mistakes, and closes with an FAQ and a practical checklist for usage monitoring and budget control.

    1. Where the Problem Starts: Matching Unit Prices, Different Bills

    Many teams run into the same situation during vendor selection: comparing the LLM APIs of several cloud providers, they find the pay-as-you-go unit prices are very close, sometimes identical across all three dimensions—input, cache hit, and output. But after running for a month, the bills can diverge noticeably, sometimes by nearly 2x.

    The problem is usually not the unit price itself, but the billing rules that sit around it. LLM APIs are generally metered per token, with a common unit of “per million tokens,” split into three base dimensions:

    • Input tokens: the prompts or context the user sends;
    • Output tokens: the content the model generates, usually priced higher than input;
    • Cached-input tokens (cache hits): repeated prefixes that hit the cache may be billed at a lower rate.

    For clarity, the table below gives illustrative prices used only to explain the billing structure.

    Disclaimer: The prices below are illustrative and do not constitute a quote. Cache time-to-live, batch discounts, subscription plans, and off-peak discount rules vary by vendor and model; always confirm actual billing against each vendor’s official documentation.

    Model tier Input Cache hit Output Rules that create the gap
    Flagship reasoning model 20 2 100 Batch inference may be discounted from the standard price
    Balanced reasoning model 13 1.3 68 New models may come with a free quota
    Lightweight coding model 6.5 1.3 27 Some platforms offer subscription plans

    Note: the unit is per million tokens; whether prices are tax-inclusive, whether the cache-hit price applies only to input, and whether output tokens are affected by batch discounts must all be confirmed against the vendor’s billing documentation.

    If you look only at the first three columns, the differences between platforms may be small. What actually opens up the bill gap is the fourth column—rules that don’t show up directly in the unit-price numbers.

    2. Five Key Rules That Open Up the Gap

    Cache Hits: The Savings Switch for Repeated Prefixes

    LLM inference typically supports prefix caching. When multiple requests share the same system prompt, a long document, or fixed context, the repeated portion may hit the cache and be billed at the lower “cache-hit price.”

    For scenarios with fixed system prompts, frequent multi-turn conversations, or stable knowledge-base prefixes, raising the cache hit rate can significantly reduce input cost. The optimization focus is:

    • keep the system-prompt prefix stable;
    • avoid inserting random variables into a long prefix;
    • keep high-frequency calls within the cache’s time-to-live;
    • monitor the balance point between cache hit rate and write cost.

    If the hit rate can rise from near zero to a high level, input-side cost usually drops noticeably, though the exact magnitude depends on the cache-hit price, the share of input tokens, and call frequency.

    Cache Writes: The Easily Overlooked Line Item

    Many teams focus only on “how much a hit saves” and overlook that writing to the cache may itself be billed separately. Some platforms price different cache durations differently—for example, a short-lived cache and a longer-lived cache carry different prices.

    If the call interval is longer than the cache’s time-to-live, you can end up repeatedly in a “write—expire—write again” cycle. In that case, cache write cost may offset or even exceed the savings from hits.

    When evaluating a cache strategy, don’t look at the hit rate alone; also estimate:

    • the number of tokens written to cache;
    • the cache write unit price;
    • the relationship between call interval and cache time-to-live;
    • the ratio of write frequency to hit frequency.

    For long-document scenarios, the cache payoff may be high; for scenarios with frequently changing prefixes or unstable call intervals, first verify that write cost is acceptable.

    Batch Inference: The Discount Channel for Offline Work

    For tasks that don’t require real-time responses—batch summarization, offline labeling, log analysis, data cleaning, evaluation-set generation, and so on—many platforms offer a batch inference channel. It typically returns with longer latency but may be priced below real-time calls.

    One point deserves special attention: the batch discount is not a flat, universal rate. A more accurate statement is:

    When the share of deferrable traffic is P and the batch discount coefficient is D, that traffic can theoretically cut cost by roughly (1 − D) × P. For example, a 60% batch discount on traffic that is 50% deferrable reduces the cost of that portion by about 40%—but the overall bill reduction still depends on how large the deferrable share is relative to total traffic.

    Batch discounts, submittable task types, return latency, and whether output tokens participate in the discount can all differ across platforms. So confirm the vendor’s documentation before adopting it in production.

    Subscription Plans and Off-Shoulder Discounts: Levers for Predictable Traffic

    When call volume is steady and predictable, pure pay-as-you-go may not be optimal. Some platforms offer subscription plans or resource packs: you pre-purchase a quota at a lower unit cost, and any overage is settled pay-as-you-go.

    Off-peak discounts apply to workloads whose execution time can be scheduled. Shifting non-urgent calls to low-traffic windows, such as overnight, may unlock an additional discount. But whether the overall bill drops depends on several conditions:

    • the share of calls that can shift to off-peak;
    • the size of the off-peak discount;
    • the call volume covered by the plan;
    • the unit price for overage beyond the plan;
    • the workload’s tolerance for latency and stability.

    So it’s not accurate to assume that “simply enabling a plan or overnight scheduling will sharply cut the bill.” A more reasonable judgment: only when the schedulable share is high, plan coverage is sufficient, and off-peak rules are stable can you expect a meaningful cost reduction.

    Free Quotas and Model Deprecation

    In the early stage after a new model launches, some vendors may offer a quota of free tokens, which suits initial validation, quality evaluation, and load testing. But free quotas usually have time limits, total caps, or model-scope restrictions and cannot be treated as a long-term cost reduction.

    At the same time, older model versions may gradually stop opening to new users and eventually be retired. During selection, leave a buffer for model-version migration and avoid tying your business deeply to a model that is about to be retired.

    3. A Practical Cost-Estimation Model

    Rather than picking a platform by feel, fold cache hits, cache writes, batch share, subscription credits, and off-peak discounts into a single estimation function. Here is a simplified example that makes it easy to compare options side by side.

    1. def estimate_monthly_cost(
    2. input_tokens=0, # total monthly input tokens
    3. output_tokens=0, # total monthly output tokens
    4. cache_hit_ratio=0.0, # cache hit ratio, range 0 to 1
    5. cache_write_ratio=0.0, # share of input tokens that require cache writes
    6. cache_write_price=0.0, # cache write price per million tokens
    7. price=(20, 2, 100), # (input, cache hit, output) per million tokens
    8. batch_ratio=0.0, # share of traffic sent through the batch discount
    9. batch_discount=0.6, # batch discount coefficient
    10. subscription_credit=0.0, # subscription credit to deduct
    11. offpeak_ratio=0.0, # share of traffic that can shift to off-peak
    12. offpeak_discount=0.5 # off-peak discount coefficient
    13. ):
    14. p_in, p_cache, p_out = price
    15. # split input tokens into cache-hit and non-hit parts
    16. hit_tokens = input_tokens * cache_hit_ratio
    17. miss_tokens = input_tokens * (1 - cache_hit_ratio)
    18. write_tokens = input_tokens * cache_write_ratio
    19. # base real-time cost, in currency units
    20. base_cost = (
    21. miss_tokens * p_in
    22. + hit_tokens * p_cache
    23. + output_tokens * p_out
    24. + write_tokens * cache_write_price
    25. ) / 1_000_000
    26. # batch inference cost
    27. batch_cost = base_cost * batch_ratio * batch_discount
    28. # the part not sent to batch can be further split into off-peak and peak
    29. remaining = base_cost * (1 - batch_ratio)
    30. offpeak_cost = remaining * offpeak_ratio * offpeak_discount
    31. peak_cost = remaining * (1 - offpeak_ratio)
    32. # subscription credit is deducted before the final cost
    33. total = batch_cost + offpeak_cost + peak_cost
    34. return max(total - subscription_credit, 0)
    35. cost = estimate_monthly_cost(
    36. input_tokens=500_000_000,
    37. output_tokens=50_000_000,
    38. cache_hit_ratio=0.4,
    39. cache_write_ratio=0.1,
    40. cache_write_price=5,
    41. batch_ratio=0.5,
    42. batch_discount=0.6,
    43. subscription_credit=1000,
    44. offpeak_ratio=0.3,
    45. offpeak_discount=0.5,
    46. )
    47. print(f"Estimated monthly cost: {cost:.2f}")

    This function is a simplified model: cache writes are priced directly by token count, the subscription credit is deducted before the final cost, and batch and off-peak discounts apply only to the discountable portion. If in a real platform output tokens don’t participate in the batch discount, or the plan is settled as a fixed resource pack, you’ll need to split the calculation according to the vendor’s rules.

    Worked Example

    Suppose monthly input is 500 million tokens, monthly output is 50 million tokens, cache hit rate is 40%, cache write ratio is 10%, write price is 5, and base prices are 20 for input, 2 for cache hit, and 100 for output. Under these parameters, the base real-time cost is about 11,650.

    If 50% of traffic goes through the batch channel with a 60% discount, the cost is about 9,320; then adding a shift of 30% of traffic to off-peak with a 50% off-peak discount brings it to about 8,446; and with a further 1,000 subscription credit, it lands around 7,446.

    This shows that bill differences often come not from a single unit price, but from the combined effect of cache, batch, subscription, and off-peak rules.

    4. A Vendor-Selection Decision Framework

    You can consolidate the rules above into a clearer selection path:

    • When you’re not tied to a specific model version: prioritize the stability and ecosystem of pay-as-you-go. Since leading platforms’ pay-as-you-go unit prices may be close, compare engineering experience, API compatibility, monitoring, and documentation quality instead.
    • Offline, latency-tolerant tasks: prioritize batch inference, but first confirm latency requirements, task scale, and discount rules.
    • Real-time calls with predictable traffic: evaluate subscription plans or resource packs, put the steady baseline into the plan, and let overage fall back to pay-as-you-go.
    • Teams with many schedulable tasks: consider concentrating non-urgent calls into off-peak windows, but confirm the business can tolerate the added latency.
    • Long-system-prompt, multi-turn scenarios: optimize prefix design to raise the cache hit rate, while monitoring cache write frequency to avoid repeated writes eroding the gains.
    • Teams running multiple models and scenarios: don’t look at a single model’s unit price alone; build a unified token-usage ledger and then run the estimation per scenario.

    5. Common Mistakes and Cautions

    In practice, the following mistakes most easily distort cost estimation:

    1. Looking only at input price, not output price
      Output tokens are usually more expensive; if your workload produces a lot of output, output cost may dominate.

    2. Ignoring cache write cost
      A cache hit is not zero cost; frequent writes can offset the gains from hits.

    3. Treating the batch discount as a universal discount
      Batch discounts usually apply only to some tasks and come with latency, task-type, and vendor-rule constraints.

    4. Overage on a plan actually raising cost
      Once the plan quota is used up, a high overage unit price can push the actual bill beyond expectations.

    5. Not assessing model deprecation risk
      If the business is tied to a model about to be retired, the later migration and regression-testing cost may be underestimated.

    6. Overlooking monitoring and alerting
      Without usage monitoring, budget caps, and bill alerts, it’s hard to spot abnormal calls in time.

    6. FAQ

    Why do bills differ when the LLM API unit price is the same?
    Because the bill is determined by more than unit price—it’s also affected by cache hits, cache writes, batch inference, subscription plans, off-peak discounts, free quotas, call structure, and the share of output tokens.

    How do I reduce cache cost?
    First keep the prefix stable to raise the hit rate; then monitor cache write frequency to avoid long call intervals that trigger repeated writes.

    Which tasks suit batch inference?
    Tasks that don’t require real-time responses, such as batch summarization, offline labeling, log analysis, data cleaning, and evaluation generation.

    How do I evaluate a subscription plan?
    Look at whether call volume is steady, the plan’s coverage ratio, the overage price, whether tasks are predictable, and whether the plan supports sharing across multiple models or applications.

    7. Practical Recommendations

    If you already run on a public cloud, connecting to the LLM platform from the same provider can often reduce network latency, ease data-compliance work, and lower operations overhead. For example, Baidu AI Cloud’s LLM platform offers standardized token metering and batch inference, and can be combined with common cloud services such as object storage, message queues, logging, and monitoring/alerting to close the loop from usage collection to cost control. Confirm availability and pricing in the relevant official documentation before you rely on any specific capability.

    An actionable checklist:

    • Metrics to monitor: input tokens, output tokens, cached-input (hit) tokens, cache-write tokens, number of batch tasks, remaining plan quota.
    • Bill alert thresholds: set daily, weekly, and monthly budget alerts, and notify promptly when spend grows abnormally.
    • Budget caps: set call limits for core applications to avoid waste from test traffic or abnormal retries.
    • Task scheduling strategy: route real-time tasks through the standard channel and deferrable tasks through the batch or off-peak channel.
    • Model version management: periodically review new models, free quotas, and old-model retirement dates, and reserve a migration window.
    • Cost review cadence: review at least monthly, plug actual usage back into the estimation model, and continuously recalibrate your projected cost.

    In short, with the same model and the same unit price, bill differences usually come from the combination of cache, batch, subscription, and off-peak rules. Quantifying these rules into a cost model and aligning task scheduling with budget monitoring is the key to controlling LLM API costs.