Qwen Code Switched Its Base Model and Raised API Prices 5x: How to Calculate the Real Billing Cost

    When a coding-model provider switches its base model and raises prices—output tokens now cost 5x more—the headline number is only part of the story. This article breaks down why LLM inference is billed across three tiers (input, cache hit, and output), what their price ratios signal about where cost pressure concentrates, and why the same price change hits different workloads unevenly. It compares pay-as-you-go, subscription-quota, and reserved-throughput billing, provides a token-based cost estimation method with sample code, and lays out five engineering levers—cache-friendly prompts, context control, output control, tiered model routing, and cost observability—for keeping spend in check.

    One price change, three cost signals

    Recently, a domestic LLM provider adjusted the pricing of its coding model. Before the change, the pricing page listed Qwen Code output at CNY 20 per million tokens, input at CNY 4, and cache hits at CNY 0.4. After the change, output rose to CNY 100, input to CNY 20, and cache hits to CNY 1. The output unit price is 5x the original, yet the change in actual call cost is usually smaller than 5x.

    This adjustment drew attention because it exposes the part of the LLM cost structure that is most often overlooked. The nominal unit price is only the “price list” on the bill; what truly determines spending is the billing dimensions and how they are distributed across your specific workload.

    Another point worth noting from the discussion: some domestic providers, constrained by limited compute supply, tend to be less generous with coding subscription quotas than leading overseas providers. This makes subscription-tier API pricing feel more like a “suggested retail price.” Once a developer switches to a subscription and consumes against the quota, the perceived gap narrows considerably. This observation captures the essential difference between the two billing models, which this article analyzes in detail.

    This article addresses three questions:

    • What does the three-tier billing structure imply economically?
    • Why do different workloads react so differently to the same price change?
    • How should teams contain cost at both the architecture and operations levels?

    Note: The prices here are used only to demonstrate the calculation method. For actual billing rules, refer to the provider’s official documentation.

    Cost structure: why input, output, and cache are priced separately

    Two phases, two hardware bottlenecks

    A single LLM inference typically has two phases:

    • Prefill: The model processes all input tokens in parallel and builds the key-value cache needed for attention. This is a compute-intensive workload, so compute is the main constraint.
    • Decode: The model generates output tokens one at a time, re-reading all weights and the existing cache for each token. This is a memory-bandwidth-intensive workload; per-token compute demand is low but hard to parallelize.

    As a result, the service cost per output token is usually higher than per input token at equal counts, which is why mainstream providers price output higher than input. After this adjustment, the output price remains 5x the input price (the ratio stays at about 5:1), indicating that the cost pressure falls mainly on the decode side.

    Cache hits: subsidized compute, encouraged behavior

    Prompt caching works on a simple idea: when the opening segment of a request is identical to a previous request, the model reuses the already-computed key-value cache and skips the repeated prefill computation. The billed price for the hit portion is much lower than ordinary input (1/20 of input after this adjustment), but not zero. There are three reasons:

    • Cache occupies storage resources;
    • It requires retrieval and scheduling;
    • Cache typically has a lifetime, and some of it goes unused.

    Setting the cache unit price far below ordinary input is essentially a price signal encouraging developers to design requests with “reusable prefixes.” In long-context scenarios this benefits both sides: users save money and providers save compute.

    What the price ratios tell us

    Putting the three tiers together:

    Billing item Price after change (CNY per million tokens) Ratio to input price
    Input (cache miss) 20 1×
    Cache hit 1 1/20
    Output 100 5×

    These ratios are more informative than the absolute prices:

    • The value of cache hits is amplified: For the same input, the hit vs. miss unit price differs by 20x. Whether prompts can be reliably reused may be the single biggest cost variable.
    • Output becomes the cost center: Generation-heavy tasks are highly sensitive to output length, making output control more urgent than input compression.
    • Estimate cost with a “blended unit price”: Looking at any single tier easily over- or underestimates the real bill.

    Subscription quota vs. pay-as-you-go: same money, different experience

    Pricing vs. cost: who absorbs the volatility

    The cost of model services is driven mainly by the purchase and occupancy of compute resources, and when compute supply is tight, cost rises quickly with demand. The two models handle this volatility very differently:

    • Pay-as-you-go: Price changes pass through to callers quickly.
    • Subscription plans: Users pay a fixed fee for a quota, so the provider absorbs most of the cost-volatility risk.

    But a fixed fee doesn’t make volatility disappear; adjustments show up elsewhere: total quota size, quota reset frequency, availability during peak hours, and separate quota pools for scenarios like “chat” and “coding.” So the nominal API unit price does not directly represent a subscriber’s real usage cost.

    Two rulers: nominal quota vs. actual output

    Subscriptions are often understood as “buy the quota, use it freely.” But how much actual output a quota delivers depends on:

    • Quota reset cycle: Weekly resets mean different tasks consume the quota unevenly. Routine Q&A and long-context coding tasks can differ by an order of magnitude in consumption.
    • Separate quota pools: If chat and coding are metered separately, one pool being exhausted doesn’t free up the other.
    • Model and feature scope: Whether the plan includes multimodal, long-context, or peak-priority access directly affects value for money.
    • Supply-driven adjustments: When compute is tight, providers may maintain the experience by replenishing quota more often or adjusting rate limits. On the surface this looks like a benefit; in substance it reflects tight supply.

    Some observers note that certain leading overseas providers reset weekly quotas regularly—one provider’s coding tool has reset almost every day over the past week—while chat and coding tools sit in two separate quota pools. Dynamic quota adjustment is therefore not rare, and a subscription’s cost-effectiveness is far from a fixed number.

    Assessing a subscription therefore needs a new ruler: cost per completed task—the quota or fee consumed to finish a standard task. For example:

    • “How much quota does one task consume on average, and how many tasks can I finish in a week?”;
    • “How much is left in the chat pool, and how many more sessions can it support?”

    Only by converting quota back into tasks can you put subscriptions on the same table as pay-as-you-go.

    Comparing three billing models

    Dimension Pure pay-as-you-go Subscription quota Reserved throughput / committed volume
    Cost predictability Low, varies with usage High, fixed spend Fairly high, but committed volume may sit idle
    Impact of price changes Passed through directly Indirect, via quota and rate limits Relatively stable within the contract term
    Response to tight supply Price and rate limiting Quota resets, rate limits Guaranteed, but idle capacity carries risk
    Best fit Volatile usage, validation phase High-frequency use by individuals and small teams Stable, large-scale teams

    Two cautions when comparing:

    • The listed price is not the real cost. The perceived gap closes quickly because subscription quotas cap actual consumption—the same money buys a redefined amount of “effective compute.”
    • Experience is not determined by price alone. Stability, context length, and peak-hour availability matter too, and these are exactly what gets squeezed first when compute is tight.

    A judgment: don’t judge a price change by the “list price”

    One view holds that pricing is essentially a suggested retail price, and a subscriber’s real experience will quickly converge toward the API price. This is reasonable but incomplete. The gap between list price and real cost is ultimately set by three factors:

    • Quota-pool design;
    • Quota reset cadence;
    • Compute available per unit time.

    Looking only at how many times a single unit price rose can either overestimate or underestimate the impact. The right approach is to measure the “real cost of completing the same batch of tasks” before and after the change, using the same method.

    Quantifying it: translating “5x price increase” into your bill

    A cost estimation model

    Let the unit prices of input, cache hit, and output be p_in, p_cache, and p_out, and the per-task consumption be I, C, and O (in tokens). The per-task cost is:

    1. cost = (I - C) × p_in / 1e6 + C × p_cache / 1e6 + O × p_out / 1e6

    Tasks don’t exist in isolation. Coding scenarios are usually multi-turn loops: the model calls tools, reads file or command output, and continues reasoning. Let each task take n rounds on average, with one round consuming (I, C, O):

    1. task_cost = n × cost(I, C, O)
    2. rounds↑ → output per round ↑ → output share ↑ → sensitivity to output price ↑
    1. """Token cost estimator (unit: CNY per million tokens)."""
    2. def estimate_cost(n_input, n_cached, n_output,
    3. price_in=20.0, price_cache=1.0, price_out=100.0):
    4. """Estimate the cost of a single request; n_cached is the portion of input that hit the cache."""
    5. fresh = max(n_input - n_cached, 0)
    6. return (fresh * price_in + n_cached * price_cache
    7. + n_output * price_out) / 1_000_000
    8. def compare(old_prices, new_prices, workload):
    9. """
    10. workload: list of task samples, each with input / cached / output token counts.
    11. Returns total cost and price-change ratio for the whole batch under old vs. new prices.
    12. """
    13. def total(prices):
    14. return sum(
    15. estimate_cost(w["input"], w["cached"], w["output"], **prices)
    16. for w in workload
    17. )
    18. old_total, new_total = total(old_prices), total(new_prices)
    19. return {
    20. "old_cost": round(old_total, 4),
    21. "new_cost": round(new_total, 4),
    22. "ratio": round(new_total / old_total, 2) if old_total else None,
    23. }

    To use it, pass the actual token consumption from your production logs (input, cache hit, and output recorded separately) as the workload, and you get a real price-change ratio tied to your business scale—not the intuition of “5x.”

    Scenario sensitivity: same increase, different impact

    Assume each task averages 8,000 input tokens (6,000 of which hit cache) and 2,000 output tokens, with unit prices in CNY per million tokens:

    Billing item Count (tokens) Before After
    Input (uncached) 2,000 0.008 0.040
    Cache hit 6,000 0.0024 0.006
    Output 2,000 0.040 0.200
    Total per task — 0.0504 0.246
    1,000 tasks/day (monthly) — ~CNY 1,512 ~CNY 7,380

    The output price rose 5x, but total cost rose about 4.9x; if the cache fails entirely, the increase approaches 5x. Whether the cache hits directly sets the floor of the increase.

    Consider two typical workloads:

    • Long input, short output (code review, document understanding, information extraction): low output share, so the increase is diluted.
    • Short input, long output (generating whole files, long proposals): the increase approaches or exceeds the output-side multiplier.

    This generalizes to any price change: cost increase = Σ (each item’s usage share × that item’s price-change multiple). When making technology choices and budgets, quantifying the usage structure first and then assessing the price change is more meaningful than comparing list prices directly.

    Engineering levers: five ways to cut cost

    Cache-friendly prompt design

    Caching usually requires an identical request prefix to hit, and it expires. So structure prompts by “change frequency”:

    1. ┌─ Stable layer: system prompt, tool definitions, coding conventions, KB snippets ─┐ ← reused across sessions
    2. ├─ Semi-stable layer: project structure notes, summaries of files already read ─────┤ ← changes in stages
    3. ├─ Session layer: conversation summaries, edit history from previous turns ──────────┤ ← grows with the task
    4. └─ Volatile layer: current time, latest user input, random request IDs ──────────────┘ ← goes last

    Three companion cautions:

    1. Don’t insert volatile content at the front. Timestamps, random IDs, and request trace IDs appearing at the start destroy the reusability of the whole prefix.
    2. Keep tool definitions and examples stable in order and content. Avoid unrelated changes that invalidate the cache.
    3. Cache has a lifetime. Prolonged inactivity may expire the cache, and the first request after a cold start is billed as a miss, so leave some margin when estimating.

    Context engineering: cutting input-side cost

    • Long context is the main source of prefill cost. Retrieval-augmented generation recalls only the few snippets most relevant to the current task, rather than stuffing the whole codebase or document into the context.
    • Apply rolling summaries to long conversations and documents to compress the “session layer.”
    • Read files in segments as needed; avoid the habit of “reading everything up front to be safe.”

    Output control: the most urgent lever after a price hike

    • Set reasonable output limits to prevent the model from rambling or getting stuck in loops.
    • Use structured output and explicit format constraints to cut unhelpful explanatory content.
    • For edit tasks, output diffs or patches rather than rewriting whole files.
    • Pair streaming output with early termination to cut the model off when it starts to go off track.

    Tiered model routing and gateway abstraction

    Tasks differ greatly in the capability they demand: format conversion, simple classification, and code completion are often fine on a lightweight model; save architecture design and complex refactoring for a stronger model.

    If the business layer depends directly on one model’s SDK, a price change or deprecation can only be accepted passively. Adding a lightweight gateway that decouples “business request—model selection—call—usage accounting” brings three benefits:

    • Tiered routing by task;
    • Fast switching when the primary model is unavailable or prices change;
    • Accumulating comparable evaluation data.
    1. # Illustrative code: routing and accounting in a model gateway
    2. class LLMGateway:
    3. def __init__(self, routes, clients):
    4. # routes: task type -> model name, e.g. {"chat": "light", "refactor": "strong"}
    5. # clients: model name -> concrete client
    6. self.routes, self.clients = routes, clients
    7. def invoke(self, task_type, messages, **params):
    8. model = self.routes[task_type]
    9. result = self.clients[model].chat(messages, **params)
    10. u = result.usage # assume it returns input / cached / output token counts
    11. self._record(task_type, model, u)
    12. return result
    13. def _record(self, task_type, model, u):
    14. # Write the three token counts to logs/monitoring as the data source for cost accounting and alerts
    15. ...

    Cost observability and budget governance

    1. Account by token dimension: Record ordinary input, cache hits, and output tokens separately in logs, and aggregate by project, tenant, and model, so you can locate where cost concentrates.
    2. Set budget alerts: Configure daily/monthly budgets per project and trigger alerts at thresholds.
    3. Watch cache hit rate and average output length: Cache hit rate is the most sensitive leading indicator; once it drops, cost is detected before an outage occurs.
    4. Validate model switches with an evaluation set: When switching or adding a model, first compare quality and cost on a fixed evaluation set, to avoid “saving tokens but adding rework.”

    Operations and selection: locking price volatility in a cage

    1. Treat the “list price” as a variable, not a conclusion. Any model’s price can change. Make unit price a configurable parameter in the cost model, not a magic number scattered in code.
    2. Build a “multi-model + switchable” strategy. Similar to multi-core and SMP ideas in the CPU world, scalability and reliability come from combining and scheduling resources rather than binding to a single supplier. Compare primary and backup models regularly on an evaluation set, and switching cost drops to a minimum.
    3. Measure value for money by cost per completed task. A more capable model that outputs more per call isn’t necessarily more expensive. For example, if a strong model delivers the correct patch in one shot while a weak model needs three rounds of rework, the latter’s total cost may actually be higher.
    4. Watch supply stability. Rate limits, quota reset frequency, and peak-hour availability affect delivery as much as price. For critical paths, plan capacity and fallback scenarios in advance.

    Conclusion

    What’s really worth a developer’s attention in a price change that raises output prices 5x isn’t the number itself, but the three layers of logic it reveals:

    • Billing layer: The price ratios among input, cache, and output determine where optimization should focus.
    • Product layer: Pay-as-you-go, subscription, and reserved models each have their fit; nominal unit price isn’t the real cost, and the stability of quota supply affects experience too.
    • Engineering layer: Cost is ultimately determined by request structure; cache-friendly prompts, controlled context and output, tiered routing, and observable usage accounting are all indispensable.

    Once these layers are clear, a price adjustment turns from “bad news you passively absorb” into “a chance to re-examine your architecture.” If you want a unified LLM service entry point on the cloud, complete usage metering and budget management, and supporting infrastructure such as object storage, logging, and monitoring/alerting, Baidu AI Cloud offers relevant capabilities and can be one option to evaluate.