LLM API Pricing Increases: Cost Logic and Model Selection

    This article breaks down why newer large model APIs cost more, how input, output, and cache-hit tokens map to different resource costs, and why subscription quotas can feel different from list prices. It then outlines practical cost-control methods for coding agents—stable prefixes, layered context, output constraints, observability, and routing—and explains how to compare models by total cost per task rather than per-token price.

    1. The Trend: A Broad Shift Upward in Model Service Pricing

    The industry has recently seen a round of model service price adjustments: a new generation of general-purpose large models now charges several times more than the previous generation, with output reaching the order of a hundred yuan per million tokens and input around twenty yuan, while cache-hit tokens remain at roughly one yuan. This combination is not an isolated event but the result of tight compute supply, a changing inference workload mix, and product tiering strategies.

    For developers, the real concern is not the absolute numbers but three structural questions: how call patterns should change once the price gap between billing items widens; where the perceived difference between subscription quotas and pay-as-you-go billing comes from; and how to turn cost from an “uncontrollable variable” into an “estimable engineering metric” during periods of continuous price fluctuation.

    2. Breaking Down the Billing Structure: Three Prices, Three Resource Costs

    Model service billing is usually split into input tokens, output tokens, and cache-hit tokens, and the pricing differences reflect real differences in resource consumption.

    • Input side: requires a full forward pass over the entire context, and cost grows linearly with context length, making long-context scenarios especially sensitive.
    • Output side: uses autoregressive token-by-token generation, where intermediate states must be repeatedly read and written, so unit cost is significantly higher than input. This is the fundamental reason output prices are typically several times input prices.
    • Cache-hit side: when a request prefix matches already-cached content, the repeated prefix computation can be skipped, leaving only storage and hit-validation overhead, so the price can be a fraction of the input price.

    This yields the first practical conclusion: the price gap between output and input means that “making the model write less and read more” is not necessarily cost-effective. The real high-leverage move is to raise the cache hit rate and compress useless context.

    A schematic cost estimation logic can be written as:

    1. def estimate_cost(in_tokens, out_tokens, cached_tokens,
    2. p_in=20.0, p_out=100.0, p_cache=1.0):
    3. # Prices are in yuan per million tokens
    4. fresh_in = max(in_tokens - cached_tokens, 0)
    5. return (fresh_in * p_in + out_tokens * p_out
    6. + cached_tokens * p_cache) / 1_000_000

    The point of this code is to turn a vague sense of “expensive” into a verifiable billing model: once you measure the actual distribution of the three token types, cost moves from guesswork to an optimizable target.

    3. Why the “Suggested Retail Price” Diverges from Real Experience

    A key observation is that the public list price is closer to a suggested retail price, while the real experience of subscription users is determined by quota design. The mechanism can be summarized in four points.

    First, how the quota pool is divided. When conversational usage and agentic coding usage are placed in separate quota pools, the total actually available to a user within the same cycle is split, and heavy use on either side hits the ceiling early, creating the impression of “the unit price is not high, but it runs out fast.”

    Second, the quota reset cadence. If cycle quotas are reset more frequently or temporarily relaxed, the short-term increase in supply lowers the perceived marginal cost per unit time, further decoupling the list price from actual spending.

    Third, workload structure differences. Agentic coding scenarios feature long contexts, multi-turn tool calls, and frequent retries, with input tokens making up a far higher share than ordinary question answering, and the repeated computation on the input side is precisely the main source of cost.

    Fourth, hidden loss when caching does not take effect. In multi-turn sessions, if the prefix is unstable—for example, injecting a timestamp, a random identifier, or changing retrieval results each turn—the cache cannot hit, and the entire context is billed as fresh input.

    4. Cost Governance Methods for Agentic Coding Scenarios

    4.1 Stabilize the Prefix to Maximize Cache Reuse

    Putting invariant content first and variable content last is the most effective way to raise the cache hit rate. System prompts, tool definitions, and code conventions should keep a fixed order and wording, while dynamic information is placed uniformly at the end.

    1. [Fixed] System role and conventions → tool list → project conventions
    2. [Semi-fixed] Repository structure summary
    3. [Variable] Current retrieval snippets, timestamps, user input

    4.2 Layered Context and On-Demand Loading

    Do not inject the entire repository at once. A three-layer structure of “summary layer + retrieval layer + source layer” can be used: the summary layer stays resident, the retrieval layer is recalled per task, and the source layer is expanded only when necessary, keeping input tokens within the range of useful information.

    4.3 Output-Side Constraints

    Since output has the highest unit price, redundancy should be reduced through explicit output contracts: constrain the return structure, require minimal-change patches, and prohibit restating known code. For content that can be generated offline, use batch processing to run off-peak.

    4.4 Build an Observable Cost Dashboard

    It is advisable to bring call logs, token distribution, cache hit rate, and task success rate into a unified monitoring and alerting system, combined with general cloud capabilities such as log services and monitoring alerts for long-term retention and trend analysis, so cost anomalies can be detected within hours.

    1. Metrics: fresh_input_ratio / cache_hit_ratio / output_per_task / retry_rate
    2. Alerts: cache_hit_ratio drops 30% period-over-period or retry_rate exceeds threshold

    4.5 Routing and Fallback Strategies

    Route by task difficulty: simple completions go to a lightweight model, complex refactoring goes to a more capable model; when the primary channel’s quota is tight, fall back or queue automatically to avoid repeated consumption caused by task failures.

    5. Selection Advice: Shift from Unit-Price Comparison to Total-Cost Comparison

    During a period of rising prices, the comparison dimension should shift from “price per million tokens” to “total cost to complete a unit of work,” that is, total cost = tokens consumed per task × unit price × retry factor. The retry factor is often overlooked, yet it is frequently the main source of the gap. In engineering practice, four things can be examined first: whether the caching mechanism is stable and predictable, whether the quota pool division matches the actual workload, whether fine-grained usage observability is supported, and whether a stable fallback path exists.

    At the architecture level, keeping the model access layer abstract and replaceable, and consolidating prompt templates, token accounting, and routing policies behind a unified gateway, can make price fluctuations affect only configuration rather than business code. General capabilities that Baidu AI Cloud provides in model services and engineering governance, such as unified access, usage monitoring, and containerized deployment, can serve as a reference direction for building this kind of cost-controllable architecture.

    6. Conclusion

    A several-fold price increase is essentially a making-explicit of a cost signal: it puts resource consumption that was previously masked by subscription quotas back onto the bill. For developers, the response is not to wait for prices to fall but to turn cache hit rate, context efficiency, and retry rate into engineering metrics that can be continuously optimized. When cost is observable, attributable, and optimizable, fluctuations in model prices become an ordinary parameter in capacity planning rather than a risk.