LLM API Cost Accounting and Optimization After a Price Cut

    Lower standard pricing for LLM APIs changes the budget baseline after discounts end, but it does not necessarily reduce the next invoice. This article explains how to compare savings against the original standard price and against the prior actual bill, calculate inference cost across cache-hit input, cache-miss input, and output, and separate price effects from usage growth. It also covers cache optimization, output constraints, long-conversation management, monitoring, and reconciliation during pricing changes. The goal is to use cost per successful task and verifiable usage data to decide whether savings should fund broader coverage, higher answer quality, or lower operating spend.

    1. Establish the Comparison Baseline: A Standard Price Cut Does Not Necessarily Reduce the Month-over-Month Bill

    When an LLM API moves from a limited-time discount to a lower standard rate, what changes is the budget baseline after the discount ends, not necessarily the actual amount paid before and after the adjustment. Suppose the standard rate is reduced to one quarter of its previous level. If the same level of temporary discount was in effect before the adjustment, and the billing basis and usage are identical, the bills for the old and new periods can be the same. What actually falls is the spend that would otherwise have resumed when the discount expired.

    Therefore, when evaluating the benefit of a price cut, keep two baselines:

    • Savings relative to the original standard price, used to measure the effect of the price adjustment.
    • Change relative to the previous actual payment, used to explain the current bill.

    These baselines answer different questions. Mixing them can lead to treating traffic growth, longer outputs, or fluctuations in cache hit rate as an abnormal price change.

    In addition, the standard rate does not mean that every project, contract, and billing cycle gets the same price. Before putting a budget into practice, verify the actual unit price of each billing item, effective time, contract terms, and billing attribution rules. If a price change occurs midway through a billing cycle, calculate charges in segments based on the actual billed time and applicable rate. Do not recalculate the whole month’s requests at the month-end rate.

    2. Separate Three Usage Categories and Calculate Each Cost

    If the service bills cache-hit input, cache-miss input, and output separately, estimate inference cost with the following formula:

    Inference cost = (cache-hit input tokens × cache-hit input unit price + cache-miss input tokens × cache-miss input unit price + output tokens × output unit price) ÷ 1,000,000

    Usage is measured in tokens, and unit prices are in CNY per 1 million tokens. This formula covers only the three types of inference cost listed above. Taxes, other billing items, and discount deductions should be handled separately according to the actual bill. If the bill already reports cache-hit and cache-miss usage, use those values directly. Do not first charge all total input as cache-miss and then add a separate cache-hit charge.

    The following example uses hypothetical prices solely to demonstrate the calculation and does not represent any service’s quotation. Assume that, before the adjustment, the three unit prices are CNY 0.4, CNY 8, and CNY 16 per 1 million tokens, respectively, and that after the adjustment all three are reduced to one quarter of those values. An application has 60 million total input tokens in a month, of which 45 million hit the cache and 15 million miss; it also produces 10 million output tokens. At the original prices, the three costs are CNY 18, CNY 120, and CNY 160, for a total of CNY 298. At the adjusted prices, they are CNY 4.5, CNY 30, and CNY 40, for a total of CNY 74.5.

    This example shows that cost optimization should consider the cost contribution of each category, not token volume alone. Although output accounts for only 10 million tokens, it represents more than half of the adjusted inference cost. All else being equal, reducing output by 2 million tokens saves CNY 8; moving 2 million input tokens from cache-miss to cache-hit saves CNY 3.8. The two actions differ in difficulty and quality risk, so whether to prioritize them still requires business evaluation.

    3. Forecast Unit Price Changes and Usage Changes Separately

    When preparing a budget, start with a business task: first estimate the number of tasks, then estimate the average number of model calls triggered by each task, and finally calculate cost from the cache-hit input, cache-miss input, and output of each call. A single request has an easy-to-check price, but one task may involve multiple calls such as retrieval then generation, result validation, and failure retries. Multiplying the number of user requests by the first-call cost usually does not fully reflect expenditure.

    Model each business type separately. For example, batch classification often has short outputs and high call volume; document question answering may carry long materials; and multi-turn assistants tend to accumulate context as the conversation progresses. Even if these three scenarios use the same rates, the sources of budget variance are different. In addition to the normal budget, simulate traffic scaling, a drop in cache hit rate, and longer outputs separately, and define the conditions that trigger alerts or rate limiting.

    Even if all three unit prices fall to one quarter of their original levels, inference cost will fall to one quarter only when the usage mix remains unchanged. Continuing the previous example, if usage in every category grows fourfold, the new inference cost returns to the original-price total of CNY 298. If growth is concentrated in higher-priced output, the budget may be exhausted sooner. Scaling decisions should therefore be based on the cost per successful task and expected business benefit, not on the discount percentage alone.

    4. Cache Optimization: Trade Stable Prefixes for Verifiable Savings

    If the service supports cache reuse based on an input prefix, check which parts of the request are stable over time, such as system instructions, output specifications, and fixed examples. Then organize reusable content into a stable prefix according to the service’s published matching requirements, and place changing questions, timestamps, and temporary retrieval results later. For template changes, record versions and observe cache-hit usage before and after rollout to avoid meaningless formatting changes that reduce the hit rate.

    Calculate cache hit rate by token usage where possible, rather than simply counting how many requests had a hit. Even if a request reuses fixed instructions, a large document that follows may still be billed as cache-miss input. Counting such a request as a hit is not wrong, but it does not directly allow you to infer the savings amount. For the same input scale, multiply the number of tokens moved from cache-miss to cache-hit by the difference between the two unit prices, then convert using 1 million tokens, to estimate the benefit of cache optimization.

    Do not retain irrelevant context just to improve the hit rate. If a piece of material does not help the answer, removing it may cost less than continuing to reuse it and may also reduce opportunities for the model to be distracted. When different user permissions or tenant data are involved, first ensure that context and application-side caches meet isolation requirements. Reuse must not cross access boundaries.

    5. Output Optimization: Lower the Total Cost of Completing the Task, Not Every Response

    Output constraints should first come from business goals. A classification task can require the category and a brief rationale; information extraction can return only the fields needed downstream and clearly specify how missing information is represented; complex user-facing explanations should retain enough length to avoid omitting key steps or limitations. Use an output length limit as a fallback only when supported by the service and permitted by the business, and monitor truncation and the retries it causes.

    When evaluating optimization results, compare output length, task success rate, retry rate, and manual revision volume before and after the change. A shorter single output does not necessarily lower total cost. If results frequently lack fields, the business may have to resend long inputs, and the saved output cost may be offset by extra calls. For automated workflows, the core metric can be the average inference cost of successfully completing one task, with the cost of failed, retried, and fallback calls included in the numerator, so that it becomes clear whether a design truly saves money.

    Long conversations should also be managed. Retain the key facts, constraints, and to-do items for the current task, and retrieve earlier history as needed, rather than resending the full record on every turn. If model-generated summaries are used, include both the cost of summarizing and the risk of information loss in the evaluation. For key facts such as order identifiers and constraints explicitly provided by the user, prefer structured state over relying entirely on summaries.

    6. Turn the Budget into an Executable Constraint with Monitoring and Reconciliation

    On the application side, record the three actual billed usage categories by business, environment, and task type, while associating request time, pricing version, task status, and retry count. For services that provide only aggregate totals and no detail, clearly document the estimation limits. Do not treat an inferred cache volume as a billing fact. Cost analysis usually needs only counters and necessary correlation identifiers; complete sensitive inputs or outputs should not be retained long-term just for reconciliation.

    Monitoring can have two layers. The first tracks cumulative spend and projected month-end spend to identify budget risk. The second tracks cost per task, cache-miss input share, output length, and retry rate to locate anomalies. For example, if total spend rises but cost per task is stable, check business volume first. If task volume is stable but cost per task rises, check recent template revisions, context bloat, failed output constraints, or increased retries.

    During a price switch, select representative requests from before and after the switch, reconcile a small sample using actual usage and applicable unit prices, and then compare it with the summary bill. If there are differences, first check billing time, usage classification, rounding, deductions, and retry records. Avoid concluding that the bill is wrong based solely on application logs. Once the billing basis has been reconciled, update budget thresholds and scaling plans.

    An API price cut provides an opportunity to reallocate budget, but durable savings come from understanding usage. Measure price, usage, and task success rate separately, then optimize the most expensive part of the workflow. Only then can you decide whether the saved budget is best used to expand coverage, improve answer quality, or directly reduce operating expenses.