The Technical Path and Practice of Reducing LLM Costs and Improving Efficiency
This article explains how the focus of large language model competition is shifting from parameter counts to the cost per completed task, and what that means for developers and enterprises. It covers tiered model selection across flagship and everyday tiers, the three main levers of cost control (input, cached input, and output tokens), and practical techniques for managing multi-step agent workflows through task decomposition, externalized state, failure budgets, and pruning. It also outlines a three-layer evaluation framework for verifying whether a model upgrade actually lowers cost, along with a minimal deployment architecture built around caching, routing, and observability. Readers will find pseudocode examples, pricing structure illustrations, and concrete criteria for deciding when to switch models.
1. The Trend: From a Parameter Race to a Cost-per-Task Race
Over the past two years, competition in the large language model space centered mainly on parameter scale and benchmark scores. Recent product iterations, however, have clearly shifted toward a different dimension: the token consumption and total cost required to complete the same task. The keywords that keep recurring in the source material are not “bigger” but “fewer tokens used,” “lower task cost,” and “existing pricing retained.” This signals that the industry’s evaluation system is moving from the “upper bound of model capability” to “usable capability at a given cost per task.”
For enterprises and developers, this shift matters far more than a change in leaderboard rankings. AI calls in real business scenarios are not one-off question-and-answer exchanges; they are composite workflows that span long chains, multiple steps, and tool invocations. A task that looks simple, such as “generate a weekly report and file it,” may involve reading data, retrieving knowledge, structured generation, format validation, and failure retries, amounting to a dozen or more model interactions. If the cost of a single interaction drops by 20%, the end-to-end cost may fall by even more. Conversely, if a model’s capability improves but token consumption doubles, what the business side typically perceives is a rising bill with no change in experience.
The right way to evaluate a new generation of models, therefore, is to build a three-dimensional coordinate system: the capability dimension (accuracy on professional tasks), the efficiency dimension (tokens and number of calls needed to complete a task), and the cost dimension (the combined result of three price categories: input, cached input, and output). Only by observing all three at once can you judge whether an upgrade is genuinely worthwhile.
2. Capability Tiers: The Division of Labor Between Flagship and Everyday Models
The new generation of models generally adopts a two-tier or even multi-tier product structure. One tier is positioned as flagship, aimed at complex professional work, scientific research, software development, and visual design. The other is positioned for everyday tasks, emphasizing cost-effective agent workflows, code writing, and multi-step processing.
The engineering value of this layering lies in matching capability to cost. Flagship models excel at long-context reasoning, complex constraint following (for example, strictly adhering to a presentation template), high-quality structured output (slides, spreadsheets, documents), and front-end and 3D content generation. Everyday models are more economical in high-frequency, short-chain scenarios with strong fault tolerance. Their key metric is not the absolute score but whether the gap with the flagship model is small enough while the cost is low enough.
The quantitative relationships in the source material are representative: a flagship version scored about 5 percentage points higher than the previous generation on a multi-step professional task evaluation, at less than one-third of the per-task cost; compared with a competing flagship from the same period, it scored slightly higher but cost only a small fraction. The everyday-tier model trailed the flagship by less than 0.5 points on a code evaluation, at about one-fifth of the cost; on an everyday task evaluation it surpassed the previous generation’s flagship, at about one-seventh of the cost. The real takeaway from these figures is that capability gaps are being compressed while cost gaps are being amplified, which makes tiered scheduling a default architectural choice.
3. Three Levers of Cost Structure: Input, Caching, and Output
Understanding the bill structure is the prerequisite for optimization. Mainstream pricing is usually split into three categories: input tokens, cached input tokens, and output tokens. The pricing structure in the source material is $8 per million input tokens, $0.4 for cached input, and $40 for output on the flagship tier, with input and output down 20% and cached input down 60% from the previous generation; the everyday tier stays at $2 input, $0.1 cached input, and $10 output.
From an engineering perspective, the three levers correspond to three types of measures:
- Input side: compress prompts, trim redundant context, and use retrieval instead of full injection. Changing “stuff the entire manual into the context” to “retrieve matching snippets plus a summary” typically yields a several-fold reduction in input tokens.
- Caching side: place stable, unchanging system prompts, tool descriptions, and long document prefixes at the very front of the context to maximize the prefix cache hit rate. Cached input often costs only one-tenth to one-twentieth of regular input, so every 10-percentage-point improvement in hit rate noticeably improves the overall bill.
- Output side: constrain generation length, require short structured output, and split long-text generation into streamed segments with validation, avoiding the vicious cycle of “generate, exceed the limit, truncate, retry.”
An illustrative context organization order is as follows (pseudocode that expresses structure only and involves no specific API):
[Stable prefix: system role + tool list + output format constraints] # Goal: hit the cache[Semi-stable zone: business rules, glossary, template skeleton] # Goal: improve reuse rate[Dynamic zone: retrieved snippets, user input, current step state] # Goal: minimize size[Output constraints: field list + length limit + validation rules] # Goal: compress output
4. Agent Tasks: Cost Amplification and Convergence in Multi-Step Scenarios
Multi-step agent tasks are the scenario where cost is most easily underestimated. The cost does not add up linearly but carries an amplification effect: the output of each step becomes the input of the next, and errors trigger retries. The source material’s emphasis on “reducing the tokens required to complete a task” is essentially about compressing this amplification factor.
Engineering convergence can be achieved in four places:
- Task decomposition granularity: too fine causes call counts to explode, too coarse causes single-call context to bloat. A practical approach is to divide steps by “verifiable intermediate artifacts,” with each step producing a checkable structured result.
- Externalized state: write intermediate results to external storage (such as object storage, message queues, or logging services), keeping only references and summaries in the context to avoid unbounded history growth.
- Failure budget: set caps and fallback paths for retries, for example using the flagship model first and switching to the everyday model with a conservative output after two failures.
- Parallelism and pruning: run independent subtasks in parallel and prune low-value branches early.
# Pseudocode: tiered scheduling with budget controldef run_task(task, budget_tokens=200_000):plan = planner(task) # Generate steps and acceptance criteriaused = 0for step in plan.steps:model = "flagship" if step.critical else "daily"out = call_model(model, step.prompt)used += out.tokensif not verify(step, out):model = "daily" # Downgrade and retry to control costout = call_model(model, step.prompt + "Revise according to the acceptance criteria")used += out.tokensif used > budget_tokens:return fallback_report(plan, used)persist(step.id, out) # Externalize state to avoid context bloatreturn aggregate(plan)
5. Evaluation: How to Verify That Cost Reduction Is Real
Vendor-published scores are only a reference; enterprises must build their own evaluation sets. A three-layer evaluation is recommended:
- Capability layer: select 100 to 300 real business samples covering both high-frequency and long-tail cases, with metrics including accuracy, format compliance rate, and structured field completeness rate.
- Efficiency layer: record each sample’s input tokens, cached-hit tokens, output tokens, number of calls, and end-to-end latency.
- Cost layer: convert per-task cost using a unified pricing model and output a “unit cost vs. accuracy” curve.
The criterion can be quantified as a simple inequality: switching is worthwhile only when a new model satisfies accuracy improvement > cost increase; if cost drops while accuracy declines only slightly, and the decline is within a business-acceptable threshold, switching should be prioritized. In addition, the evaluation must include two categories of metrics, “format following” and “tool call correctness,” because in office and development scenarios a format error is often more damaging than a content error.
6. Deployment Architecture: Caching, Routing, and Observability
The recommended minimum viable architecture contains five general-purpose components: a unified gateway (handling routing and rate limiting), a prefix caching layer (reusing stable context), a retrieval service (injecting knowledge on demand), state storage (externalizing intermediate artifacts), and monitoring and alerting (dashboards for token consumption and failure rates).
A “three-tier routing” strategy is suggested: high-value complex requests go to the flagship tier; regular requests go to the everyday tier; batch offline tasks go to a low-cost tier with longer latency allowed. Paired with two core dashboard metrics, cache hit rate and per-task cost, you can continuously drive down the bill without sacrificing experience.
Cost attribution should also be established: break down token consumption by business line, scenario, and model tier to locate sources of abnormal growth. In practice, the most common waste comes from three places: full document injection, unlimited retries, and output without length constraints.
7. Conclusion
The core change in the new generation of models is not being “a little smarter” but treating “the cost of completing a task” as a first-class optimization target. For developers, the real dividend lies not in leaderboards but in architecture: tiered selection, prefix caching, externalized state, budget control, and self-built evaluation. These five things determine whether cost reduction actually shows up on the bill. If an enterprise wants to build similar capabilities on Baidu AI Cloud, it can assemble the architecture above directly from general-purpose category components (such as object storage, message queues, container platforms, logging services, and monitoring and alerting), without relying on any proprietary API.
