Understanding LLM API Pricing Adjustments: Tiered Billing and Cost Estimation

    This article explores how to evaluate LLM API price adjustments by breaking down tiered billing structures. It explains the cost implications of cache misses, cache hits, and output tokens, and provides methods and code examples for estimating API costs. Additionally, it offers actionable strategies to optimize API usage across different business scenarios.

    1. Look at the Tiers, Not Just a Single Price

    LLM APIs are typically billed by token. A token is the basic unit of text processing; one Chinese character usually corresponds to one or two tokens, depending on the model. Most service providers break down pricing into several tiers:

    1. Input (Cache Miss): The newly submitted context in a request that requires full computation.
    2. Input (Cache Hit): The part of the request that shares a prefix with recent requests and can reuse previously computed results.
    3. Output: The content generated by the model token by token.

    Looking only at a “price per million tokens” often leads to one-sided conclusions. A price adjustment might only affect one tier, or the adjustment magnitude might vary significantly across tiers. To determine whether an adjustment is reasonable, you must first examine the price of each tier individually, then analyze the ratio between them.

    2. What Do the Three Tiers Reflect in Terms of Cost?

    2.1 Input (Cache Miss)

    The cost of a cache miss primarily comes from the model performing a full forward pass on new text. The longer the context, the greater the computational load. The price for this tier typically reflects base compute costs and is the most directly tied to “improvements in model capabilities.”

    2.2 Input (Cache Hit)

    A cache hit occurs when the server finds an identical prefix to a historical request and reuses the previously calculated intermediate results. This skips redundant computation, so the pricing is usually significantly lower than a cache miss. The cache hit price may also be influenced by storage duration and cache eviction policies. Refer to the specific rules published by each service provider.

    2.3 Output

    When generating output, the model produces tokens sequentially. Each generated token requires a full forward pass, and because subsequent tokens depend on previous ones, the process is difficult to parallelize. Therefore, the output unit price is usually higher than the input price. For most providers, the output price is several times that of an input cache miss. The longer the output, the more noticeable the cost increase.

    3. Understanding Price Adjustments Through Ratios

    To evaluate the magnitude of a price adjustment, it is recommended to look at two metrics simultaneously:

    • Absolute Increase: How much the unit price for each tier changed and the percentage increase.
    • Relative Ratio: The multiplier relationship between tiers, such as “how many times the output price is compared to the cache hit price.”

    The absolute increase reflects the direct impact on your budget. The change in ratio reflects the direction of the billing structure adjustment. If all tiers increase by the same proportion, the ratio remains unchanged, indicating only a general price level shift. If some tiers increase significantly more than others, the ratio widens, altering the cost structure.

    The following uses fictitious numbers to demonstrate this. These prices are only for calculation examples and do not represent any real product’s pricing.

    Assume a model’s original pricing is: Input (Cache Miss) $8 per million tokens, Cache Hit $1 per million tokens, Output $32 per million tokens. A request contains 100,000 input tokens, of which 80,000 hit the cache and 20,000 miss, with 5,000 output tokens.

    • Miss portion: 20,000 × 8 / 1,000,000 = $0.16
    • Hit portion: 80,000 × 1 / 1,000,000 = $0.08
    • Output portion: 5,000 × 32 / 1,000,000 = $0.16
    • Total: $0.40

    If there were no cache hits, all 100,000 input tokens would be priced as cache misses, making the input cost $0.80. The cache effectively halves this cost.

    Assume that after a price adjustment, the cache miss price rises to $16, output rises to $64, and the cache hit price remains $1. The cost for the same request becomes:

    • Miss portion: 20,000 × 16 / 1,000,000 = $0.32
    • Hit portion: $0.08
    • Output portion: 5,000 × 64 / 1,000,000 = $0.32
    • Total: $0.72

    In this example, the doubling of the output price has the most significant impact on total cost because output accounts for the highest proportion of the overall fee. The cache hit price remains unchanged, so its proportion of the total cost is compressed. This illustrates that the same price increase, when applied to different tiers, affects different businesses in entirely different ways.

    4. Generic Code Example for Cost Estimation

    The following function can be used to evaluate the cost of a single call or to estimate monthly business expenses in batches.

    1. def estimate_cost(miss_tokens: int, hit_tokens: int, output_tokens: int, price: dict) -> float:
    2. """
    3. Calculate the cost of a single call (unit: USD).
    4. price is the unit price per million tokens, containing miss, hit, and output keys.
    5. """
    6. cost = (
    7. miss_tokens * price["miss"]
    8. + hit_tokens * price["hit"]
    9. + output_tokens * price["output"]
    10. ) / 1_000_000
    11. return cost
    12. old_price = {"miss": 8, "hit": 1, "output": 32}
    13. new_price = {"miss": 16, "hit": 1, "output": 64}
    14. usage = {"miss_tokens": 20_000, "hit_tokens": 80_000, "output_tokens": 5_000}
    15. print(f"Single call cost at old price: ${estimate_cost(**usage, price=old_price):.2f}")
    16. print(f"Single call cost at new price: ${estimate_cost(**usage, price=new_price):.2f}")

    In practice, you should read the number of cache miss inputs, cache hit inputs, and output tokens from the usage fields returned by the server, rather than estimating the split ratio yourself. Most APIs provide these statistics in their responses; refer to the corresponding service documentation for specific field names.

    5. Impact on Different Business Scenarios

    Different scenarios rely on different tiers to varying degrees, and thus are affected by price adjustments differently.

    Long-text generation and code generation: These scenarios involve many output tokens, so changes in output unit price directly determine costs. If the output price increases significantly, prioritize compressing output length or routing some tasks to cheaper models.

    Multi-turn dialogue and fixed prompt scenarios: Each request carries the same system prompt and conversation history. The prefix is stable, resulting in a high cache hit rate. Changes to the cache hit price significantly impact these scenarios.

    Retrieval-Augmented Generation (RAG) and document QA: Retrieved document chunks are often long and the same document may be queried multiple times. If the prefix of the same document can be kept stable, the caching benefits will be substantial.

    One-time, short input, short output tasks: These tasks inherently cost less. Tiered price changes have a limited impact on total expenses; focus mainly on the volume of calls.

    6. Actionable Optimization Strategies

    6.1 Maintain a Stable Prompt Prefix

    Caching relies on prefix matching. Place unchanging content—such as system instructions, role settings, and fixed examples—at the very beginning of the request, and put variable user inputs at the end. Avoid inserting timestamps, random IDs, or other fields that change every time within the fixed content, as this will break the prefix and lower the cache hit rate.

    6.2 Control Output Length

    Set a reasonable maximum output token limit in the request and explicitly demand brevity in the prompt. For tasks requiring structured results, prioritize requesting compact formats like JSON, preventing the model from generating large blocks of explanatory text.

    6.3 Tiered Routing

    Not all tasks require the most powerful model. Classify tasks first: send simple classification, extraction, or rewriting tasks to lower-priced models, and reserve complex reasoning for high-priced models. Routing rules should be validated through offline evaluation to ensure quality requirements are met.

    6.4 Batch and Asynchronous Processing

    For tasks that do not require real-time responses, combine them into batch requests or use asynchronous queues. This reduces request peaks and makes it easier to control concurrency and retry costs.

    6.5 Establish Usage Monitoring

    It is recommended to log the number of cache miss inputs, cache hit inputs, and output tokens, along with the corresponding costs, for every call, aggregated by business line, functional module, and model version. If the proportion of a certain tier suddenly spikes, you can promptly identify cost issues caused by prompt modifications or business logic changes.

    7. How to Evaluate if a Price Adjustment is Reasonable

    When evaluating an adjustment, the unit price alone is insufficient to draw a conclusion. It is recommended to judge comprehensively from the following dimensions:

    • Unit Task Cost: Calculate the average cost of completing a business unit (e.g., a single Q&A, a report) and compare the changes before and after the adjustment.
    • Quality and Completion Rate: If the new version shows clear improvements in accuracy, stability, or task completion rate, a cost increase might be acceptable. If quality is unchanged, you need to reassess whether to continue using it.
    • Alternative Solutions: Consider the cost and capability differences of other providers, self-hosted deployments, or different model specifications, but base your selection on actual evaluation results.
    • Structural Changes: If the price adjustment is primarily concentrated on output or a specific tier, you should adjust how your business makes API calls rather than simply accepting or abandoning the model.

    8. Summary

    LLM API billing typically consists of three parts: input cache miss, input cache hit, and output. The key to evaluating a price adjustment is examining the absolute increase of each tier and the ratio changes between them, then estimating the real impact based on your business’s input-output structure. By stabilizing prefixes, controlling output, implementing tiered routing, and maintaining continuous monitoring, most teams can effectively control API costs without significantly sacrificing quality.