Why LLM API Bills Can Differ by 2x at the Same Token Price
Identical per-million-token prices across cloud platforms do not guarantee identical bills. This article explains why two teams with similar workloads can end up paying nearly twice as much, and shows how to model the real cost as unit price multiplied by usage structure multiplied by billing rules. It breaks down pay-as-you-go, batch discounts, prompt caching, subscriptions, and off-peak pricing, then offers a four-step routing decision path, common mistakes to avoid, and practical guidance for applying the model on Baidu AI Cloud.
1. The Problem: Same Unit Price, Double the Bill
In real model-service procurement, developers often run into a counterintuitive situation. Put the price lists of several major cloud platforms side by side, and the per-million-token input price, cache-hit price, and output price for the same model tier are identical. Yet at month-end settlement, two teams with comparable workloads receive bills that differ by nearly 2x.
The reason is not mysterious. The pay-as-you-go unit price is only one coefficient in the cost formula, while the bill is the product of “coefficient × usage structure × billing rules.” Once the coefficients are leveled, the difference can only come from the last two factors: usage structure (real-time vs. offline, prefix repetition rate, peak/off-peak distribution) and the billing rules each platform layers on top of the standard unit price (batch discounts, caching policies, subscription plans and off-peak discounts, free quotas for new users).
So the right way to choose a platform is not to compare prices horizontally. Build a profile of your own usage first, then plug each platform’s rules into the same cost model and calculate.
2. The Cost Model: Writing the Bill as a Computable Formula
Let the input tokens of a single call be $I$, the output tokens be $O$, the cache hit rate be $h$, the standard input unit price be $p_i$, the cache-hit unit price be $p_c$, and the output unit price be $p_o$. The expected cost per call can be written as:
cost_per_call = I * (h * p_c + (1 - h) * p_i) + O * p_o
The monthly bill is the sum across task types:
monthly = Σ (calls_k * cost_per_call_k * discount_k) - free_quota
Here discount_k is the discount factor introduced by platform rules. Batch tasks are usually priced at a discount off the standard rate (commonly around 60% in the industry; check each platform’s current published terms for specifics). A subscription plan is “a fixed monthly fee that covers part of the quota, plus pay-as-you-go for anything beyond it.” Off-peak discounts push the unit price for specific time windows even lower.
This formula tells us three things. First, the cache hit rate affects the bill linearly, and the savings are largest in high-hit-rate scenarios. Second, output tokens usually cost several times more than input tokens, so controlling output length is often more effective than compressing prompts. Third, the discount factor applies only to specific task types; using it in the wrong scenario means giving up the discount.
3. Four Rule Categories, Broken Down One by One
3.1 Pay-as-you-go: Comparable, but No Room to Optimize
When unit prices are identical across vendors, this item only provides predictability, not optimization room. Its value is as a baseline for measuring how much the other rules actually save.
3.2 Batch: A Deterministic Discount for Offline Tasks
The batch API trades higher latency for a lower price. It fits scenarios that do not require second-level responses, such as log summarization, bulk labeling, offline evaluation, and data cleaning. The engineering essentials are that tasks can be split, retried, and written back idempotently; pairing it with a message queue helps smooth out spikes and re-deliver failed jobs.
3.3 Caching: Automatic Gains from Repeated Prefixes
Mainstream implementations automatically enable caching for repeated prefixes and set a relatively short default time-to-live. Two things need attention: writing to the cache may be billed separately, and once the TTL expires the content must be written again. So placing stable content such as system prompts, tool definitions, and long documents at the front and keeping it byte-for-byte identical will noticeably raise the hit rate. Conversely, inserting a timestamp or random ID at the head of the prompt will make the cache fail completely.
# Bad example: volatile content first, so the prefix differs every time and the cache never hitsprompt_bad = f"Current time {now()}, request ID {uuid4()}\n" + STABLE_SYSTEM# Good example: stable content first, volatile content lastprompt_good = STABLE_SYSTEM + f"\nUser question: {question}"
3.4 Subscriptions and Off-Peak: Trading Deferability for Price
The core logic of a subscription is packaging “predictable baseline load” for sale, with anything beyond it reverting to pay-as-you-go. It suits real-time workloads with stable call volume and a locked model version. Off-peak discounts suit offline workloads that can be scheduled into overnight troughs. Stacking the two lowers the bill significantly more than price comparison alone.
4. Decision Path: Four Steps to a Plan
- Is a delayed response acceptable? If yes, prioritize batch for those tasks and route the rest to real-time.
- Can the model version be locked? Once locked, evaluate the combined cost of a subscription plan plus pay-as-you-go overage.
- Is the prefix repetition rate above 30%? If so, restructure the prompt to put stable content first and reuse it.
- Do you already run workloads on a cloud? Integrating within the same cloud environment avoids cross-network transfer and operations costs, at the same price as the vendor’s standard rate.
Sample implementation:
def route(task):if task.deadline_seconds >= 3600:return "batch" # Offline: batch discountif task.model_locked and task.qps_stable:return "subscription" # Real-time baseline: subscription + pay-as-you-go overagereturn "on_demand" # Fallback: standard pay-as-you-go
5. Common Mistakes
- Comparing unit prices only: ignoring the discount factor means voluntarily giving up 30% to 50% of potential savings.
- Assembling prompts carelessly: putting timestamps or session IDs first drives the cache hit rate to zero.
- Watching input but not output: the output unit price is usually several times the input price, so capping max output length pays off directly.
- Overlooking model retirement: older model versions stop opening to new users and are gradually phased out. Official guidance generally recommends migrating to the newer general-purpose version, so the model identifier should be a configuration item rather than hard-coded.
- Ignoring free quotas: newly launched models often come with a one-time complimentary quota, which is well suited for load testing and canary rollouts.
6. Applying This on Baidu AI Cloud
The large-model service platform on Baidu AI Cloud also offers common capabilities such as pay-as-you-go, batch, and caching, so the model above can be applied directly: first collect input/output length distributions and the cache hit rate from one week of real traffic, then plug them into the cost formula for an A/B calculation. Consolidate the model identifier, timeouts, retries, and routing policy into a unified gateway layer, and use logging services plus monitoring and alerting for usage attribution. Only then can you continuously verify whether the bill has actually gone down.
