LLM Inference Cost Evaluation and Model Selection: A Practical Guide

    Comparing per-million-token prices across vendors is a common but unreliable way to choose an LLM. Real bills are driven by call patterns, not price sheets. This guide breaks down how input, output, and cache-hit pricing work, why multi-turn retries and cache hit rates often outweigh unit price, and how to run reproducible small-traffic A/B tests, off-peak scheduling, and budget guardrails to establish a defensible cost baseline.

    1. The Starting Problem: Why Unit-Price Comparisons Lead to Wrong Conclusions

    A mistake that keeps recurring in model selection work is taking the “price per million tokens” published by different vendors, subtracting one from another, and declaring a winner. This is unreliable because unit price is only a static parameter, while the real bill is determined by the call pattern. For the same workload, differences in prompt organization, context length distribution, and retry strategy can change cost by several times.

    A recent example in the industry: two vendors released lightweight models for high-concurrency scenarios on the same day, and the community immediately started arguing about price. But the variables that actually determine cost were almost never that price table. They were the engineering details below.

    2. Breaking Down the Billing Structure: You Are Not Buying Tokens, You Are Buying Three Kinds of Overhead

    Mainstream usage-based billing usually splits a request into three priced parts:

    • Input tokens: system prompts, conversation history, retrieved context, and the user’s current input;
    • Output tokens: the content the model generates, usually priced significantly higher than input;
    • Cached portion: when a request prefix repeats a recent request, the cached input is often billed far below the normal input price, and some schemes approach free when the hit is sufficient.

    The key conclusion here: output price is usually several times the input price, so any prompt optimization that “makes the model write less filler” pays off far more than compressing the input. The existence of caching also means a “repeated prefix” turns from a cost burden into a cost advantage, provided you put stable, unchanging content at the very front of the prompt.

    A recommended layered prompt structure:

    1. [Fixed layer] Role definition, output format constraints, glossary, examples (cacheable long-term)
    2. [Semi-fixed layer] Domain knowledge, retrieved snippets (updated per batch)
    3. [Variable layer] User's current question, timestamp, random identifier (must go last)

    If you put content that changes every time, such as timestamps or random IDs, at the beginning, the hash of the entire prefix changes, all caching is invalidated, and actual spending can multiply several times over. This is the most common and most easily overlooked cause of cost overruns.

    3. Multi-Turn Calls: The Underrated Hidden Cost Amplifier

    To improve accuracy on complex tasks, engineering practice commonly adopts a “multiple attempts + result verification + retry” strategy. This has a direct consequence: a nominal single call may actually be three to five calls.

    If a task’s baseline consumption is 1,000 input tokens and 300 output tokens, three-sample voting pushes real consumption close to 3,000 and 900. At that point, even if a scheme’s input price is 20% lower, a higher probability of triggering retries can make total cost go up instead.

    So cost evaluation must introduce two metrics:

    • Effective task cost = total spend ÷ successfully delivered tasks, not total spend ÷ number of calls;
    • Retry amplification factor = actual number of calls ÷ number of logical tasks.

    In practice, a model with slightly lower but stable accuracy plus one retry is often cheaper than a model with slightly higher accuracy that needs three samples. During selection, “first-pass success rate” should be treated as a first-class metric in load testing.

    4. Cache Hit Rate: The Highest-Weighted Variable in the Cost Model

    In high-repetition scenarios (for example, batch processing similar documents, fixed-template generation, or long-running scheduled jobs), the impact of cache hit rate on the bill often exceeds the unit price difference itself. Cost can be approximated as:

    1. Total cost ≈ input tokens × unit price × (1 - hit rate × discount rate)
    2. + output tokens × output unit price
    3. + extra consumption from failed retries

    From the formula: raising the hit rate from 20% to 80% can cut input-side spending by more than half, an amount large enough to cover any reasonable unit price gap. Engineering means of improving hit rate include stable prefixes, isolating sessions by business shard, avoiding dynamic variables inside fixed segments, and controlling the rolling strategy of the context window.

    Note that different schemes differ in cache granularity, validity period, and minimum cacheable length requirements. These are vendor implementation details and must be based on official documentation and hands-on measurement, not assumptions.

    5. Don’t Guess, Measure: Small-Traffic A/B and a Reproducible Baseline

    Any paper analysis is worth less than one week of real traffic. The recommended approach is to build a reproducible evaluation and cost observability process:

    1. Fixed evaluation set: sample from historical real requests, covering four distributions: long input, short input, high difficulty, and low difficulty;
    2. Parallel dual channels: connect candidate schemes to the same business code and route through an adapter layer, with zero changes to business logic;
    3. Unified metric definitions: record call count, input/output tokens, cache hit status, failure rate, and end-to-end latency at the same time;
    4. Attribution to tasks: use “actual cost per successful task” as the only comparison basis;
    5. Continuous observation: cover at least one full business cycle, including peak and trough periods.

    A minimal adapter layer sketch:

    1. def call_model(provider, messages, **kw):
    2. # provider is decided by configuration; the business side is unaware of the specific implementation
    3. resp = PROVIDERS[provider].chat(messages, **kw)
    4. metrics.record(
    5. provider=provider,
    6. in_tokens=resp.usage.prompt_tokens,
    7. out_tokens=resp.usage.completion_tokens,
    8. cached=resp.usage.get("cached_tokens", 0),
    9. latency=resp.elapsed_ms,
    10. )
    11. return resp.text

    With unified instrumentation, cost comparison turns from a “feeling” into auditable data.

    6. Off-Peak Scheduling: The Money-Saving Lever Most People Ignore

    If the calls are offline batch processing (content summarization, bulk tag extraction, scheduled archiving, and so on), then execution time itself is a cost variable. Time-of-day pricing, which is common in the industry, means scheduling jobs into low-price windows can reduce spending without changing a single line of prompt.

    The engineering recommendation: introduce a configurable scheduling window for batch jobs, pair it with a backoff strategy for failed retries, and set a daily token budget cap with alert thresholds. Budget guardrails are more valuable than after-the-fact review, because they can cut off an anomalous path before the bill gets out of control.

    1. Scheduling policy example:
    2. Priority P0 (online interaction) -> all hours, latency guaranteed first
    3. Priority P1 (near real-time) -> avoid peaks, minute-level delay allowed
    4. Priority P2 (offline batch) -> run only in low-price windows, interruptible and resumable

    7. Conclusion: Upgrade Selection from “Price Comparison” to “Cost Engineering”

    Back to the original question: how to view a newly released lightweight model rationally. The answer is not its price table, but its effective task cost under your traffic profile. The suggested order of execution: first do prompt layering and cache optimization, then measure the retry amplification factor, then run a small-traffic A/B across a full business cycle, and finally solidify the cost baseline with off-peak scheduling and budget guardrails.

    The value of this method is that it transfers: no matter how many new models appear or how prices change, you can produce a data-backed conclusion within a week instead of relying on guesswork. For teams that operate AI capabilities over the long term, cost that is observable, reproducible, and optimizable is the truly sustainable engineering capability.