Evaluating LLM Inference Costs: What to Look at Beyond Token Pricing

    When a new flagship model costs several times more per token than its predecessor, the instinct is that it has become expensive. This article explains why unit price is only one variable in the real cost equation, and how to compare models on cost per successful task instead of price sheets. It covers a normalized cost formula with retry rate and cache hit rate, throughput and latency benchmarking (TTFT, TPS, P50/P95/P99), context caching and batching as cost levers, first-pass quality metrics, and a practical decision checklist. The takeaway: whether a flagship price increase pays off depends on your cache hit rate, retry rate, and first-pass success rate.

    1. The Problem: A Price Multiple Is Not a Cost Multiple

    When a new flagship model charges several times more per token than the previous flagship generation, the immediate reaction is “it got more expensive.” But in real engineering terms, unit price is only one variable in the cost equation. The actual bill is determined by four factors together: the price per token, the total number of tokens needed to complete the same task, the number of requests a given unit of time can serve, and the engineering cost paid to hit business latency targets. The intuition that a newer model can actually be “more cost-effective in practice” essentially means this: the denominator changed more than the numerator.

    So before judging whether something is expensive, you must fix the task definition first, then compare the total spend on completing the same task—not the numbers on a price sheet.

    2. Converting Price into Cost per Completed Task

    Different model generations differ in output speed, instruction-following ability, and long-context stability, and these differences directly change token consumption. For a structured extraction task, a weaker model may need multiple rounds of follow-up and retries, while a stronger model gets it right in one pass; the cumulative input and output tokens of the former can be several times those of the latter.

    You can establish a common baseline as follows:

    1. # Use "cost per 1k successful tasks" as the unified metric
    2. def cost_per_1k_tasks(price_in, price_out,
    3. avg_in_tokens, avg_out_tokens,
    4. retry_rate=0.0, cache_hit_rate=0.0):
    5. billable_in = avg_in_tokens * (1 - cache_hit_rate)
    6. per_task = (billable_in * price_in + avg_out_tokens * price_out)
    7. per_task *= (1 + retry_rate) # extra consumption from retries on failure
    8. return per_task * 1000

    The key conclusion: retry rate and average output length often affect total cost more than the unit price difference itself. Cutting the retry rate from 20% to 5% is equivalent to getting a 25% discount.

    3. Throughput and Latency: The Overlooked “Hidden Unit Price”

    Output speed (tokens generated per second) determines how many concurrent requests a single instance can serve within a fixed latency budget. If a new-generation model significantly improves output throughput, the number of requests that can be served under the same hardware and concurrency quota rises, and the fixed cost amortized per call drops accordingly. This is also why “comparing against the fast tier of the previous generation” is the meaningful comparison—putting services of different performance tiers on the same price sheet will inevitably distort the conclusion.

    The recommended benchmarking metrics include the following, and must be collected under real business traffic patterns:

    • Time to first token (TTFT): affects the perceived smoothness of interactive applications;
    • Output rate (TPS): affects the total time for long-text generation and concurrency capacity;
    • End-to-end P50/P95/P99: capacity planning should be based on P95, not the average;
    • Success rate and rate-limit triggers per unit time: rate limiting turns into queuing and timeout-retry costs.
    1. Example benchmarking matrix
    2. Concurrency levels: 1 / 8 / 32 / 128
    3. Input length: 512 / 4K / 32K tokens
    4. Output length: 256 / 1024 tokens
    5. Record: TTFT, TPS, P95, error rate, cost per 1k tasks

    4. Context Reuse and Batching: The Second Lever of Cost Structure

    Most business requests share a large common prefix (system prompts, tool descriptions, knowledge base snippets). Services with context caching can reduce or waive billing for repeated prefixes, and with a high hit rate, input costs can drop by an order of magnitude. On the engineering side, three things should be done: keep the prefix ordering stable, place volatile content at the end, and segment and pre-compress long documents with summarization.

    Batching is another path: trade throughput for unit price, use an asynchronous queue to handle offline tasks, and reserve online quota for interactive traffic. The typical division is—the online path uses a low-latency channel, while offline cleaning, batch summarization, and evaluation regression go through the batch channel.

    1. # Prefix stabilization: move volatile fields to the end to improve cache hit rate
    2. def build_prompt(system_static, tools_static, user_dynamic):
    3. return f"{system_static}\n{tools_static}\n---\n{user_dynamic}"

    5. Quality Cost: First-Pass Rate Is the Ultimate Metric

    A cheap-per-token approach that needs repeated correction carries costs in human review and rework. Evaluation should introduce three task-level metrics: first-pass success rate, structured-output validity rate, and human-intervention rate, and use a fixed evaluation set for generational comparison. If a new model raises the first-pass rate from 70% to 90% under the same prompt, total cost may still drop even if the unit price doubles.

    6. Decision Checklist

    1. Unify the baseline: replace unit-price comparison with “cost per 1k successful tasks”;
    2. Compare like-for-like tiers: benchmark only against the same performance tier of the previous generation;
    3. Use measured data: benchmark P95 and success rate under real traffic, and reject vendor-stated figures;
    4. Capture the gains: prioritize enabling context caching, batching, and prefix stabilization;
    5. Layered routing: send high-value requests to the flagship tier and push long-tail requests down to a lightweight tier;
    6. Continuous observation: build a cost dashboard through logging services and monitoring alerts, and review unit-cost trends weekly.

    In related practice at Baidu AI Cloud, the above methods can be implemented by combining general-purpose logging services, monitoring alerts, message queues, and container platforms, forming a closed loop of “observable—benchmarkable—optimizable.” The conclusion: whether a flagship model’s price increase is worth it does not depend on the price-sheet multiple, but on your cache hit rate, retry rate, and first-pass success rate.