LLM API Cost Optimization: Same Price, Different Bills, Six Cost Levers

    Why can LLM API bills differ by 30% or nearly double even when on-demand unit prices are nearly the same? Because unit price is only one input to the final bill. This article explains the main billing items—regular and cached input, cache writes, output, batch discounts, subscriptions or committed usage, credits, and regional multipliers—and walks through six cost levers: context caching, batch inference, subscriptions, region/network choices, credits, and model-tier routing. It includes a unified worked example, business profiles, usage attribution, common pitfalls, and a five-step optimization roadmap.

    1. Why the Same Price Can Produce Different Bills: Billing Is Driven by Line Items

    Many teams estimate LLM costs by looking only at the on-demand unit price for online models. They select a model, plug estimated call volume into several cloud platforms, see nearly identical unit prices, and conclude that the vendor choice does not matter much. But the month-end bill can differ by 30% or even approach double. The reason is not that the unit price was calculated incorrectly; rather, the on-demand unit price is only one input in the billing formula.

    A complete LLM inference bill can be abstracted as:

    1. Monthly cost = out-of-plan usage subtotal + subscription fees - credits

    The same unit price only means the unit-price column is the same. What really separates the bills is which billing items the usage is split into. Common billing items include:

    Billing item Impact on bill Main determinants
    Regular input (cache miss) Baseline input cost Request volume, context length
    Cached input Far below regular input Prefix stability, cache validity period
    Cache write May be charged separately Write policy, cache validity period
    Output Usually more expensive Generated length
    Batch discount Overall discount Whether the task can be delayed
    Subscription or committed usage Fixed spend offsets usage Usage predictability, whether the commitment is fully used
    Credits Offsets part of the cost Credit size, validity period, applicable models
    Regional multiplier Overall markup Call region, cross-network links

    The same batch of requests may all fall under “regular input + output,” or part of it may move to “cache hit,” “batch discount,” or “subscription offset.” Therefore, the key to evaluating cost is not “which vendor has the lowest unit price,” but: which billing items will my requests enter? Can part of the usage be moved to a cheaper billing item?

    The following rules are common industry practices. For specific prices, discounts, cache-write fees, plan terms, and result-retention periods, refer to the latest billing documentation for the chosen platform.

    2. Breaking Down the Bill: Six Billing Rules and Cost Levers

    2.1 Context Caching: Pay Less for Repeated Content

    Many requests have fixed prefixes, such as system prompts, business rules, knowledge-base documents, and few-shot examples. This content may be sent repeatedly on every call. If it is all charged as regular input, the cost can be high.

    The mainstream approach is prefix caching: when the platform detects that the beginning of a request is identical and has not expired, it charges that portion of input at the cache-hit price, while only the new portion is charged at the regular price. Some platforms also charge separately for cache writes, so examples need to distinguish whether the write fee is included.

    For one input example, assume total input is 10,000 tokens, of which 8,000 tokens are a fixed prefix and 2,000 tokens are new content. The cache-hit price is one-tenth of the regular input price, and no cache-write fee is calculated. Then the input cost is:

    1. 8000 × 0.1 + 2000 × 1 = 2800

    This is equivalent to about 28% of the original input cost of 10,000. This refers to a reduction in “input cost,” not that the entire bill is charged at 30%; output costs, batch discounts, and subscription fees still need to be calculated separately. If the platform charges a cache-write fee, the write portion must be added according to the platform’s rules.

    Practical points:

    1. Put stable content at the front. Avoid placing timestamps, request IDs, or random numbers at the beginning, which can invalidate the prefix.
    2. Make the cache validity period cover the actual call interval. If the interval between adjacent calls exceeds the cache lifetime, the benefit may be offset by cache-write fees.
    3. Make cache hit rate a core monitoring metric, displayed alongside latency and error rate.

    2.2 Batch Inference: Trade Waiting Time for Price

    Conversational applications usually require second-level responses, but many tasks do not require real time, such as offline summarization, historical ticket tagging, batch review, nightly data jobs, and knowledge-base rebuilding. These tasks can be submitted to an asynchronous batch interface and results retrieved within an agreed time window.

    Common batch pricing is around 50% of the real-time price, with some platforms at 50%–60%. For specific discounts, retrieval deadlines, result-retention periods, and retry rules, refer to the platform’s billing documentation. For tasks that can wait, changing only the integration method without changing the model can reduce the bill by 40–60%.

    For example, a customer-service product generates 200,000 conversation summaries per day. If all go through the real-time interface, the cost is high; if migrated to nightly batch processing and the platform discount is 60%, this portion is calculated at 0.6. Product functionality does not change, and user perception is usually unchanged.

    Prerequisites include: generating a batch file and uploading it to storage accessible to the platform; retrieving results after task completion; result files may have a retention period; retry failures must be included in the time budget.

    2.3 Subscriptions and Committed Usage: Package Predictable Load in Advance

    Some platforms offer monthly or per-cycle token subscription plans. A common design is that after paying a fixed fee, the plan covers a certain amount of input or total tokens, with no additional charge within the plan; usage beyond that is billed at the standard price; it may also cover only off-peak calls, with higher-tier pricing for peak overage.

    Whether it is worthwhile can be judged by the break-even point:

    1. Break-even usage = plan fee ÷ standard on-demand unit price

    If monthly usage is consistently above the break-even point, a subscription is usually more economical. If it is consistently below the break-even point, it is like paying for unused allowance. If usage is near the break-even point, you need to look closely at whether the plan covers all models, whether it covers output, whether overage is priced higher, and whether there are off-peak restrictions. Do not buy a plan using peak usage, and do not force a plan using off-peak usage. A more reliable method is to use 2–4 weeks of actual usage for shadow estimation before deciding on a tier.

    2.4 Region and Network: Cost Is Not Only About Tokens

    The same model may have different service prices in different regions. Some regions may have higher unit prices than others, possibly related to cross-region network link costs and local resource costs. There is a tradeoff here: being closer to users can reduce latency, but high-priced regions may push up the bill.

    Cross-cloud calls also create hidden costs:

    • Public egress traffic fees, where both request and response bodies may be charged;
    • Additional network latency; long-context requests have large request bodies;
    • Timeout retries amplify costs, since every retry is a real billable call.

    Therefore, when a business already runs in one cloud, preferring a same-region model service on the same platform often reduces both network costs and retry calls.

    2.5 Credits: Do Not Treat a One-Time Discount as a Long-Term Budget

    When a new model launches, there is often a million-token-level free credit for trial and evaluation. These credits have a real impact on the bill, but they usually apply only to specific models and have a usage deadline, so they are not enough to support long-term capacity planning. It is recommended to list credits as a temporary offset, calculate capacity planning at zero, record when the credit is exhausted, and switch budgets in advance.

    2.6 Model Tiers: The Most Suitable Model Is the Cheapest Model

    The bill is a weighted sum of model usage. Routing simple tasks such as classification, extraction, and format conversion to a lightweight model is often more effective than simply negotiating price. Using the assumed unit prices in this example, the lightweight model’s input is about one-third of the flagship’s and output is about one-quarter of the flagship’s; if the task output is short, the combined cost may drop to about one-quarter of the original.

    Model routing cannot be one-size-fits-all; decisions should be based on task quality gains:

    1. Build an offline evaluation set;
    2. Run the lightweight model and confirm that quality is acceptable;
    3. Use canary traffic and monitor online quality;
    4. Keep a fallback switch.
    1. # Illustrative code: only demonstrates routing structure, not tied to a specific bill
    2. TASK_ROUTES = {
    3. "intent_classify": {"model": "lite", "mode": "batch", "cache": True},
    4. "doc_summary": {"model": "flagship", "mode": "batch", "cache": True},
    5. "chat_reply": {"model": "flagship", "mode": "realtime", "cache": True},
    6. }
    7. def route(task_type: str) -> dict:
    8. return TASK_ROUTES.get(task_type, TASK_ROUTES["chat_reply"])

    3. Unified Example: How the Bill Changes for the Same Usage

    The unit prices in this section are for demonstrating billing rules only and do not represent any vendor’s actual pricing. All unit prices are in CNY per million tokens. Unless otherwise specified, A, B, C, D, and F do not include cache-write fees; if the actual platform charges write fees, they should be added separately according to the write rules.

    Assumed unit prices:

    Model tier Regular input Cached input Output Batch discount
    Flagship 20 2 100 Charged at 60%
    Lightweight 6.5 1.3 27 Charged at 60%

    Baseline usage: 10 million input tokens per month, i.e., 10 million tokens; 1 million output tokens, i.e., 1 million tokens. All real-time, no cache. The baseline bill is:

    1. 10 × 20 + 1 × 100 = 300 CNY

    On this basis, observe different rules:

    Scenario Billing method Monthly bill (CNY) Compared with baseline Notes
    Baseline All real-time, no cache 300 0% Control
    A. Long-document Q&A 60% input cache hit 192 -36% Cache-write fee not included
    B. Offline document summary Full batch 180 -40% Batch charged at 60%
    C. Batch + cache Batch and 60% cache hit 115.2 -62% Cache-write fee not included
    D. Conversation summary routing 60% of input and output switched to lightweight 175.2 -42% Assumes quality is acceptable
    E. Subscription coverage Subscription of 300 CNY includes 20 million input, output billed on-demand 400 +33% Input below break-even
    E′. Same subscription with input increase Input 30 million, output 1 million 600 +100% Compared with 700 CNY on-demand for the same usage, saves 14.3%
    F. Cross-region call Unit price in another region is about 1.1× the baseline region 330 +10% Excludes cross-network traffic and retries

    The row-by-row verification is as follows. All calculations below use “million tokens” as the unit.

    • A: Of the input, 6 million tokens hit the cache, i.e., 6 million; 4 million miss, i.e., 4 million. Input cost = 6 × 2 + 4 × 20 = 92; output cost = 1 × 100 = 100; total 192 CNY.
    • B: Real-time total is 10 × 20 + 1 × 100 = 300; batch charged at 60% gives 300 × 0.6 = 180 CNY.
    • C: Cached input cost = 6 × 2 + 4 × 20 = 92; output cost = 1 × 100 = 100; real-time total 192; batch charged at 60% gives 192 × 0.6 = 115.2 CNY.
    • D: Lightweight input 6 × 6.5 = 39, output 0.6 × 27 = 16.2; flagship input 4 × 20 = 80, output 0.4 × 100 = 40; total 39 + 16.2 + 80 + 40 = 175.2 CNY.
    • E: Plan fee 300 CNY covers 20 million input. Monthly input 10 million does not exceed; output 1 × 100 = 100; total 400 CNY. Break-even input = 300 ÷ 20 × 1,000,000 = 15,000,000 tokens.
    • E′: Plan of 300 CNY covers 20 million input; input 30 million, overage 10 million, i.e., 10 million; overage input fee = 10 × 20 = 200; output fee = 1 × 100 = 100; total 600 CNY. The same usage on-demand is 30 × 20 + 1 × 100 = 700 CNY, so the subscription saves 100 CNY, about 14.3%. But the absolute bill in E′ is higher than the baseline because input increases from 10 million to 30 million and cannot be directly compared with the baseline’s savings.
    • F: Input 10 × 22 = 220, output 1 × 110 = 110; total 330 CNY.

    This set of examples shows: at the same usage, the bill for A through D can drop from 300 CNY to between 115.2 and 192 CNY; if input-volume changes are considered, using a subscription incorrectly or making a cross-region call can push up the budget. True cost optimization is not just focusing on unit price, but putting requests into the appropriate billing items.

    4. Five Business Profiles and Selection Advice

    Business profile Typical workload Cost levers Immediate actions and cautions
    Online chat / intelligent customer service Real-time, with fixed system prompts and knowledge-base prefixes Stable prefix + cache; subscription to cover stable input when necessary First check the real-time vs batch ratio, then cache hit rate; also monitor first-token latency
    Offline batch processing Deferrable, queueable, large volume Prefer batch interfaces, layered with cache First check the share of deferrable tasks; note result-retention periods and retry windows
    Creative writing / coding assistant Frequent interaction, long context, long output Cache + output-length governance + model-tier routing First check the share of output tokens; output is often the main cost
    Multi-tenant / multi-business platform Volatile load, needs per-tenant accounting Tag usage per tenant, set quotas and alerts First aggregate bills by tenant; an anomaly in one tenant may drag down the overall budget
    Embedded / edge devices Dispersed traffic, poor network conditions Nearest access, control context length First check retry count and timeout rate; retries directly amplify billable volume

    5. Break the Bill into Actionable Granularity: Usage Attribution

    If you can only see one total bill, optimization is hard to implement. A mature practice is to instrument at the application layer so that every call leaves an aggregatable metering record.

    One call record may include:

    1. {
    2. "ts": 1735660800,
    3. "tenant": "biz_a",
    4. "task_type": "doc_summary",
    5. "model": "flagship",
    6. "mode": "batch",
    7. "input_tokens": 6200,
    8. "cached_tokens": 4800,
    9. "cache_write_tokens": 0,
    10. "output_tokens": 380,
    11. "region": "region-a",
    12. "latency_ms": 920
    13. }

    These fields can support three types of analysis: identifying tasks by task type that can be migrated to batch or lightweight models; identifying abnormal growth by tenant; and calculating cache hit rate and locating sources of prefix instability.

    5.1 Billing Convention for Cache Hits and Writes

    Cached tokens are still part of input and cannot be double-counted or missed. Cache writes usually count only the new prefix, changed portions, or are calculated separately according to the platform field; it should not be assumed by default that all input is counted as write billing volume.

    1. def billable_tokens(input_tokens: int, cached_tokens: int, cache_write_tokens: int = 0) -> dict:
    2. """Split billable items using a generic cache convention; specific write rules depend on the platform used"""
    3. fresh = max(input_tokens - cached_tokens, 0)
    4. return {
    5. "fresh_input": fresh,
    6. "cached_input": cached_tokens,
    7. "cache_write": cache_write_tokens,
    8. }

    5.2 Monthly Reconciliation: Subtotals by Call Mode

    Monthly reconciliation cannot apply one batch coefficient to the entire bill, because batch discounts usually apply only to batch usage. Usage should be grouped by mode, with real-time and batch subtotals calculated separately, then subscription fees, overage fees, and credits added.

    1. # All totals are summed by the mode field in call records
    2. realtime_cost = (
    3. fresh_realtime_total / 1e6 * PRICE_INPUT
    4. + cached_realtime_total / 1e6 * PRICE_CACHED
    5. + cache_write_realtime_total / 1e6 * PRICE_WRITE
    6. + output_realtime_total / 1e6 * PRICE_OUTPUT
    7. )
    8. batch_subtotal = (
    9. fresh_batch_total / 1e6 * PRICE_INPUT
    10. + cached_batch_total / 1e6 * PRICE_CACHED
    11. + cache_write_batch_total / 1e6 * PRICE_WRITE
    12. + output_batch_total / 1e6 * PRICE_OUTPUT
    13. )
    14. batch_cost = batch_subtotal * BATCH_RATIO
    15. monthly_cost = realtime_cost + batch_cost + subscription_fee - free_credit + overage_cost

    Here, BATCH_RATIO applies only to the batch group; overage_cost represents usage beyond the subscription plan; free_credit is the discount that can be offset within its validity period. If the plan covers part of the usage, first deduct the covered amount from the usage subtotal, then add the plan fee and overage fee.

    6. Six Common Pitfalls

    1. Only comparing unit prices, not billing rules. When unit prices are the same, compare cache mechanisms, batch discounts, subscription terms, and regional coverage.
    2. Treating long context as an advantage by default. An uncached long prefix is charged at the regular price; prioritize reusing stable prefixes and cleaning up historical messages.
    3. Applying subscriptions one-size-fits-all. Buying a plan with peak usage wastes money; buying with off-peak usage may lead to overage price increases.
    4. Ignoring the billing impact of retries and failures. Timeout retries and regeneration after review blocks both generate real calls.
    5. Not accounting for the network bill in cross-platform calls. Egress traffic, latency, and retry amplification may exceed the token price gap.
    6. Upgrading models without regression evaluation. Model changes should compare quality and unit cost on the same evaluation set.

    7. Implementation Roadmap: Five Steps to Build a Cost-Optimization Loop

    1. Establish a baseline (1–2 weeks): enable usage logging and track tokens and costs by model, task type, call mode, and region.
    2. Split tasks: move deferrable tasks to batch; extract stable prefixes into a unified template to improve cache hit rate.
    3. Route models: build an evaluation set, gradually switch simple tasks to lightweight models, and keep a fallback switch.
    4. Match the commercial model: use shadow data to calculate the subscription break-even point; existing cloud businesses should prefer same-region access.
    5. Run routine operations: report tokens, hit rate, and cost per request; configure budget alerts; review the bill monthly.

    Conclusion

    “Same unit price, different bill” essentially means the unit price is the same but the billing rules are different. LLM API cost optimization has shifted from “choosing the cheapest vendor” to “putting requests into the most suitable billing items.”

    By priority, the six levers can be evaluated in order: first, batch processing instead of real-time; second, improving cache hit rate; third, model-tier routing; fourth, subscriptions and committed usage; fifth, nearest access and region selection; sixth, short-term use of credits. While keeping the model unchanged and quality stable, combining these rules can help most businesses reduce inference bills by 30%–60%. The premise is having a usage bill that can be split, understood, and traced.