LLM API Pricing: Why Identical Unit Prices Produce Bills That Differ by Half

    Two platforms can list identical model names, context lengths, and published per-token prices, yet generate monthly bills that differ by nearly 50% for the same call volume. The published unit price describes only one of the three variables that actually determine a bill: usage, price, and the billing rules that apply discounts, surcharges, and free tiers. This article breaks down how LLM API bills are structured, how to decompose token usage into cheaper and more expensive categories, and which billing rules are most often overlooked (prompt caching, batch processing, off-peak discounts, subscriptions, free quotas, and regional pricing). It then shows how to model and verify costs in code, offers scenario-based strategies for optimizing spend, and outlines how to build cost governance into your engineering workflow. The framework is platform-agnostic and aims to give you a way to judge costs, not to declare which provider is cheapest.

    Introduction: Same Price, So Why Is the Bill Half?

    Many teams, when choosing a platform, pull each provider’s pricing page into a single spreadsheet and compare unit prices line by line, then conclude “it’s all the same.” What actually confuses both finance and engineering is a different phenomenon: on two platforms, the model name, context length, capability description, and published unit price are completely identical, and the team calculates based on the same call volume, yet the monthly bills differ by nearly half.

    The reason isn’t that one side calculated wrong. It’s that the published unit price describes only one dimension of the billing process. A bill is actually the product of three variables:

    • Usage: how much of each type of token is consumed;
    • Price: the published unit price of each type of token;
    • Rules: under what conditions each type of usage is counted, and at what discount, into the bill.

    Unit price only affects the first term of that product. What really widens the gap is often the overlooked rule term. This article does not evaluate any specific product. Instead, it abstracts this kind of difference into a reusable analysis framework. Around the billing mechanism of LLM APIs, it explains in sequence:

    • the structure of a bill;
    • how to decompose usage;
    • which rules are most easily overlooked;
    • how to estimate and verify with code;
    • how to optimize cost for your business scenario.

    One note upfront: each platform’s rules are governed by its official pricing page and billing documentation, which change over time and may differ by region, promotion, or contract terms. The goal here is to provide a way to judge, not to conclude “which provider is cheapest.”

    1. Decomposing the Problem: What Variables Are Actually in a Bill?

    1.1 An Overlooked Fact: The Bill Is Not Just Tokens × Unit Price

    By intuition, LLM API billing is simple: “usage times unit price.” But in a real bill, you’ll rarely find these common charges on the price table:

    • cache write fees;
    • long-context tiered surcharges;
    • reasoning (thinking) tokens;
    • multimodal inputs such as images and audio;
    • “tool result re-injection” in tool calls.

    They’re usually written in the billing notes rather than on the price table. If you only look at the price table when estimating, systematically underestimating cost is almost inevitable.

    So it’s clearer to write the bill as a formula:

    Monthly bill = Σ(each billable quantity × corresponding unit price × rule coefficient) + fixed fees such as subscriptions − free quota deductions

    Here the “rule coefficient” is the collection of all discounts, surcharges, and free rules for each category. Across platforms, the price terms may align perfectly, while the rule coefficients can differ by 0.4 to 0.6. This is the root of “same price, different bill.”

    1.2 Billing Basis: The Three Sources of the Numbers on a Bill

    For the same call volume, different teams’ estimates can differ a lot, and the problem is often in the measurement basis. Before comparing prices, align on these first:

    1. Billable tokens vs. visible tokens. Bills are usually based on server-side token counts, and different tokenizers may produce different counts. Some platforms also convert non-text inputs such as images and audio by additional rules, none of which show up in text length.
    2. Tax-inclusive vs. tax-exclusive. Whether the unit price on the pricing page includes tax, and whether you can obtain an invoice at the applicable tax rate under your contract, directly affects actual spend.
    3. Currency and settlement exchange rate. Some platforms price in USD and settle by exchange rate; resource costs and tax structures also vary by region, so the unit price can be noticeably higher in some regions than in others.

    Only after unifying the basis is comparison meaningful. This is also the step most easily botched in multi-platform comparisons.

    2. Decomposing Usage: Splitting Tokens into “Cheaper” and “More Expensive” Categories

    To optimize cost, first see where the money goes. Tokens in LLM calls can be split into at least five categories, with costs differing by tens of times:

    Billable quantity When it occurs Pricing characteristic
    Input without a cache hit Each request carries entirely new content Standard input price
    Input with a cache hit Hits an already-cached prefix Usually 10–20% of the input price
    Cache write Creating or refreshing a cache entry Close to the input price; may be free in some regions
    Output The model’s generated answer Usually several times the input price; the biggest cost
    Fixed fees Subscription plans, reserved throughput, etc. Decoupled from usage; sunk if left unused

    There is an important rule of thumb here:

    • For output-heavy workloads, the optimization focus is “generate shorter, use smaller models” — for example, compress system prompts, trim the reasoning process, and use lightweight models as a fallback for simple requests;
    • For input-heavy workloads with high prefix repetition, such as agents carrying long system prompts or knowledge-base Q&A, the focus is on caching and prefix organization.

    The two share almost no techniques, so you cannot apply the same approach to both.

    3. Six Most Easily Overlooked Billing Rules

    3.1 Caching: The Hit Price Is Low, but the Hit Rate Depends on Request Structure

    Most mainstream platforms’ context caching works like this:

    • it uses the longest fully identical token sequence in the request prefix as the matching basis;
    • the hit portion is billed at a “cache hit price” significantly below the input price, commonly 10–20% of it;
    • hits usually have a time-to-live (commonly minutes to an hour) and are rewritten once expired;
    • some regions charge a one-time fee close to the standard input price for the “write” action.

    This means caching is not a “flip it on and save money” switch but a structural problem. Whether the hit rate is high or low depends entirely on how the request prefix is organized. You can apply this template:

    1. [Fixed layer] System prompt, tool definitions, few-shot examples — identical every time
    2. [Semi-fixed layer] Knowledge-base retrieval results, long documents — version them by content hash; if the content is unchanged, the prefix is unchanged
    3. [Volatile layer] Timestamps, session IDs, random numbers, user questions — push to the back or remove

    Arrange the three types of content from top to bottom: the higher up, the more stable, and the longer the cacheable prefix. The following Python example shows how to run a “prefix contamination check” before assembling messages:

    1. import hashlib
    2. FIXED_PREFIX = """You are an enterprise knowledge-base assistant.
    3. Rules: 1. Answer only based on retrieval results; 2. State clearly when there is no basis; 3. Cite index numbers."""
    4. def build_messages(rag_chunks: list[str], question: str) -> list[dict]:
    5. # Semi-fixed layer: retrieval results fingerprinted by content; if the content is unchanged, the prefix is exactly unchanged
    6. version = hashlib.sha256("\n".join(rag_chunks).encode()).hexdigest()[:12]
    7. stable_prefix = f"{FIXED_PREFIX}\n[KB version:{version}]\n" + "\n".join(rag_chunks)
    8. return [
    9. {"role": "system", "content": stable_prefix}, # Fixed + semi-fixed; try to hit the cache
    10. {"role": "user", "content": question}, # Put the volatile layer last
    11. ]
    12. def cache_efficiency(hits: int, misses: int) -> float:
    13. return hits / (hits + misses) if hits + misses else 0.0

    A few common “hit-rate killers” are worth watching for:

    • concatenating the current time after the fixed prefix — time changes every second, so the cache keeps invalidating;
    • using randomly ordered retrieval results — the same question retrieved twice in a different order yields a different prefix;
    • inserting conversation history before the system prompt in multi-turn sessions;
    • inserting dynamic content early in streaming output.

    Practical advice: treat “cacheable prefix tokens” and “cache hit rate” as standard monitoring metrics, tracked continuously per business line.

    3.2 Batch Processing: Trading Latency for Discounts, Suitable for “Offline, Can-Wait” Tasks

    Many platforms offer asynchronous batch APIs: submit a large number of requests at once, let the platform queue and execute them in spare compute, and return the results in bulk later. Because they don’t occupy real-time resources, these tasks usually cost about half of online calls, at the price of going from “second-level response” to “minute- or even hour-level.”

    From a billing standpoint, batch processing is the easiest discount to adopt, but the prerequisite is that the task itself can be “delayed.” Typical use cases include:

    • bulk labeling of historical tickets;
    • batch summarization and classification of documents;
    • offline dataset generation and eval-set labeling;
    • nightly reporting and inspection-report generation.

    Requests in real-time pipelines are completely unsuited to batch processing; migrating them hastily would directly harm the user experience.

    3.3 Subscription vs. Pay-as-You-Go: A “Monthly Plan or Meter” Arithmetic Problem

    Some platforms offer subscription plans: pay a fixed fee each month to receive a certain token quota or call allowance, with usage beyond that billed at the standard price. Some also distinguish “all-hours quota” from “off-peak quota” within a plan, where off-peak calls consume less quota — effectively a disguised discount.

    Here you can borrow the thinking behind mobile data plans and first calculate the “break-even point”:

    Break-even point (monthly) = subscription price ÷ (pay-as-you-go unit price × usage per unit)

    Only when actual monthly usage clearly exceeds this point does a subscription truly pay off; otherwise the fixed fee becomes a sunk cost. Two other easily overlooked factors:

    • Lock-in risk. Subscriptions cover only specific models; after a model upgrade or a business migration, this cost may be wasted;
    • Allocation and visibility. How quotas are allocated and tracked across multiple businesses and teams needs to be designed in advance.

    3.4 Off-Peak Discounts: Scheduling Off-Peak Earns Extra Discounts

    Some platforms give tiered discounts for low-traffic hours (commonly late night to early morning), with the discount varying by time slot. Its essence is peak shaving and valley filling: the platform discounts idle compute for businesses that can wait.

    When you can shift half your calls from peak to trough, the cost of those calls can even drop by about half — especially significant for “non-real-time, can-be-delayed” tasks. Key implementation points:

    • the task itself can be queued, such as nightly batches or scheduled summaries;
    • don’t cross a clear “deadline,” to avoid missing business windows;
    • explicitly mark the task’s deadline in code, rather than defaulting to “the sooner the better.”

    3.5 Free Quotas and Model Generations: Short-Term Bonuses and Long-Term Costs

    When a new model launches, platforms often offer a free trial quota or new-user credits. These are suitable for capability validation and regression evaluation, but not as a production budget baseline: once the quota runs out, the cost structure switches immediately.

    Another easily overlooked long-term cost is “model generations”:

    • older-generation models usually give a deprecation timeline, during which they are no longer open to new users;
    • migration is not as simple as changing a model name — you need to re-run the eval set, adjust prompts and parameters, and assess quality regressions;
    • if a business deeply depends on some old model’s features, the migration cost may far exceed the savings from unit-price differences.

    So in architecture design, it is advisable to keep a “model adapter layer”: business code targets a unified abstract interface, rather than scattering a specific model’s parameter names everywhere.

    3.6 Regional Price Differences: Proximity Beats “Picking the Cheapest”

    The same model from the same platform may cost different amounts in different regions. Because of resource costs and settlement factors, some regions’ unit prices are often noticeably higher than others. But only picking the “cheapest region” is not always optimal; you also need to weigh:

    • Network latency. Cross-region calls bring noticeable round-trip latency;
    • Egress traffic fees. Cross-region or cross-cloud transfers may incur extra bandwidth charges;
    • Data compliance requirements. Some businesses’ data is not allowed to leave a region.

    So “connect in proximity” is usually the lowest overall cost in most scenarios: call the model service in the same region where your data is generated in the same cloud, which usually also lets you use the internal network and reduces public egress fees.

    4. A Unified Cost Model: Writing the Rules into Code

    The theory aside, let’s use an executable model to unify the rules above. It abstracts “rules” into a replaceable parameter configuration, making it easy to run horizontal comparisons across platforms and approaches.

    1. from dataclasses import dataclass
    2. from typing import Callable
    3. # ---------- 1. Price: expressed as USD per 1M tokens ----------
    4. # Note: the unit prices and coefficients below are illustrative hypothetical values,
    5. # only to demonstrate the calculation method.
    6. @dataclass(frozen=True)
    7. class Price:
    8. input_rate: float # Unit price for input without a cache hit
    9. cache_read_rate: float # Cache hit unit price
    10. output_rate: float # Output unit price
    11. cache_write_rate: float # Cache write unit price (None means free)
    12. batch_discount: float = 0.5 # Batch discount: paid = list price × discount
    13. cache_hit_eligible: bool = True # Whether this model/region supports the cache hit price
    14. # ---------- 2. Usage profile ----------
    15. @dataclass(frozen=True)
    16. class UsageProfile:
    17. input_tokens: int # Monthly input tokens (including the cache hit portion)
    18. output_tokens: int # Monthly output tokens
    19. cache_hit_ratio: float = 0.0 # Ratio of input that hits the cache
    20. cache_write_ratio: float = 0.0 # Ratio of input used to create/refresh the cache
    21. batch_ratio: float = 0.0 # Ratio submitted via batch (discount applied to the whole request)
    22. offpeak_ratio: float = 0.0 # Ratio of online calls falling in off-peak hours
    23. offpeak_rate: float = 1.0 # Off-peak online unit price discount
    24. # ---------- 3. Rules: expressed as policy functions ----------
    25. # Policy signature: (usage profile, unit price, this request's actual unit price) -> actual paid unit price
    26. # When the hit price is unavailable, it can fall back here without changing the main billing flow.
    27. Rule = Callable[[UsageProfile, Price, float], float]
    28. def cap_by_eligible(rule: Rule) -> Rule:
    29. """When the model or region does not support the cache hit price,
    30. the hit portion falls back to the standard input price."""
    31. def wrapped(p: UsageProfile, price: Price, rate: float) -> float:
    32. rate = rule(p, price, rate)
    33. if not price.cache_hit_eligible and rate < price.input_rate:
    34. return price.input_rate
    35. return rate
    36. return wrapped
    37. # ---------- 4. Main billing flow ----------
    38. def monthly_cost(
    39. usage: UsageProfile,
    40. price: Price,
    41. rules: list[Rule] | None = None,
    42. subscription: float = 0.0,
    43. ) -> dict:
    44. rules = rules or []
    45. p_in = usage.input_tokens / 1e6
    46. p_out = usage.output_tokens / 1e6
    47. # 1. Offline portion: whole request at the batch discount, cache rules still apply
    48. b_in, b_out = p_in * usage.batch_ratio, p_out * usage.batch_ratio
    49. batch_rate_in = rules_apply(usage, price, price.input_rate * price.batch_discount, rules)
    50. batch_rate_out = rules_apply(usage, price, price.output_rate * price.batch_discount, rules)
    51. batch = b_in * batch_rate_in + b_out * batch_rate_out
    52. # 2. Online portion: first distinguish input types, then apply online policies
    53. o_in = p_in * (1 - usage.batch_ratio)
    54. cache_hit = o_in * usage.cache_hit_ratio
    55. cache_write = o_in * usage.cache_write_ratio
    56. fresh_in = o_in - cache_hit - cache_write
    57. rate_fresh = rules_apply(usage, price, price.input_rate, rules)
    58. rate_hit = rules_apply(usage, price, price.cache_read_rate, rules)
    59. rate_out = rules_apply(usage, price, price.output_rate, rules)
    60. write_rate = price.cache_write_rate
    61. if write_rate is not None:
    62. write_rate = rules_apply(usage, price, write_rate, rules)
    63. online = (fresh_in * rate_fresh + cache_hit * rate_hit
    64. + p_out * (1 - usage.batch_ratio) * rate_out
    65. + (cache_write * write_rate if write_rate is not None else 0.0))
    66. # 3. Fixed fees and total
    67. total = online + batch + subscription
    68. baseline = p_in * price.input_rate + p_out * price.output_rate
    69. return {
    70. "online": round(online, 2),
    71. "batch": round(batch, 2),
    72. "subscription": subscription,
    73. "total": round(total, 2),
    74. "saving_vs_payg": round(1 - total / baseline, 4) if baseline else 0.0,
    75. }
    76. def rules_apply(usage: UsageProfile, price: Price, rate: float, rules: list[Rule]) -> float:
    77. for rule in rules:
    78. rate = rule(usage, price, rate)
    79. return rate

    Take the hypothetical parameters “flagship model at 20 / 2 / 100, writes at input price, batch at 50%” as an example. The monthly profile is: 3 billion input tokens (40% cache hit, 1% new cache write) and 300 million output tokens. The results are:

    Strategy combination Monthly bill (USD) vs. pay-as-you-go
    All online pay-as-you-go (no cache) 66,000 —
    All online pay-as-you-go (with cache) 57,000 −13.6%
    30% of tasks via batch 60,408 −8.5%
    Half of online calls scheduled off-peak (50%) 48,450 −26.6%
    Batch + off-peak combined 45,471 −31.1%
    Off-peak + 50% subscription plan 40,471 −38.7%

    The “off-peak + subscription plan” figure is calculated as follows: 90% of the online portion is covered by the plan (at 50%), 10% is overage at pay-as-you-go, plus a $10,000 fixed subscription fee.

    Two takeaways:

    • The gap comes mainly from rules. Under the above assumptions, the price terms are identical; merely switching the rule combination makes the bill differ by over 30%, and if two rules apply at once, the gap is even larger. This is precisely the mathematical source of “same unit price, bill differs by half.”
    • Subscriptions are not a panacea. With the same off-peak and same 50%, but a monthly usage of only 30% of the assumed value, the subscription plan would actually cost more, because it counts the fixed fee in full.

    The model’s value is not to give a “standard answer” but to let you quickly judge, whenever assumptions change, which rule is most worth fighting for or exploiting.

    5. Scenario-Based Strategies: What Should Different Businesses Choose?

    Bringing the analysis above down to concrete scenarios, it roughly boils down to four typical playbooks.

    5.1 Capability-First: Don’t Lock into a Single Model, Keep the Ability to Switch

    When a business has high demands on model capability and doesn’t want to be tied to one model version, a more robust approach is:

    • call through a unified “model adapter layer,” routing to different model tiers by task type within the layer;
    • continuously track each model’s output quality and cost with the same eval set;
    • prefer channels with transparent billing rules, which makes horizontal comparison easier.

    This way, even if a model is deprecated or its price rises, the business side only needs to adjust the adapter layer’s configuration, and the cost structure is not rebuilt from scratch.

    5.2 Offline-Task-Oriented: Batch + Off-Peak, Get the Full Discount

    For tasks that can wait, use both rules to the fullest:

    • submit via the asynchronous batch API to earn the batch discount;
    • set a “deadline” rather than “complete as soon as possible” for tasks, letting the scheduler automatically place them in off-peak hours.

    Using the Section 3 hypothetical parameters, an input-heavy offline task that fully uses both batch and off-peak can drop its bill by over 30%.

    5.3 Real-Time Interactive: Subscription as a Base + Overage Pay-as-You-Go

    For online businesses that must respond within seconds, the discount room concentrates in the subscription + off-peak combination:

    1. use the last 3–6 months of historical usage to determine the “baseline call volume”;
    2. size the subscription quota to just cover the baseline, with fluctuation going pay-as-you-go;
    3. move all delayable asynchronous tasks (such as session summarization and QA/QC) to off-peak hours;
    4. review the usage distribution monthly and dynamically adjust the plan tier.

    5.4 Existing-Workload-Oriented: Connect in Proximity, Avoid “Migrating Clouds to Save Money”

    For businesses that already have data, storage, and compute on a cloud platform, there is usually no need to migrate cross-cloud just for “a lower unit price.” Three reasons:

    • the unit-price difference is often smaller than the combined cost of migration, rework, and data compliance;
    • same-region internal-network calls have advantages in network latency and egress traffic;
    • cross-cloud data synchronization itself incurs costs and stability risks.

    A more reasonable approach: first do “cache + batch + off-peak” rule optimization within the existing platform, understand the bill structure, then decide whether to migrate.

    6. Cost Governance: Making the Bill “Observable and Attributable”

    No matter how good the strategy, it needs data to support it. It is advisable to fold these mechanisms into daily engineering practice:

    1. Collect usage comprehensively. Record the input, output, cache hits, and other fields for each call, tagged with business line, scenario, version, and so on, to enable attribution by dimension.
    2. Establish unit-economic metrics. Beyond the total bill, look at “cost per request,” “cost per active user,” and “cost per thousand calls” — these metrics are what let you compare different approaches horizontally.
    3. Set budgets and alerts. Set budget thresholds by day and by business line, and alert promptly on abnormal growth, so a traffic spike doesn’t blow up the bill.
    4. A/B test before ramping up. Before launching a new model, new prompt, or new caching strategy, first validate quality and cost on a small traffic share, then ramp up gradually.
    5. Periodically review billing rules. A platform’s discount rules, free quotas, and model deprecation plans all change; it is advisable to review your assumptions against the official documentation once a quarter.

    A minimal viable metering example:

    1. import json
    2. import logging
    3. logger = logging.getLogger("llm_cost")
    4. def log_usage(model: str, usage: dict, tags: dict) -> None:
    5. """Write the billable usage of a single call to structured logs for later bill attribution."""
    6. record = {
    7. "model": model,
    8. "input_tokens": usage["prompt_tokens"],
    9. "output_tokens": usage["completion_tokens"],
    10. "cached_tokens": usage.get("prompt_tokens_details", {}).get("cached_tokens", 0),
    11. **tags, # e.g. {"biz": "support", "env": "prod", "scene": "rag"}
    12. }
    13. logger.info(json.dumps(record, ensure_ascii=False))

    Note that different platforms return usage fields with inconsistent naming, so it is advisable to normalize them once in your own logging layer, to avoid field differences interfering with later analysis.

    7. Common Pitfalls Checklist

    Finally, here is a consolidated list of the easiest pitfalls, for self-checking:

    • Looking only at the price table. Cache writes, long-context surcharges, thinking tokens, and the like are often not on the price table;
    • Ignoring cache write costs. When prefixes change frequently, write fees may cancel out all the savings from hits;
    • Overlooking thinking tokens. With reasoning mode on, the output contains many invisible thinking tokens, billed at the output price;
    • Using free quotas as a budget baseline. Once the quota is exhausted, the cost structure suddenly changes;
    • Treating subscriptions as “more is always cheaper.” When usage is insufficient, the fixed fee is pure loss;
    • Crossing regions to save money. This ignores latency, egress traffic, and compliance costs;
    • Deep coupling to a single model. Migration costs are high at model generations;
    • Comparing without a unified basis. Mixing tax-inclusive and tax-exclusive figures, different regions, and different currencies in a comparison — the conclusions are often distorted.

    Conclusion

    “Same unit price, bill differs by half” is not mysterious. It reminds us that LLM API cost optimization is essentially a “structural” problem, not a “pricing” problem. What truly determines the bill is your design ability in three things:

    • organizing tokens to be more cacheable;
    • arranging tasks to be more delayable;
    • matching plans to fit usage more closely.

    The recommended order to proceed:

    1. unify the basis;
    2. decompose usage;
    3. check the rules;
    4. model and estimate;
    5. validate on a small traffic share;
    6. roll out to full traffic.

    This method depends on no specific platform. Whichever cloud provider’s model service you ultimately choose, you can use the same framework to calculate costs clearly and make trade-offs.