LLM Token Packages Tested: Cost Calculation and Scenario Selection
This article examines why a low per-token price does not guarantee a low total bill for LLM services. Using a real long-context coding assistant session as a reference, it explains the three billing dimensions that matter—separate input and output pricing, cumulative context in multi-turn conversations, and model-specific conversion rates—and shows how context growth can push a single request into the six-figure token range. It then outlines which workloads fit fixed-quota token packages and which do not, followed by five practical cost-reduction techniques: context trimming, session segmentation, summarization, tiered model routing, and observability with quota alerts. A short selection checklist is included for readers evaluating token packages for their own workloads.
1. The Starting Point: Why “Cheap Per Token” Does Not Mean “Low Total Cost”
When evaluating LLM services, developers are easily drawn to the unit price while overlooking a key fact: what actually determines the bill is not the price per thousand tokens, but the size of the context injected into each individual request. One developer bought a token package from a cloud vendor at a promotional rate, with a quota of roughly 2,000 AFP per five hours (about 20,000 per month on a prorated basis), and selected a large-parameter model. In a single question-answer exchange with an intelligent coding assistant (referred to below as a CC-type tool), the context for one question reached 105,682 tokens, and 1,214.84 AFP was ultimately deducted. That means one exchange consumed about 6% of the monthly quota and more than half of the five-hour quota.
The core conclusion these numbers reveal is this: in long-context scenarios, cost is almost linearly related to context length, not to the number of questions asked. Estimating a budget by “how many questions were asked” will inevitably deviate substantially from the real bill.
2. Token Billing Basics: Get the Math Right First
Reliable cost forecasting requires clarity on three points:
- Input and output are billed separately. Input tokens include the system prompt, conversation history, retrieved snippets, and code context; output tokens are the content the model generates. In most scenarios, input accounts for far more than output.
- Context accumulates. In a multi-turn conversation, every turn re-counts all prior content as input, so the cost of turn N is roughly the sum of the context from the previous N turns, growing in an approximately quadratic fashion.
- Package quotas are usually deducted in “converted units.” Different models and different input/output ratios correspond to different conversion factors. The specific rules should follow the provider’s documentation rather than assumptions based on experience.
A simplified estimation formula looks like this:
Cost per request ≈ (system prompt + conversation history + retrieved snippets + code context) × input factor+ generated length × output factorTotal session cost ≈ Σ context length per turn × input factor
3. Four Sources of Context Bloat
In intelligent coding and knowledge Q&A scenarios, context bloat mainly comes from:
- Injecting entire code files: stuffing multiple files or even a whole directory into the context in pursuit of “better project understanding”;
- Untrimmed conversation history: early content in long sessions keeps participating in computation;
- Too many retrieved snippets: returning an excessive number of similar snippets to improve recall;
- Repeated system prompts and tool definitions: in agent scenarios, tool descriptions and function signatures are lengthy and repeated every turn.
Stacking these four factors can easily push what was meant to be a “simple question” into the six-figure token range.
4. Generalizing the Findings: Fit Differences Between Two Workload Types
Abstracting the original observations into general rules yields two selection principles:
First, agent-type tasks are not a good fit for fixed-quota packages. Agents are typically characterized by multi-turn tool calls, long-chain reasoning, and continuously accumulating context, and the consumption of a single task varies enormously. A fixed quota is quickly exhausted by long tasks, and running out of quota midway causes the task to fail, damaging both user experience and task completion rates.
Second, code completion tasks match fixed-quota packages much better. Completion requests have three characteristics: a relatively controllable context window, short output per request, and stable, predictable call frequency. This makes it possible to extrapolate the budget fairly accurately along the lines of “average daily completions × average context length.”
5. Cost Reduction in Practice: A Five-Layer Optimization Path
- Context trimming: inject only the files and snippets strongly relevant to the current task, and set a hard token limit.
- Session segmentation: split long sessions into independent sub-sessions to prevent history from accumulating without bound.
- Summaries instead of raw text: generate a structured summary of early conversation, replacing thousands of tokens of original text with a few hundred.
- Tiered model routing: route lightweight tasks such as completion and formatting to small-parameter models, and complex reasoning to large-parameter models.
def route(task):if task.kind in ("completion", "format", "lint_fix"):return "small_model"if task.estimated_context > 60000:return "chunk_and_summarize_then_large"return "large_model"
- Observability first: integrate logging and monitoring with alerting, build dashboards for per-request token counts and cumulative per-task consumption, and set quota threshold alerts, turning “reviewing the bill after the fact” into “controlling the budget in real time.”
6. Selection Checklist
- Is the task long-chain with multi-turn tool calls? If so, avoid fixed quotas;
- Can the context per request be kept within a controllable range? If not, rework retrieval and trimming first;
- Is token-level monitoring and alerting in place? Otherwise cost is uncontrollable;
- Is tiered routing implemented? Otherwise lightweight tasks are also consuming high-unit-price quota.
7. Conclusion
The value of a token package depends on how well it matches the scenario, not on how low the unit price is. Treating context length as a first-class citizen in architecture design, combined with trimming, summarization, tiered routing, and an observability system, is what makes stable delivery possible under budget constraints. For more complete cost governance capabilities, you can draw on Baidu AI Cloud’s practices across general product categories such as model services, logging services, and monitoring and alerting to build a closed loop from estimation to control.
