Why LLM API Bills Can Differ by 50% at the Same Token Price

    This article explains why two cloud platforms with identical per-million-token pricing can still produce bills that differ by roughly half. It breaks down the token-based cost formula, shows how input/output ratios, cache hit rates, discounts, and time-of-use distribution drive actual spend, and outlines three engineering paths: keeping on-demand routing portable, sending deferrable work through batch channels, and using subscriptions with off-peak scheduling for stable real-time loads. It also covers cache hit-rate tuning, cost observability, and a practical action checklist for cutting monthly bills without changing business outcomes.

    1. Where the Problem Starts: Same Unit Price, Different Bills

    A counterintuitive pattern often shows up during multi-platform evaluations. Put the price sheets for the same LLM side by side across cloud platforms, and the input price, cache hit price, and output price per million tokens are identical. Pull the end-of-month bills, however, and for the same call volume, one platform can cost roughly half of the other.

    This shows that the per-unit price is only one coefficient in the cost formula, not the cost itself. What actually determines spend is the combination of billing rules and call patterns: whether the task can be deferred, whether request prefixes repeat, whether the workload is stable over the long term, and whether existing cloud resources are already in place. Fix these variables and identical unit prices are the expected result. Let them vary and diverging bills are equally expected.

    This article does not cover any specific vendor or product. It only discusses the billing dimensions and optimization methods common across the industry, and provides a cost governance framework that can be applied directly in engineering.

    2. Write the Cost Formula First

    For any token-billed service, the cost of a single request can be abstracted as:

    1. cost per request = input tokens × input price
    2. + cache hit tokens × cache hit price
    3. + cache write tokens × cache write price
    4. + output tokens × output price
    5. monthly bill = Σ(cost per request) × (1 - discount) + fixed subscription fee + overage at on-demand rates

    The formula shows four levers that can move the bill:

    1. The input-to-output ratio. Output prices are usually significantly higher than input prices, so scenarios with a high output share are naturally more expensive.
    2. The cache hit rate. Cached portions are billed at a lower price, and the more repeated prefixes, the more visible the savings.
    3. The discount factor. Batch offline channels and subscription plans are two common sources of discounts.
    4. Time distribution. Some platforms offer lower rates for off-peak resources, so whether the load can be shifted directly affects the discount.

    3. What Four Platforms at the Same Price Actually Means

    The conclusion of the original comparison can be abstracted into one general judgment: when upstream model prices are set uniformly by the model vendor and cloud platforms only resell them, convergence of on-demand unit prices is the norm. In that case, the choice of platform should not be based on unit price, but on three rules.

    • Batch channel discounts: some platforms bill asynchronous batch jobs at a percentage of the standard price, which suits deferrable workloads such as offline data processing, batch summarization, and log labeling.
    • Free quotas for new users: some platforms offer a certain amount of free tokens for new models, which suits load testing and prototype validation but does not constitute a long-term cost advantage.
    • Subscription and off-peak rules: some platforms offer package plans covering specific models, trading a fixed monthly fee for a lower unit cost, and may add a further discount for nighttime hours, with overage reverting to on-demand rates.

    One caveat: cache writes may be billed separately, and the default time-to-live is short. If the business prefix is unstable or the concatenation order changes frequently, the cache will almost never hit and will only add write overhead.

    4. Engineering the Three Optimization Paths

    Path 1: On-Demand First, Stay Portable

    For model capabilities that are not locked in, on-demand payment is the safest choice. In engineering terms, calls should be wrapped behind a unified gateway, with configuration deciding the actual route, so that model identifiers are not scattered across business code.

    1. # Example: unified gateway with configuration-driven routing
    2. ROUTES = {
    3. "chat": {"provider": "cloud_a", "model": "general-pro", "mode": "on_demand"},
    4. "embed": {"provider": "cloud_b", "model": "embedding-v3", "mode": "on_demand"},
    5. }
    6. def call(task_type, messages, **kw):
    7. r = ROUTES[task_type]
    8. return gateway.invoke(r["provider"], r["model"], messages, **kw)

    Path 2: Send Offline Jobs Through the Batch Channel

    The test is simple: can the result tolerate latency from minutes to hours? Anything that can be deferred should be turned into an asynchronous task, posted to a message queue, and submitted in batches by the consumer to get the discounted price.

    1. def classify(req):
    2. if req.max_latency_ms is None or req.max_latency_ms > 60_000:
    3. return "batch" # discounted channel
    4. return "realtime" # on-demand or subscription

    Path 3: Use Subscriptions Plus Off-Peak Scheduling for Stable Real-Time Loads

    When call volume is stable over the long term and the model is locked in, a subscription plan is usually cheaper than pure on-demand. The key is to schedule movable workloads into off-peak hours:

    1. nightly batch window after 18:00 → subscription plan + off-peak discount
    2. daytime interactive requests → covered by subscription, overage on-demand

    Example scheduling logic:

    1. def schedule(job, now_hour):
    2. if job.deferrable and now_hour >= 18:
    3. return run_offpeak(job) # off-peak discount
    4. return run_standard(job)

    5. Cache Hit Rate: The Most Overlooked Lever

    The way to raise the hit rate is a stable prefix: put the system prompt, tool definitions, and few-shot examples at the very front in a fixed order, and put the changing parts at the end. Also note that the default time-to-live is very short, so long gaps between calls will invalidate the cache. Before launch, add hit-rate instrumentation and track it per business line; links whose hit rate falls below expectations should be reworked first.

    6. Cost Observability: Measure Before Optimizing

    Without bucketing there is no optimization. At minimum, record these dimensions: business line, task type, real-time or batch, cache hit tokens, input and output tokens, price tier, and discount type. Example accounting script:

    1. def monthly(ts, in_tok, hit_tok, out_tok, price, discount):
    2. base = in_tok*price[0] + hit_tok*price[1] + out_tok*price[2]
    3. return base * (1 - discount)

    If an organization already uses general-purpose capabilities such as the container platform, message queue, logging service, and monitoring and alerting from Baidu AI Cloud, it can reuse those existing resources to host the gateway, asynchronous queue, and cost dashboard described above without building anything new.

    7. Conclusion and Action Checklist

    1. When unit prices are the same, do not use unit price as the selection criterion.
    2. Bucket the traffic first: deferrable work goes to the batch channel, stable work goes to a subscription, and the rest stays on-demand.
    3. Fix the prefix, and verify the cache hit rate with instrumentation.
    4. Build a cost dashboard per business line, and review discount coverage weekly.
    5. Keep routing configuration-driven to avoid being locked into a single billing rule.

    Following this approach can typically compress the monthly bill by 30% to 50% without changing business outcomes, and the optimization measures can migrate smoothly as platform rules change.