Same Unit Price, Different Bills: Breaking Down LLM API Monthly Cost Differences
LLM API price sheets can look identical, yet monthly bills can diverge because usage structure, billing rules, and invocation patterns all affect total cost. This article breaks down the variables behind API spending—uncached and cached input tokens, output tokens, request timing, and execution mode—and provides a reusable Python cost-calculation script. It also examines batch processing, cache TTL and write fees, subscription versus overage billing, time-of-day scheduling, regional deployment, model migration, selection workflow, and billing reconciliation.
Same unit price, why different bills
LLM APIs are usually billed by token. Put several providers’ price sheets side by side, and it is easy to conclude that “the price is the same.” But a monthly bill is determined by three factors together: usage structure, billing rules, and invocation method. The same request executed under different rules can produce very different bills.
This article breaks down the rules that affect cost one by one, explains how each rule changes the total, and provides a calculation script that can be applied directly.
1. Start by breaking down billing variables
Before calculating cost, split usage into four variables:
- Uncached input tokens: the part of each request that is not reused and must be billed at full rate.
- Cached input tokens: the part where a repeated prefix is reused from cache, usually at a clearly lower unit price than ordinary input.
- Output tokens: content generated by the model, generally at the highest unit price.
- Request time distribution and execution mode: real-time requests versus batch jobs, and which time periods they are concentrated in.
Looking only at total token count hides structural differences. Two workloads with the same total volume can produce bills that differ by several times if their cache hit rates differ.
2. Use a script to calculate the same usage
The script below converts the variables above into cost. The unit prices are for demonstration only and do not represent the real prices of any service.
from dataclasses import dataclass@dataclassclass Price:input: float # CNY per million tokens, uncached inputcache_hit: float # CNY per million tokens, cached inputoutput: float # CNY per million tokens, outputdef monthly_cost(usage: dict, price: Price, batch_ratio: float = 1.0) -> float:"""usage values are token counts; returns cost in CNY."""million = 1_000_000uncached = usage["input"] - usage["cached"]cost = (uncached / million * price.input+ usage["cached"] / million * price.cache_hit+ usage["output"] / million * price.output)return cost * batch_ratiousage = {"input": 10_000_000, "cached": 6_000_000, "output": 2_000_000}price = Price(input=10, cache_hit=1, output=50)print(round(monthly_cost(usage, price), 2)) # 146.0print(round(monthly_cost(usage, price, batch_ratio=0.5), 2)) # 73.0
In this example, monthly input is 10 million tokens, of which 6 million hit cache, and output is 2 million tokens. At the example unit prices, the monthly cost is CNY 146. Without cache hits, the same input would all be billed at the normal price, raising the cost to CNY 200. If the task uses batch processing with a 50% discount, the cost drops to CNY 73.
The value of the script is that it fixes the method. After replacing the example prices and usage with real price sheets and real usage logs, the same code can compare multiple options side by side.
3. Batch offline jobs: trade waiting time for unit price
Batch interfaces usually allow the service provider to process requests within a certain time window and settle them at a lower price than real-time calls. This type of rule fits scenarios such as:
- Offline document summarization, data labeling, and historical corpus cleaning;
- Report generation and overnight batch evaluation;
- Tasks that are not sensitive to result return time and only care about final completion.
Before using batch processing, confirm three things. First, whether the discount covers all models or only some models. Second, whether the task completion deadline meets business requirements. Third, whether failed retries are billed again. For interactive scenarios, such as conversations where users wait for an immediate reply, batch processing is not suitable because waiting time directly affects experience.
4. Cache billing: prefix reuse benefits and write costs
Cache benefits come from repeated content. System prompts, fixed knowledge documents, tool definitions, and similar content remain unchanged across multiple requests. The service provider can cache this prefix and bill subsequent hits at a lower unit price.
Cache billing usually includes two elements:
- Cache TTL: how long the cache is retained after the last hit. If the interval between two requests exceeds the TTL, the cache expires and the next request writes it again.
- Write fee: some services charge separately for cache writes, and the write unit price may be higher than ordinary input.
Therefore, whether caching is worthwhile depends on the number of hits. Let S be the amount saved per hit relative to ordinary input, and W be the extra cost of one write. The required number of hits satisfies:
n ≥ W / S
For example, if each hit saves CNY 0.5 and one write costs an extra CNY 2, at least 4 hits are needed to break even. For tasks with long request intervals and few reuses, enabling caching may actually increase cost.
An engineering practice is to place stable content at the front of the prompt and put changing user input at the back. The more stable the prefix, the higher the hit rate.
5. Subscriptions and overage billing: fixed cost and marginal cost
A subscription plan is usually structured as “a fixed monthly fee plus an included allowance, with usage beyond the allowance billed by volume.” Let the monthly fixed fee be F, the overage unit price beyond the included allowance be p_over, the pure pay-as-you-go unit price be p, and monthly usage be Q in million tokens. The costs of the two approaches are:
- Pay-as-you-go: Q × p
- Subscription: F + max(0, Q − included allowance) × p_over
When usage is large and stable, the subscription’s unit cost is usually lower. The break-even point can be found by setting the two expressions equal. Note that subscriptions often come with usage terms, such as covered model scope, concurrency limits, permitted scenarios, and prohibited uses. Cost calculation should include these constraints in the decision rather than comparing price alone.
6. Time-of-day distribution and off-peak scheduling
Some services offer differentiated pricing by time period. If low-price periods exist, the time distribution of business calls directly affects cost.
The evaluation method is to count request volume by hour in logs and calculate the share that falls in low-price periods. Then determine how many of those tasks can be deferred. For example, report generation and data backfills can usually be scheduled at night, while real-time user requests must remain at their original times.
7. Regional deployment and data egress
The same service may have different prices in different regions, and some regions may be priced noticeably higher than others. When choosing a region, consider the following factors together:
- Network latency: the farther the caller is from the service node, the longer the response time;
- Compliance requirements: whether data is allowed to be transmitted across borders;
- Data egress fees: transferring data across regions or networks may be billed separately;
- Resource proximity: deploying in the same region as existing business systems usually reduces network cost and operational complexity.
Price is only one factor in region selection. A lower-priced region may bring higher latency or compliance risk, which can raise total cost instead.
8. Model iteration and retirement costs
Model versions are updated continuously. Old versions gradually stop onboarding new users and are retired at a certain point. Migration is not just changing a model name; it also includes the following work:
- Run regression tests on an evaluation set to confirm output quality does not decline;
- Adjust prompts to adapt to behavior differences in the new model;
- Recalculate cost, because unit prices and cache rules may differ between old and new versions;
- Update monitoring and alert thresholds.
A way to reduce migration cost is to abstract the invocation layer and make model names, endpoints, and parameters configurable. At the same time, keep a fixed evaluation set so each migration can be verified quantitatively.
9. Selection decision workflow
When selecting a service, follow these steps:
- Split business traffic into real-time calls and offline tasks;
- Measure the input, cache hit, and output proportions for each traffic type;
- Use the cost script to calculate monthly costs for three to four candidate options;
- Assess lock-in risk for each option, including migration cost and dependence on a single model;
- Record price sources and verification dates, and recheck once before launch.
The decision usually depends on traffic structure rather than the list unit price of any one provider. Offline traffic suits batch processing, stable high usage suits subscription evaluation, and multi-region business requires a tradeoff between latency and compliance.
10. Price verification and bill reconciliation
Price pages change over time, and price data in articles or internal documents quickly becomes stale. Three practices are recommended:
- Mark every price number with its source, verification date, unit (CNY per million tokens), and currency;
- Put the price table in a configuration file read by the script, so prices do not scatter across code and documents;
- Reconcile the actual bill with the calculated result every month. When deviations appear, check cache hit rate, retry count, and time distribution.
With this record in place, teams can quickly recalculate after price changes.
