Token Cost Optimization for Multi-Model LLM Routing: A Practical Guide

    This article presents a practical framework for reducing token costs when routing requests across multiple large language models. It covers task tiering, multiplier-based routing under a unified quota pool, off-peak scheduling, batching, caching, and context compression. It also outlines a three-task evaluation design comparing low-cost, mid-tier, high-capability, and automatic modes across quality, cost, and stability, followed by an enterprise control checklist and general implementation guidance. Readers will learn how to match model capability to task needs while keeping quality gates intact and avoiding unnecessary spend.

    1. Background: Model Selection Is Now About Value, Not Availability

    When a platform offers models from multiple providers, users are no longer asking whether a capability exists. The real question is how to get the best match between cost and quality. A typical pattern is that the number of selectable models grows from two to ten, alongside mechanisms such as a unified quota pool, multiplier-based pricing, time-based discounts, and free allowances for small tasks. This reflects a broader shift in the industry: from relying on a single model for everything to routing across multiple models on demand.

    For enterprises and developers, the challenge comes down to three points:

    1. Tasks vary widely: summarization, extraction, code generation, and web retrieval have very different compute requirements.
    2. Billing has many dimensions: input and output tokens, multipliers, time windows, and cache hits all affect the final bill.
    3. Quality cannot be sacrificed: scenarios such as finance and legal demand strict formatting and accuracy.

    2. Core Method: Turning Model Selection into Engineering Rules

    2.1 Task Tiering

    Group tasks into three tiers:

    • L1 lightweight tasks: short-text rewriting, field extraction, and format conversion, which should prefer low-multiplier small models.
    • L2 standard tasks: structured summarization, table generation, and routine code, which should use mid-tier models.
    • L3 complex tasks: cross-document reasoning, long tool-call chains, and architecture design, which are the only cases that justify high-capability models.

    2.2 Unified Quota Pool and Multiplier-Based Routing

    Under a unified quota pool, maintain a multiplier for each model. During routing, prefer the lowest-multiplier model that still clears the quality gate:

    1. score = quality_gate(pass) ? 1 : 0
    2. cost = (in_tokens * in_rate + out_tokens * out_rate) * multiplier
    3. choose min(cost) among models with score = 1

    2.3 Time Windows and Batching

    Schedule non-real-time work (daily reports, weekly reports, batch extraction) into discounted time windows. For homogeneous requests, apply batching and result caching to reduce repeated billing.

    2.4 Context Compression

    Run retrieval and denoising first, then send the cleaned context to the model. For long documents, extract key points segment by segment and perform a second-pass summary. This can significantly reduce input tokens.

    3. Evaluation Design: Three Tasks to Verify Cost Differences

    Following the same idea, we designed three task types. Each task was run once with three models plus an automatic mode, for 12 runs in total, recording quality and quota consumption.

    • Task A: a 21-page annual report, producing an 800-word summary plus a key financial metrics spreadsheet with page references.
    • Task B: a small expense-reimbursement workflow tool that is usable for finance, including validation and export.
    • Task C: web research on industry material, producing a briefing for management.

    Evaluation dimensions:

    • Quality: field completeness, format compliance, traceable citations, and runnable code.
    • Cost: input and output tokens, multiplier, and total quota.
    • Stability: timeout rate and number of retries.

    Illustrative evaluation table (values show relative trends, not absolute benchmarks):

    Task Low-multiplier model Mid-tier model High-capability model Automatic mode
    A Annual report summary + table Meets quality bar, lowest cost Medium cost Highest cost Close to lowest
    B Reimbursement tool Needs multiple rounds of fixes High first-pass rate Over-engineered Low to medium
    C Industry briefing Insufficient citations Best balance Cost on the high side Low to medium

    The conclusion matches the original observation: for the same work, switching models can produce several-fold cost differences, and automatic mode usually lands close to the best cost-performance point.

    4. Implementation Checklist: Five Enterprise Cost Controls

    1. Routing gateway: unified authentication, rate limiting, and model selection by multiplier and quality gate.
    2. Budget guardrails: quota caps and alerts per project or per user.
    3. Cache layer: semantic caching for repeated prompts and retrieval results.
    4. Observability: log tokens, multipliers, and quality scores for every call to close the loop.
    5. Regression evaluation: run a fixed evaluation set whenever a model or prompt changes to prevent cost from creeping back up.

    5. General Implementation on Baidu AI Cloud

    You can deploy the routing gateway on a container platform, store evaluation sets and outputs in object storage, use a message queue to smooth batch-processing peaks, and track token and multiplier consumption with logging and monitoring alerts. These are all general capability categories and do not involve any proprietary interfaces.

    6. Conclusion

    In the multi-model era, competitiveness does not come from how many models you use. It comes from whether you have built a routing and evaluation system with two objectives: quality and cost. Tier tasks, route by multiplier, schedule by time window, and reuse through caching, and you will spend quota where it matters.