Why Are Output Tokens More Expensive Than Input Tokens?

    This article breaks down why LLM output token rates are typically higher than input rates, and why the largest line item on an AI coding bill is often repeated historical context rather than generation. It explains how each tool call forces the client to resend the full conversation, how prompt caching changes unit price but not the amount of context carried forward, and how context length and round count amplify each other. It closes with a practical cost formula and an optimization checklist.

    Imagine spending $100 on an AI coding task that reads files, edits code, and runs tests. According to a set of public modeled estimates, only $18 goes toward generating new content, while the single most expensive line is $67 for reading historical context. The files have already been read and the test results have already been seen, so why does the billing continue?

    The answer lies in a single tool-call round trip. This article explains why output token rates are generally higher than input rates, and how, under that pricing structure, the bill is driven up by the number of rounds and the context length.

    1. Start With the Bill: The Cost Is Repetition, Not Generation

    Broken down, the $100 looks roughly like this:

    • Historical context read (cache hit): about $67
    • New content generation (output): about $18
    • Base cost of new input added this round: about $12
    • Surcharge for writing historical context into cache: about $3

    Two points here are easy to misread.

    First, the cheapest unit price wins on volume. Cache reads usually have the lowest unit price of all billing items, but they are multiplied by the full history that must be reread every round, accumulating to roughly 3.7 times the generation cost.

    Second, these numbers come with assumptions. They assume a fixed price tier and that the entire reusable prefix hits the cache. Change the price tier, or let part of the prefix miss, and the most expensive line takes on a different name — it may become the base input fee or the cache write fee. So what matters is not the number “67” but the mechanism that produces it.

    2. Why One Tool Call Triggers Repeated Charges

    The key is the handoff of control. The model does not operate the file system or execute commands directly; it can only issue an instruction such as “read this file” and then return control to the client. Once the tool finishes, the result is sent back, and for the model to continue working, the client must send another request.

    That request does not carry only the new result. So the model understands why the file was read, what it contained, and what to do next, everything from prior rounds must be sent along: system constraints, user requirements, files already read, commands already executed, test logs already seen.

    Schematically, the process looks like this:

    1. Round 1 request: [system prompt + user goal] -> model output: read file A
    2. Round 2 request: [all of Round 1] + [contents of file A] -> model output: modify code
    3. Round 3 request: [all of Round 2] + [edit result] -> model output: run tests
    4. Round 4 request: [all of Round 3] + [test logs] -> model output: read file B again
    5. ...
    6. Round T request: [all of Rounds 1..T-1] + [this round's tool result]

    Caching optimizes the unit price of reading that history; it does not remove the history from the next round’s input. This is why “already read” does not mean “no longer billed.”

    3. Two Layers of Logic Behind Higher Output Prices

    1. Technical layer: token-by-token generation is serial

    Input processing can be highly parallel — the whole context can be computed in a single forward pass and reused from cache. Output must be generated autoregressively, one token at a time, where each step depends on the previous one. It cannot be parallelized or reused across requests. Different computational characteristics lead to different cost structures, so output rates are typically several times input rates (commonly in the 3–5x range, varying by price tier).

    2. Economic layer: pricing steers behavior

    Pricing output higher signals to callers: make the model say less, say it precisely, and minimize rework. Meanwhile, offering a substantial discount on cache reads encourages a “stable prefix + incremental append” usage pattern, keeping repeated context as cheap as possible.

    Layered together, these two logics produce a counterintuitive result: output, which has the highest unit price, is not necessarily the largest item on the total bill, while cache reads, which have the lowest unit price, may dominate the cost.

    4. The Formula That Actually Drives Cost

    To budget for a feature, the right approach is to sum the tokens actually received in every round, not just count the lines of code finally delivered:

    1. Total cost ≈ Σ(input tokens per round × corresponding input rate) + Σ(output tokens per round × output rate)
    2. Rough estimate: total input ≈ average context length N × number of rounds T

    Note that N and T amplify each other: one more tool call means one more round, and the tool result lengthens the input of every subsequent round, pushing N higher still. This is a positive feedback loop.

    This leads to a conclusion that matters for planning: after a product revision, even if the delivered code is the same length as before, cost can rise noticeably as long as a few more rounds were tried on average. Looking for the cause in “average output length” will miss this process entirely.

    A more realistic estimation snippet:

    1. def estimate_cost(rounds, base_ctx, growth_per_round, out_per_round,
    2. p_in, p_cache_read, p_cache_write, p_out):
    3. ctx, total = base_ctx, 0.0
    4. for _ in range(rounds):
    5. total += ctx * p_cache_read # most of the history hits the cache
    6. total += out_per_round * p_out # generation for this round
    7. ctx += growth_per_round # tool results push up later context
    8. return total

    5. What a Cache Hit Actually Saves

    What gets saved is only the repeated computation of the prefix portion: attention computation for stable prefixes such as the system prompt, prior conversation, and already-read files is reused, so it is billed at a very low rate. Three things are not saved: the billing for newly added tool results, the billing for this round’s output, and standard input billing for the portion that misses the cache. Understanding this explains why the bill can still be high even with a high cache hit rate.

    6. An Actionable Optimization Checklist

    • Stable prefix, incremental append: put the system prompt and fixed constraints first, and avoid changing them midway, which invalidates the prefix and causes large-scale cache misses.
    • Compress tool returns: paginated reads, summarized logs, returning only necessary fields — all directly reduce the growth slope of N.
    • Cut wasted rounds: merge tool calls that can run in parallel and consolidate the “read–edit–test” loop to reduce T.
    • Context governance: archive or summarize stale history promptly so the full history does not accumulate indefinitely.
    • Budgeting and observability: log input, output, and cache hits per round and configure monitoring alerts; attribute cost using the real distribution rather than average output length.

    Conclusion

    Output tokens cost more because of computational characteristics and pricing strategy together, while the bulk of the bill often comes from historical context carried over and over. The two variables you can actually control are average context length and number of rounds. In the model service practice of platforms such as Baidu AI Cloud, bringing both into your budget model and monitoring system is far more effective than watching how many lines of code were output.