How to Calculate LLM API Costs When Prices Increase 5x

    This article breaks down how a 5x increase in LLM API pricing affects real monthly bills. It explains the four token categories used in billing, two key pricing asymmetries, and the concept of usage leverage that determines the actual cost of accessing model capability. It then outlines five engineering techniques—prefix stabilization, context trimming, output budget constraints, tiered routing, and observability—to reduce cost per task, along with a vendor evaluation checklist covering capability, cost, leverage, migration, and compliance.

    1. The Starting Point: Unit Prices Rose, but Bills Do Not Scale Linearly

    A recent topic of broad discussion is that a new-generation large model’s public pricing is roughly five times higher than the previous generation: output is on the order of 100 RMB per million tokens, input around 20 RMB, and cache-hit input only around 1 RMB. The discussion easily slides into a “is it expensive or not” argument, but for developers, three more engineering-oriented questions need to be answered:

    1. How does a unit price change propagate to the monthly bill;
    2. Why the actual consumption of different models on the same task varies enormously;
    3. When price is not an advantage, how to use engineering means to drive down the cost per task.

    Once these three points are clear, “expensive” and “cheap” are no longer labels but calculable, optimizable variables.

    2. Breaking Down the Billing Structure: Four Token Categories and Two Asymmetries

    Billing for mainstream large model services usually falls into four token categories: input (prompt), output (completion), cache-hit input, and, in some scenarios, batch or offline invocation discounts. Understanding pricing requires grasping two asymmetries:

    • Input-output asymmetry: The output unit price is generally several times the input. This means tasks that generate long text, long chains of thought, or long code completions naturally cost more than long-document summarization tasks.
    • Cache vs. non-cache asymmetry: The cache-hit unit price can be as low as a few percent of the non-cached input. Once stable content such as system prompts, tool definitions, few-shot examples, and long document prefixes hits the cache, the marginal cost is almost negligible.

    A schematic cost formula is as follows:

    1. cost per call = input tokens × P_in × (1 - h)
    2. + input tokens × P_cache × h
    3. + output tokens × P_out
    4. where h is the cache hit rate, and P_cache is usually far smaller than P_in

    This formula explains the core confusion in the original discussion: when average consumption per task is similar, the party with the higher unit price necessarily has a higher bill; and when cache hit rates and context reuse strategies differ, the bill gap is further widened or narrowed.

    3. The Amplification Mechanism of Bills: The Multiplier Is Not Price, but a “Usage Lever”

    Converting a subscription plan into “the ratio of nominal quota to plan price” reveals an overlooked metric—the usage lever:

    1. lever multiplier ≈ consumable quota within the plan / plan price

    Mature solutions in the industry often push this multiplier above 20x, meaning a $20 tier can support hundreds of dollars’ worth of calls, and a $200 tier can support five-figure dollar amounts of calls. If a solution’s lever multiplier is significantly lower than that of same-generation competitors, the real experience for heavy users will still be on the expensive side even if the absolute price does not look high. This is the typical cause of “leading on benchmarks but lagging on cost-effectiveness”: benchmarks measure the upper limit of capability, while the lever measures the cost of acquiring a unit of capability.

    4. Bringing Costs Back Under Control: Five Engineering Techniques

    1. Prefix stabilization: Fix the system prompt, tool schema, and knowledge base snippets at the very front of the request to maximize cache hits; place variable content at the end.
    2. Context trimming: In retrieval-augmented scenarios, control the number of recalled items and snippet length, using reranking instead of brute-force stuffing; summarize and compress historical conversations rather than replaying them in full.
    3. Output budget constraints: Explicitly set maximum output length and structured output constraints to avoid the model consuming tokens on irrelevant branches.
    4. Tiered routing: Hand simple intent classification and format conversion to small-parameter models or rule engines, and escalate to the large model only for complex reasoning, forming a cost gradient.
    5. Observability first: Integrate logging services and monitoring alerts, tag and measure token consumption, cache hit rate, and cost per task by business dimension, so optimization has a data basis.
    1. # Pseudocode: a call skeleton with a cache-friendly prefix and budget control
    2. def call_model(user_msg, budget_out=800):
    3. prefix = STATIC_SYSTEM + TOOL_SCHEMA + KB_SNIPPET # stable prefix, helps cache hits
    4. resp = client.chat(
    5. messages=[{"role": "system", "content": prefix},
    6. {"role": "user", "content": user_msg}],
    7. max_tokens=budget_out,
    8. )
    9. metrics.record(tokens_in=resp.usage.prompt_tokens,
    10. tokens_out=resp.usage.completion_tokens,
    11. cached=resp.usage.get("cached_tokens", 0))
    12. return resp.text

    5. Selection Evaluation Checklist: Turning “Expensive for a Reason” into a Verifiable Conclusion

    • Capability dimension: task success rate on your own evaluation set, not public leaderboard rankings;
    • Cost dimension: average consumption per task × unit price, further adjusted by the cache hit rate;
    • Leverage dimension: the ratio of plan quota to price, and whether it matches the team’s call intensity;
    • Migration dimension: whether the interface abstraction layer is in place, avoiding lock-in to a single vendor;
    • Compliance dimension: whether data residency, audit logs, and content safety policies meet requirements.

    For multi-cloud or hybrid deployment, you can use a container platform to unify the inference gateway, use object storage to accumulate evaluation corpora, and perform cross-vendor cost reconciliation through a unified logging and monitoring system.

    6. Conclusion

    A fivefold price increase is itself only a signal; what truly determines product strength is the two variables of “cost per task” and “usage lever”. Developers should treat pricing as an optimizable input: improve cache hits through prefix stabilization, compress wasted consumption with tiered routing and output budgets, and continuously calibrate with an observability system. Once these are done, looking back at whether the subscription tier design is reasonable—for example, whether the low tier can support usage on the order of thousands of RMB and the high tier usage on the order of tens of thousands of RMB—makes it possible to judge whether a solution has the cost foundation to compete head-on with external options. If an enterprise wants to build this cost-controllable invocation system on its own cloud, the general capabilities provided by Baidu AI Cloud, such as the container platform, logging service, and monitoring alerts, can serve as the implementation foundation.