Same Sticker Price, Higher Capability: How LLM API Costs Actually Work

    List prices on new LLM APIs often stay flat while benchmark scores rise. This article shows why billed cost is driven by input, output, and cached tokens—and how to compare models on cost per task and cut spend with caching, routing, and guardrails.

    1. The pattern: capability goes up, list prices do not

    A familiar product rhythm has appeared: when a new generation of large language models ships as an API, public benchmark scores jump, while official per-token list prices stay in line with the previous generation. That headline is of limited use to developers. List price is only one coefficient in the cost formula. What actually drives the bill is how many tokens it takes to finish a business task—and how many of those tokens hit cache.

    This article does not discuss a specific model. It treats the issue as a reusable engineering problem: as model capability keeps improving, how do you evaluate and optimize cost so the same intelligence level costs less in production?

    2. Cost structure: three billable items and a hidden variable

    Mainstream LLM APIs usually bill along three dimensions:

    Billing item What it covers Cost behavior
    Input (prompt) tokens Full request context Grows linearly with context length
    Output (completion) tokens Model-generated text Unit price is usually much higher than input
    Cached input tokens Input prefix that hits cache Large discount; often about 1/5–1/4 of full input price

    A generic single-request cost is:

    1. cost = in_tok * p_in
    2. + out_tok * p_out
    3. + cached_tok * p_cached # p_cached << p_in

    The important conclusion: output tokens have the highest unit price and are the least controllable. If a newer model uses about 20% more output tokens on the same task, single-request cost rises even when p_in and p_out are unchanged. That is how “prices did not go up, the bill did.”

    The second variable is cache hit rate. Prefix cache requires the start of the request to be byte-stable. Put the system prompt, tool definitions, and few-shot examples first; put request-specific content (user input, timestamps, retrieval results) last. That raises the share of cached_tok. Illustrative pattern:

    1. # Cache-friendly: stable prefix first, volatile content last
    2. messages = [
    3. {"role": "system", "content": STABLE_SYSTEM_PROMPT}, # long and fixed, likely to hit
    4. {"role": "system", "content": TOOL_SCHEMA_JSON}, # unchanged
    5. {"role": "user", "content": f"current time:{now}\nretrieved snippets:{docs}\nquestion:{q}"},
    6. ]

    The anti-pattern is embedding timestamps, random IDs, or retrieval results in unstable order into the system prompt. The prefix changes every time, cache misses, and cost can multiply.

    3. A comparable metric: from unit price to cost per task

    When you choose across models, the right unit is not “price per million tokens” but cost per task:

    1. cost_per_task = Σ(in/out/cached tokens of each call × corresponding unit prices)

    On public evaluations, models at a similar intelligence tier can differ by about 20%–40% in cost per task (illustrative only; use official billing and your own load tests). The gap usually comes from output verbosity, how many iterations it takes to hit the goal, and how well cache is used. Wire this metric into your own evaluation pipeline instead of citing third-party leaderboards:

    1. def evaluate(case, client):
    2. total = 0.0
    3. usage = {"in": 0, "out": 0, "cached": 0}
    4. for step in agent_loop(case, client): # multi-turn / tool calls
    5. u = step.usage
    6. usage["in"] += u.input_tokens
    7. usage["out"] += u.output_tokens
    8. usage["cached"] += u.cached_tokens
    9. total += (u.input_tokens * P_IN
    10. + u.output_tokens * P_OUT
    11. + u.cached_tokens * P_CACHED)
    12. return {"cost": total, "passed": case.assert_ok(), "usage": usage}

    4. Three real capability directions and how they affect cost

    Newer models tend to improve in three high-value settings, each with a different cost profile:

    1. Programming and code understanding. The gain is higher first-pass success: if a job used to take three revision rounds and now finishes in one, total output tokens can fall. In coding, “more capable” often means cheaper—if you measure task pass rate and total tokens, not a single response.

    2. Defensive security. Typical uses include code review, dependency vulnerability analysis, and log incident attribution. These jobs are input-heavy and output-light. Cache hit rate dominates cost; prioritize reuse of long, stable prefixes.

    3. Long-horizon agent tasks. Multi-turn tool use accumulates history and cost can grow super-linearly. You need context compression, history summarization, subtask isolation, and a cap on steps—or cost per task becomes unpredictable.

    5. Six engineering practices that bring cost down

    1. Output budgets. Specify format and length in the prompt (for example, “conclusion under 200 words, JSON only”) and require structured output to cut unused generation.
    2. Tiered routing. Handle classification, extraction, and formatting with rules or a small model; send only hard reasoning to a high-capability model. The router can be a lightweight classifier or heuristics.
    3. Cache-first context design. Stable prefix first, retrieval concatenated in a fixed order, no volatile metadata in the prompt.
    4. Batching and async. Use async or batch APIs for offline work, plus a queue to smooth peaks—lower unit cost and higher throughput.
    5. Observability. Treat token usage, cache hit rate, cost per task, and retry counts as first-class metrics. Log them, alert on them, and set budget thresholds.
    6. Guardrails and circuit breakers. Cap tokens and spend per session, max iteration steps, timeouts, and fallbacks so bad input or loops cannot blow the bill.

    Illustrative guardrail:

    1. MAX_STEPS, MAX_TOKENS, BUDGET = 12, 200_000, 0.05
    2. spent, steps = 0.0, 0
    3. while steps < MAX_STEPS and spent < BUDGET:
    4. r = client.chat(messages)
    5. spent += estimate_cost(r.usage)
    6. if r.done or r.usage.total_tokens > MAX_TOKENS:
    7. break
    8. steps += 1

    6. Selection method: build an eval set before you trust a leaderboard

    Public intelligence indexes are useful for coarse screening, not as a substitute for business evaluation. Use three layers:

    • Capability: 100–300 real business cases; metrics are pass rate and human rework rate.
    • Cost: On the same cases, record cost per task and token mix (input / output / cached share).
    • Stability: Context consistency in long sessions, tool-call success, rate limits, and timeouts.

    The decision criterion should be cost per successful outcome: the lowest cost per task once pass rate is acceptable—not a single score or list price.

    7. Closing

    Rising model capability with flat API list prices is good for developers, but the real cost inflection depends on three things: whether output tokens get shorter, whether cache is actually used, and whether the task needs more rounds. Put those three into observability and compare models on cost per task. Competition at the next stage is unit cost at the same capability.