Understanding the Cost Logic Behind Large Model API Price Increases

    This article breaks down why a recent large model API price adjustment raised output token costs far more than cached input, and what that means for your bill. It explains the three-tier token pricing model, the two key ratios that drive cost, and the physical reasons output is the most expensive tier while cache hits are the cheapest. You will find a cost formula for estimating your own spending, four practical optimization techniques, and guidance on evaluating models by total cost rather than sticker price.

    1. The Trigger: A Price Change That Forced a Cost Reassessment

    A recent generation of an AI coding tool’s model adjusted its billing: output pricing is roughly four times the previous generation, uncached input is about three times, while the cache-hit tier rose more modestly. The end result lands around 100 RMB per million output tokens, 20 RMB per million input tokens, and 1 RMB per million cache-hit tokens.

    These numbers drew attention not because of the increase itself, but because they changed the proportions within the cost structure. To understand why, you first need to break the bill apart.

    2. The Breakdown: Three Pricing Tiers and Two Key Ratios

    Mainstream large model APIs typically bill tokens across three tiers:

    • Input (cache miss): full prefill, the heaviest compute load;
    • Input (cache hit): the prefix KV cache is reused, so only the new portion is processed;
    • Output: token-by-token autoregressive decoding, which cannot be parallelized.

    The two ratio shifts observed in the original are the real story:

    Metric Previous Gen New Gen Meaning
    Uncached input / cached input ~6x ~10x The value of caching is amplified
    Output / cached input ~25x ~50x Output becomes the absolute cost center

    The conclusion is clear: the cache-hit tier rose modestly, while the output tier rose the sharpest. This shifts the focus of cost optimization from “compressing context” to “controlling output length + improving cache hit rate.”

    3. The Cause: Why Output Is the Most Expensive and Cache the Cheapest

    From a computational standpoint, the price differences across the three tiers have a clear physical basis:

    1. The output stage is serial. Each new token depends on prior results and cannot be parallelized like prefill, so per-token compute utilization is low, making it the most expensive.
    2. Uncached input requires fully recomputing attention keys and values, a high-throughput, parallelizable workload, so its unit price is significantly lower than output.
    3. A cache hit skips most of the prefill and only bears storage and scheduling overhead, making it the cheapest.

    When a new generation pushes the output-to-cache-hit ratio from 25x to 50x, it is effectively using price signals to steer callers: do not treat the model as an infinite “text generator,” and instead reuse prefixes as much as possible.

    4. Modeling: Use a Formula to See Where Your Bill Is Heading

    Let uncached input be $a$, cached input $b$, and output $c$ (in RMB per million tokens), and define:

    • Cache hit rate $h = \frac{\text{cached input}}{\text{total input}}$
    • Output-to-input ratio $r = \frac{\text{output tokens}}{\text{input tokens}}$

    Then the blended cost per million input tokens is:

    1. Cost = (1 - h) * a + h * b + r * c

    Plugging in both generations’ prices (a=6.5/20, b=1.1/2, c=27/100) for a sensitivity analysis yields three patterns:

    • When $r$ is large (generation-heavy workloads like code completion or long-form generation), total cost is dominated by $c$, and the price increase is felt most strongly;
    • When $h$ approaches 1 (fixed system prompts, repeated Q&A over long documents), the modest rise in $b$ significantly offsets the overall increase;
    • When $h$ is very low and $r$ is moderate (scattered multi-turn conversations), costs rise the most, because both unfavorable factors stack.

    5. Optimization: Four Actionable Cost Control Techniques

    1. Stabilize the prefix. Put the system prompt, tool definitions, and examples first and keep them byte-for-byte unchanged; avoid volatile fields like timestamps or random IDs that pollute the prefix. This is the prerequisite for raising $h$.
    2. Structure for reuse. Split long documents and code-base context into stable blocks, organized in call order, so adjacent requests share as long a common prefix as possible.
    3. Constrain output. Replace “be as detailed as possible” with explicit format and length constraints to cut wasted decoding; for enumerable results, prefer structured output over free text.
    4. Layer your routing. Send simple tasks to smaller models or a rules engine, and escalate to large models only for complex tasks, avoiding high-unit-price tiers for low-value requests.

    Illustrative wrapper:

    1. def estimate_cost(input_tokens, hit_ratio, out_ratio, price):
    2. a, b, c = price # uncached input, cached input, output
    3. hit = input_tokens * hit_ratio
    4. miss = input_tokens - hit
    5. out = input_tokens * out_ratio
    6. return (miss * a + hit * b + out * c) / 1_000_000

    6. Selection Advice: Put Price Back Inside Total Cost

    Unit price is only one variable. When evaluating, also weigh the task’s real need for output length, how reusable the context is, the stability of the caching mechanism and how cache hits are billed, and whether monitoring, alerting, and logging services provide token-level usage observability. In general engineering practice on platforms such as Baidu AI Cloud, the usual recommendation is to first run a small-traffic canary to measure the real $h$ and $r$, then plan capacity and budget accordingly, rather than extrapolating directly from the sticker price.

    7. Conclusion

    The essence of this price adjustment is making the underlying fact explicit: output compute is expensive, while prefix reuse is cheap. For developers, rather than debating the size of the increase, it is better to continuously measure cache hit rate and output-to-input ratio as two core engineering metrics—they determine which segment of the cost curve you ultimately land on.