LLM Token Plan Testing and Cost Evaluation Guide
This guide explains why a low per-unit price does not guarantee controllable costs when choosing token-based LLM plans. It breaks down the four token categories used in billing, shows how context expansion drives consumption in multi-turn sessions, and compares two workload profiles: AI agents versus code completion. It also provides a reusable four-step method to estimate quota capacity using real request samples and P95 values, helping developers decide whether a quota plan, pay-as-you-go billing, or a hybrid approach fits their workload.
1. The Starting Point: Why a Low Unit Price Does Not Mean Controllable Costs
When evaluating model service plans billed by token quota, developers most often make the mistake of focusing on the listed price. An entry tier that looks highly attractive (for example, a very low monthly fee with a total quota several times the monthly fee) makes it easy to place an order immediately. But the real bill depends on three variables: how the unit quota is priced, how many tokens a single request actually consumes, and how densely requests arrive within a given period. The first two determine how expensive a single call is; the third determines how long the quota lasts.
The signals from a real-world test are representative: under a promotional tier, the available quota in a 5-hour window was about 2000 AFP, with a monthly total of about 20,000 AFP. Using a third-party model, a single question consumed about 105,682 tokens in an AI coding tool, which translated to about 1214.84 AFP deducted per question-answer exchange. One division gives the key conclusion: 2000 ÷ 1214.84 ≈ 1.65, meaning this window was only enough for one to two complete question-answer rounds. Even by the monthly quota, 20,000 ÷ 1214.84 ≈ 16.5, meaning roughly sixteen interactions of the same scale per month. This does not mean the plan is “bad”; it means the workload profile does not match the quota model.
2. Break Down the Billing Categories First: Token Is Not One Thing
To calculate costs accurately, you must distinguish four token categories:
- Normal input: the prompt explicitly entered by the user;
- Cached input: the part that hits a prefix cache and can reuse historical context, usually priced significantly lower than normal input;
- Output: content generated by the model, usually the most expensive;
- Thinking/reasoning tokens: intermediate steps produced by reasoning-capable models before giving an answer, usually billed at the output rate.
Mainstream pricing generally shows a gradient of “output more expensive than input, normal input more expensive than cached input.” This leads to a counterintuitive conclusion: a task that only makes the model “read a lot and write a little” (such as long-document review or log attribution) has costs mainly determined by input; a task that requires long-form generation will see costs quickly pushed up by output. If you do not break down the categories when budgeting, the error can easily reach several times.
A schematic cost model can be written as:
def cost(req, price):return (req.normal_in * price.inp+ req.cached_in * price.cached+ req.output * price.out+ req.reasoning * price.out) # reasoning tokens are mostly billed as output
3. Context Expansion: The Real “Black Hole” for Quotas
A single consumption of 105,682 tokens almost certainly does not come from a one-line question typed by the user. Its composition is usually: system prompts and tool descriptions, project-level rule files, conversation history, retrieved or automatically attached code snippets, tool call return values, plus reasoning tokens. To “understand the project,” AI coding tools by default inject a large amount of repository context, which often accounts for more than eighty percent of the total.
More importantly, context accumulates across multiple turns. If each turn adds about 20,000 tokens, after ten turns a single request can exceed 100,000 tokens. This means costs grow approximately quadratically with the number of turns, not linearly. Mitigation measures include: enabling prefix caching to reuse stable prefixes, compressing and summarizing history, trimming repository context by task, splitting long tasks into separate sessions, and setting truncation and structured summaries for tool return values.
# Pseudo-flow: controlling context size1. Fix system + project rules (cacheable)2. Inject only file snippets relevant to the current task3. When history exceeds a threshold -> replace original text with a summary4. Tool output -> structured summary + key fields
4. Two Workload Profiles: AI Agent vs. Code Completion
The test conclusion of “not recommended for agents, possibly sufficient for code completion” is essentially a judgment about workload characteristics.
AI agent workloads are characterized by: a single task involving multiple rounds of tool calls, each round carrying the full history and tool list, retries and self-verification further amplifying the number of calls, and outputs that include longer reasoning and intermediate artifacts. Token consumption is strongly correlated with task complexity and has extremely high variance; a complex task consuming the entire window quota is normal.
Code completion workloads are the opposite: the context window is relatively fixed (the current file plus a small amount of context), the output is very short (a few lines to a few dozen lines), and each request is small but frequent. This type of workload is cache-friendly and predictable in cost, making it more suitable for quota-based plans. However, note that completion scenarios are extremely sensitive to latency; failures caused by quota exhaustion or rate limiting will directly interrupt the coding flow.
5. A Reusable Quota Estimation Method
Before going live, do a quantitative evaluation in four steps:
- Sampling: take 20–50 requests from real tasks and record the distribution of the four items: input, cached input, output, and reasoning tokens;
- Modeling: use the cost function above to calculate the mean and P95 per call;
- Conversion: total quota ÷ mean per call = number of supported calls; then convert to available days by average daily requests;
- Boundary testing: verify rate limits, concurrency caps, and retry strategies to avoid “quota remaining but being rate-limited.”
A simple capacity check:
budget = 20000per_call_p95 = 1200print(budget // per_call_p95) # 16 calls of the same scaleprint((budget // per_call_p95) / 30) # about 0.55 calls/day
When the result is lower than the business’s average daily demand, the conclusion is clear: this tier is not suitable for this type of workload, and you should switch to pay-as-you-go billing, enterprise-level quotas, or a hybrid approach (heavy workloads go through a dedicated channel, lightweight completion goes through a quota plan).
6. Conclusions and Recommendations
The value of quota-based plans lies in predictable costs, making them suitable for stable, short, high-frequency, cache-friendly workloads. For agent scenarios with severe context expansion and long tool call chains, quotas can be quickly depleted, leading to a broken experience. The practical recommendation is: first build a cost baseline with real sampling, then reduce per-call consumption through three means—caching, context trimming, and session splitting—and finally do capacity planning based on P95 rather than the mean. If your organization already uses model services from Baidu AI Cloud, you can similarly build an internal cost dashboard using the four categories of “input / cached input / output / reasoning,” enabling quota attribution by team and by project so that cost optimization has a solid basis.
