LLM Cost Optimization: A Tiered Scheduling Approach for Routing Requests by Value Density
This article explains how to treat LLM API calls as a tiered, routable, and measurable system to keep costs predictable when model or cache prices change. It breaks the monthly bill into a reproducible cost formula, proposes an L1/L2/L3 routing model that sends high-value tasks to strong models and low-value tasks to cheaper ones or cache, and details cache governance, scenario-based budgeting, quota selection, and observability practices for continuous cost control.
1. Why Cost Efficiency Became an Engineering Problem
When upstream model prices change by several multiples, many teams find that their bill grows out of proportion to business growth. The cause is usually not the unit price itself but the call structure: a large share of requests are exploratory, repetitive, and low in value density, yet they run on the most expensive model tier. A phenomenon from the source material illustrates this—after the cache hit price was adjusted to several times its original value, the number of tokens consumable under the same budget dropped from roughly 7 billion to roughly 1.4 billion. This shows a rule: in cache-sensitive workloads, cost is highly elastic with respect to the cache unit price.
So cost efficiency is no longer just “which model to pick,” but “how to land each class of request on the right capability tier.” That requires governing model calls as a system that can be tiered, routed, and measured.
2. Cost Model: Break the Bill into Computable Quantities
Any optimization should start from a reproducible formula. For the vast majority of token-based billing scenarios, monthly cost can be abstracted as:
monthly cost ≈ Σ(input tokens × input price)+ Σ(output tokens × output price)+ Σ(cache hit tokens × cache price)+ Σ(cache write tokens × cache write price)
This yields three practical conclusions:
- The cache hit unit price is an amplifier. When the cache hit price rises several-fold, the larger the hit volume, the more the bill is amplified. The drop from 7 billion to 1.4 billion in the material is exactly a 5x relationship, showing that this kind of workload relies almost entirely on the cache dividend.
- Output tokens are usually more expensive than input, so for long-form generation and batch refactoring tasks, cost elasticity comes mainly from the output side.
- Auxiliary calls (exploration, retrieval-style Q&A, code location) have low value density, and having a high-priced flagship model carry them is where cost efficiency is lost the most.
Teams should maintain a mapping table of “request category — model tier — budget share” and allocate budget explicitly, rather than letting all traffic default to the highest tier.
3. Tiered Scheduling: Route Requests by Value Density
The core idea of tiered scheduling is: use high-capability models for primary tasks, low-cost models for auxiliary tasks, and avoid calling a model at all for repetitive tasks.
A practical tiering proposal:
| Tier | Typical tasks | Suggested capability tier | Reference budget share |
|---|---|---|---|
| L1 primary | Complex reasoning, architecture design, critical code generation | High-capability tier | 30%–50% |
| L2 auxiliary | Code exploration, comment generation, unit test drafts | Low-cost tier | 10%–20% |
| L3 no-call | Repeated Q&A, fixed templates, reuse of existing conclusions | Cache/retrieval | Approach 100% as much as possible |
The idea from the material—“use an extremely low-cost model as a code exploration sub-agent and reserve the main plan for the expensive model”—is a typical L2 practice. Its benefit does not come from unit price but from completely removing high-priced tokens from low-value paths.
Illustrative routing logic can be written as:
def route(task):if task.repeated and cache.hit(task.key):return cached_answer # L3: consumes no model tokensif task.type in ("code_explore", "summarize_doc", "gen_tests"):return cheap_model(task) # L2: low-cost tierreturn strong_model(task) # L1: high-capability tier
The key is that routing decisions must be observable: every downgrade must record its reason, otherwise the quality loss cannot be evaluated later.
4. Cache Governance: The Highest-Leverage Step in a Price-Hike Cycle
Since changes in the cache unit price can multiply the budget, cache governance should be treated as an independent engineering item, not an incidental framework capability.
- Improve prefix stability: Put the system prompt, tool definitions, and long-lived context at the very front and keep them byte-for-byte identical, avoiding prefix invalidation caused by timestamps, random IDs, or dynamic concatenation.
- Shrink context volume: Deduplicate and truncate retrieval results to avoid repeatedly stuffing entire documents into the context.
- Separate “cacheable” from “non-cacheable”: Data containing user privacy or strong time sensitivity should not enter a shared cache; this is both a compliance requirement and a way to avoid inflated hit rates.
- Build a hit-rate dashboard: Continuously track cache hit rate, average context length, and output length as three core cost metrics.
It must be emphasized that any cache scheme must be premised on data isolation and permission boundaries. Reusing cache content across tenants is a high-risk design and should not be introduced in the name of cost optimization.
5. Budget Estimation: Replace Intuition with Scenario Analysis
In the face of a price hike, the most practical approach is not to argue about “expensive or not” but to run three scenario estimates:
Scenario A (before the hike): budget of 68 yuan → about 7 billion tokensScenario B (cache price up 5x): same budget → about 1.4 billion tokensScenario C (after tiering + cache governance): auxiliary traffic sinks, primary tokens drop → target back within a sustainable range
Estimation must make three inputs explicit: average daily token consumption, cache hit share, and input-to-output ratio. The material mentions “a theoretical ceiling of about 6 billion, with actual daily usage not maxed out,” which points to a commonly overlooked fact: for most teams the bottleneck is insufficient task supply, not insufficient quota. In that case the marginal return of buying more plans is very low, and the priority should be to raise effective call density.
6. Choosing Plans and Quotas
For quota-based purchasing, follow three principles:
- Primary quota ensures depth, auxiliary quota ensures breadth. The auxiliary model quota can be very small; as long as the unit price is low enough, it can cover a large volume of exploratory calls.
- Preserve replaceability. Once model calls are wrapped behind a unified abstraction layer, a price change means editing configuration, not business code.
- Put compliance and invoicing processes first. Enterprise procurement must account for invoices, audits, and data compliance requirements; these are hard constraints in selection and should not be patched after the fact.
7. Observability and Continuous Governance
Cost optimization rebounds without measurement. Collect at least: token distribution by task type, cache hit rate, downgrade call ratio, average cost per task, and quality spot-check pass rate. When the quality spot-check rate falls while cost falls, the downgrade has gone too far and the L2 share needs to be pulled back.
A simple daily-granularity check:
if daily_cost > budget * 0.8:lower_l2_ratio() # compress auxiliary-tier calls firstif quality_pass_rate < threshold:raise_l1_ratio() # quality first, raise the primary tier back up
8. Conclusion
Cost efficiency during a price-hike cycle does not depend on finding some “cheapest model,” but on whether the call structure is finely governed. Tier the requests, stabilize the cache, turn the budget into a reproducible scenario model, and continuously calibrate with observable metrics—only then can cost stay predictable and quality stay protected through price swings. This method does not depend on any specific vendor and applies to most forms of token-billed LLM services.
