LLM Cost and Model Selection: A Practical Guide to Routing, Caching, and Cost Governance

    This guide explains why usage rankings and spending rankings for large language models rarely match, and how to turn that gap into a repeatable selection process. It covers a four-layer evaluation framework (task tiering, quality evaluation, cost and capacity estimation, engineering and compliance constraints), four cost optimization techniques (model routing, semantic caching, context compression, batching and asynchronous execution), and the observability practices needed for ongoing cost governance, closing with a deployment checklist.

    1. Why the Call Volume Ranking and the Spending Ranking Disagree

    Public model usage statistics usually come in two forms: one ranking by cumulative tokens processed, and one ranking by cumulative spend. Put them side by side and a pattern repeats itself. The top of the call volume ranking is typically occupied by low-cost lightweight or mid-tier models, while the top of the spending ranking is usually held by higher-priced flagship models. A single flagship model can account for more than 30% of total spend while its share of call volume is far lower.

    This is not a measurement artifact. It follows directly from cost structure. The cost of a single request can be approximated as:

    1. cost per request ≈ (input tokens × input price + output tokens × output price) × (1 + retry amplification factor)
    2. total spend = Σ cost per request

    The retry amplification factor comes from timeout retries, backoff after rate limiting, and second attempts after content safety blocks. Flagship model prices are often several times, sometimes an order of magnitude, higher than lightweight models. As a result, a flagship model can top the spending ranking even without leading on call volume. Conversely, a lightweight model may handle enormous call volume while its cumulative spend stays very low.

    The conclusion is straightforward: looking only at call volume underestimates budget pressure, and looking only at spend misjudges the real workload. Model selection has to consider both dimensions.

    2. A Reusable Evaluation Framework

    Break the evaluation into four layers and narrow the candidate set step by step.

    The first layer is task tiering. Classify business requests into three difficulty levels: simple, medium, and complex. The simple tier covers intent recognition, field extraction, format conversion, and summarization or rewriting. The medium tier covers multi-turn question answering, structured generation, and routine code completion. The complex tier covers long-document reasoning, cross-file code modification, and advanced mathematical or logical inference. The point of tiering is that different tiers should be bound to models at different price points, rather than routing all traffic to a single strongest model.

    The second layer is quality evaluation. Build a set of at least several hundred real business samples, annotate reference answers or acceptance rules, and score with automatic metrics plus manual spot checks. Evaluation should focus on stability rather than peak performance. If repeated calls on the same input produce high variance, that becomes unpredictable user experience problems in production.

    The third layer is cost and capacity estimation. Multiply measured average input and output token lengths by the projected daily call volume to get monthly token volume, then multiply by unit price to get a budget range. Reserve a separate allowance for peak factors and retry overhead; in practice, a margin of 20% to 50% is a safe choice.

    The fourth layer is engineering and compliance constraints. These include whether the context window covers the longest document, whether structured output is supported, concurrency and rate limit quotas, data residency and audit requirements, and vendor lock-in risk. This layer often determines whether a candidate model can actually go live.

    3. Four Cost Optimization Techniques

    Model routing. Use a task classifier or a rule engine as a front-end decision step and distribute requests across models at different price points. Illustrative logic:

    1. if task type in {extraction, classification, rewriting}:
    2. use lightweight model
    3. elif task type in {multi-turn QA, structured generation}:
    4. use mid-tier model
    5. else:
    6. use flagship model + result self-check

    Semantic caching. Build a vector index for frequently repeated or semantically equivalent requests and reuse the historical result on a hit. Customer support, knowledge question answering, and document summarization scenarios typically see meaningful hit rates, making this the fastest way to cut cost. Caches need a time-to-live and an invalidation policy so answers do not go stale.

    Context compression. Use retrieval augmentation to inject only the necessary fragments, combined with summary-based history compression, to reduce input tokens. In long conversations, unbounded concatenation of history messages is a common cause of runaway cost.

    Batching and asynchronous execution. Merge non-real-time tasks into batch requests and run them during off-peak hours. This also lowers the probability of triggering rate limits and indirectly reduces retry amplification.

    4. Observability and Cost Governance

    Nothing gets optimized without measurement. Collect the model identifier, input and output tokens, latency, status code, and business identifier for every call, then build a dashboard and attribute spend across three dimensions: business line, scenario, and tenant. On top of that, set budget alerts and quota circuit breakers so that when spend in a scenario grows abnormally, traffic automatically falls back to a backup model.

    Supporting engineering practices include: assign version numbers to prompts and model versions so quality regressions are reproducible; classify failed requests to separate rate limiting, timeouts, content blocks, and genuine errors; and run evaluation regressions regularly to catch quality drift caused by model version updates.

    5. Deployment Checklist

    1. Complete difficulty tiering of business requests and bind each tier to candidate model tiers;
    2. Build a real-sample evaluation set and record quality and variance;
    3. Estimate the monthly budget from measured token lengths and reserve headroom;
    4. Roll out semantic caching and context compression;
    5. Connect call-level observability dashboards and budget alerts;
    6. Define a fallback plan and a version regression process.

    6. Conclusion

    The essence of model selection is not finding the single strongest model, but balancing quality, cost, stability, and compliance. Using the dual lens of call volume and spend, together with tiered routing, cache reuse, and end-to-end observability, most teams can bring inference cost into a reasonable range without sacrificing user experience. If more elastic compute and supporting capabilities are needed, a unified model gateway and governance layer can be built on general-purpose product categories such as the container platform, object storage, log service, and monitoring and alerting offered by Baidu AI Cloud.