LLM Plans and Quotas: How to Calculate Your Real Token Consumption
Unit price is one of the most misused metrics in LLM service selection. This article explains why actual consumption, not the headline price, dominates your bill. It covers how tokens are counted, how the cost curves of subscription plans and pay-as-you-go differ, five amplifiers that inflate usage, a runnable cost-estimation script, seven engineering optimizations, and enterprise-grade usage governance. It closes with a checklist for making model-selection decisions based on measured consumption rather than price alone.
1. The Core Problem: Low Unit Price Doesn’t Mean Low Cost
When choosing a model service, “how much per million tokens” is the most easily misused metric. A real bill can be reduced to a very simple equation:
Actual spend = consumption structure × pricing rules
Unit price is only one part of the pricing rules, while the consumption structure is determined by your own application code. The central claim of this piece—don’t judge tokens by unit price, actual consumption is what dominates—holds up in practice for three reasons:
- The billing unit is the token, not “characters” or “calls.” The same requirement described in Chinese versus English, or code mixed with comments, produces noticeably different tokenization results.
- A single business action often triggers multiple model calls. In agentic, tool-calling scenarios especially, “fixing one bug” can involve dozens of round trips.
- Context grows and accumulates across conversation turns. In multi-turn dialogue, every turn resubmits the history, so consumption grows super-linearly.
Ignore these three points and you get the classic surprise: “the unit price dropped 30%, but the bill went up.”
2. First, Understand How Tokens Are Counted
Before discussing savings, you have to understand the billing basis. The industry generally uses subword tokenization. A few rules of thumb from practice:
- Chinese: one character roughly maps to 1–2 tokens;
- English: about 4 characters per token;
- Code, JSON, indentation spaces, and symbols are also tokenized and counted;
- Multimodal inputs such as images, PDFs, and audio are likewise converted to tokens before billing.
One point deserves special attention: all three of the following count as input tokens—system prompts, tool (function) definitions and parameter structures, and few-shot examples. Many teams stuff thousands of characters of rule descriptions and dozens of examples into their prompts, and that overhead is paid again on every single call.
If you need a rough budget during the coding phase, you can use the general estimation method below (exact values should come from the usage fields returned by the server):
def rough_token_count(text: str) -> int:"""General estimate: CJK characters count as 1.5 tokens, others as 0.25 tokens/char.For capacity planning only; actual usage should follow the API's usage fields."""cjk = sum(1 for ch in text if '\u4e00' <= ch <= '\u9fff')others = len(text) - cjkreturn int(cjk * 1.5 + others * 0.25)
Also keep one general pricing rule in mind: input and output tokens are priced separately, and the output unit price is usually significantly higher than the input price. This directly means that “making the model write less fluff” saves more money than “making the model think more.”
3. Two Billing Models: Subscription Plans and Pay-As-You-Go
For developer-facing LLM services, the mainstream billing forms fall into two categories, and their cost curves have completely different shapes.
| Dimension | Subscription Plan (quota-based) | Pay-as-you-go (API billing) |
|---|---|---|
| Cost predictability | Fixed periodic spend; marginal cost is zero before exceeding the quota | Strictly linear with actual usage |
| Typical limits | Quota caps within a rolling time window, concurrency limits | Account balance and rate quotas |
| Over-limit behavior | Queuing, throttling, or rejected requests | Continues billing until the balance runs out |
| Best fit | High-frequency, single-user daily interactive coding | Low-frequency bursts, batch jobs, production system integration |
| Main risk | Work interruption when the quota is exhausted | Bill spikes caused by runaway loops |
Subscription products in the industry commonly use a “rolling time window + quota pool” design—for example, short-term throttling over a window of several hours, combined with a cumulative quota measured in weeks. This design is friendly to interactive use, but note that interactive scenarios have extremely high consumption density per unit of time: submitting large-context requests back-to-back within a single window can easily trip the rate limit early.
A practical decision method:
If monthly avg total consumed tokens × unit price < plan monthly fee × 0.6 → pay-as-you-go is more cost-effectiveIf monthly avg total consumed tokens × unit price > plan monthly fee × 1.5 → the subscription is more cost-effectiveIn the middle range → hybrid: interactive on the plan, batch on the API
Actual unit prices and quota parameters should follow the pricing page in the official documentation of the cloud service you choose. Major cloud providers—Baidu AI Cloud among them—commonly offer a standard combination for their model services: pay-as-you-go billing, quota or resource packages, and usage logs with monitoring and alerting. The right move when selecting a service is to check each billing item’s definition one by one, not to compare a single headline price.
4. Five Amplifiers of Consumption
4.1 Context accumulation (the biggest impact)
If every turn carries the full history, the input for turn i is roughly i × average tokens per turn, and the cumulative consumption is O(n²):
def cumulative_input_tokens(turns: int, avg_turn_tokens: int) -> int:"""Cumulative input tokens when every turn carries the full history"""return sum(i * avg_turn_tokens for i in range(1, turns + 1))# Average 2000 tokens per turn, 10 consecutive turnsprint(cumulative_input_tokens(10, 2000)) # 110000print(cumulative_input_tokens(30, 2000)) # 930000
Going from 10 to 30 turns increases the cost by more than 8×, yet the user only perceives it as “chatting a bit longer.”
4.2 Agent and tool-calling loops
A single task like “fix one failing test” may include reading files, searching code, generating a patch, running tests, reading errors, and generating another patch… Each step is a model call carrying the full context. If one task involves 30 calls averaging 8,000 input tokens, that’s roughly 240,000 input tokens per task. This is currently the largest hidden cost source in development scenarios.
4.3 Output length
When generating complete files, long documents, or large blocks of refactored code, the output token count rises quickly, and the output unit price is higher. Asking the model to “output the plan first, then the code” is often cheaper than having it output everything at once.
4.4 Retries and failure rebuilds
Re-runs after network timeouts, rate-limit rejections, or format-validation failures all repay the input cost. Clients without idempotency and caching can multiply consumption several-fold during outages.
4.5 Repeated delivery of large-context material
Entire repositories, long specification documents, and large tables of data get pasted into conversations over and over. This kind of “static large prefix” is where caching yields the highest returns.
5. Cost-Estimation Script
Consolidate the factors above into a runnable estimator for capacity planning:
from dataclasses import dataclass@dataclassclass Call:input_tokens: intoutput_tokens: intcached_input_tokens: int = 0 # Input tokens served from the prefix cachedef estimate_cost(calls, p_in, p_out, p_cached):"""p_in / p_out / p_cached are per-1K-token prices"""total = 0.0for c in calls:fresh = max(c.input_tokens - c.cached_input_tokens, 0)total += (fresh * p_in+ c.cached_input_tokens * p_cached+ c.output_tokens * p_out) / 1000return round(total, 4)
To use it, feed in the real call records collected in your logging service. The key metrics here are not the total spend but the average cost per business action and the cache hit rate—the former for assessing business viability, the latter for gauging how much optimization room remains.
6. Seven Engineering Optimization Techniques
- Context compression: Use a sliding window to keep recent turns and backfill early history with summaries, pulling O(n²) back down to roughly O(n).
- Prompt slimming: Remove duplicate examples and verbose rules; replace them with structured descriptions plus specification snippets loaded on demand.
- Tiered model routing: Run a lightweight intent check first; send simple tasks to a small model and escalate to the flagship model only for complex reasoning.
- Prefix cache reuse: Most services require an identical prefix for prefix caching, so keep the system prompt, tool definitions, and static documents at the very front of the message and leave them unchanged, with dynamic content placed after.
- Output budget constraints: Set an explicit maximum output length explicitly and generate long artifacts in segments, avoiding a single generation that gets discarded and rewritten wholesale.
- Call deduplication and idempotency: Cache identical inputs at the request level; on failed retries, use exponential backoff and reuse the existing context.
- Observability: In the logging service, tag each call’s input/output/cached tokens by project_id, user_id, and env, and pair this with monitoring and alerting that sets daily and weekly thresholds.
7. Enterprise Usage Governance
Once the team scales up, the cost problem becomes a governance problem. A four-step approach:
- Unified model gateway: Consolidate authentication, rate limiting, auditing, and cost accounting in one place; forbid teams from connecting directly.
- Tag-based attribution: Attach project, environment, and trace identifiers to every call so bills can be broken down by dimension.
- Tiered budget alerts: Warn at 80% of the daily quota and cut off at 100% to prevent a single point from spiraling out of control.
- Quota isolation and review: Separate development, testing, and production pools; produce a weekly top-N list of highest-consumption calls and trace them back to specific code paths.
8. Conclusion and Selection Checklist
The true cost formula is “consumption × pricing structure,” and optimizing consumption usually pays off far more than switching to a cheaper model. Before you commit, verify these items one by one:
- How many model calls does one of my business actions trigger on average?
- What are the average number of turns and the average context length per conversation?
- Is caching enabled for static large prefixes?
- Is there a hard cap on output length?
- Do I have per-project usage attribution and budget alerts in place?
Quantify these questions before looking at unit price, and the selection decision becomes much clearer—measure consumption first, then talk price. That is the correct order for controlling large-model spending.
