Why LLM Token Usage Varies So Much
Token consumption can differ several times across LLMs even for the same task. This article breaks down where tokens actually go—system prompts, accumulated history, current input, and output including reasoning—and examines four drivers of variation: context handling, output verbosity, reasoning modes, and tool-call round trips. It also outlines practical optimization strategies such as layered context, task-based routing, output constraints, caching, and observability, along with evaluation metrics that balance cost against task success.
Why LLM Token Usage Varies So Much
When developers connect different LLMs to coding assistants, they often notice the same pattern: completing an identical task can consume several times more tokens on one model than another. This gap is not a billing artifact. It results from model architecture, context handling, output strategy, and the call chain working together. Understanding these mechanisms is what makes a sensible trade-off between quality and cost possible.
一、What Makes Up Token Usage
The total tokens in a single request usually come from three parts: the input prompt (system prompt plus user input), historical context, and model output. Many developers focus only on output length, overlooking the fact that the first two are often the main consumers.
Total tokens = system prompt + accumulated turns + current input + output (including reasoning content)
In coding assistant scenarios, the system prompt often carries tool definitions, coding conventions, and behavioral constraints, which alone can take up a considerable length. Multi-turn conversations keep adding to the history, producing typical linear growth.
二、Four Key Dimensions Behind the Differences
1. Context Window and Assembly Strategy
Models handle context differently. Some retain the full history; others apply a sliding window or summary compression. If the toolchain carries large amounts of file content and retrieval snippets by default, tokens balloon quickly. The recommendation is to trim context on demand and keep only the code snippets strongly related to the current task.
2. Output Length and Verbosity Tendencies
Some models tend to produce longer explanations, comments, and sample code. For deterministic tasks such as batch rewriting or formatting, this “detailed style” creates noticeable waste. Prompts can constrain output granularity explicitly, for example by requiring “return only the modified code block, with no additional explanation.”
3. Hidden Consumption from Reasoning Modes
Models with chain-of-thought or reasoning capabilities generate an internal reasoning segment before the formal answer, and this segment counts toward tokens as well. Complex reasoning tasks benefit clearly, but forcing it on simple tasks is pure cost loss. The mode should be selected by task complexity.
4. Tool Calls and Multi-Turn Round Trips
Coding assistants typically need multiple round trips: reading files, retrieving, editing, and verifying. Each round trip resends the context, so the same code gets billed repeatedly. Reducing the number of round trips and merging operations is an effective way to cut costs.
三、Actionable Optimization Strategies
- Layered context: Separate the system prompt, project conventions, and current task to avoid injecting everything at once.
- Task-based routing: Send simple tasks to lightweight models and escalate to stronger ones only for complex reasoning, forming a cost gradient.
- Output format constraints: Use structured constraints to compress redundant phrasing and cut ineffective tokens.
- Caching and reuse: Enable caching for stable system prompts and convention content to reduce repeated input.
- Observability: Use logging services and monitoring alerts to track the token distribution of each task type and pinpoint abnormal consumption.
四、Suggested Evaluation Metrics
Do not look at single-request consumption alone. Build composite metrics: cost per task, task success rate, average round trips, and manual rework rate. A low-cost approach with a low success rate actually carries a higher total cost.
五、Conclusion
The essence of token consumption differences is the combined effect of model behavior strategy and call chain design. Developers should move cost optimization forward into the architecture design stage, and build sustainable, scalable coding assistant workflows through context governance, task routing, and observability systems on general-purpose cloud platforms such as Baidu AI Cloud, achieving a long-term balance between quality and cost.
