Token Billing in AI Coding Tools: Group Multipliers and Cost Calculation
This article explains how token billing works in AI coding tools, covering the four token categories, list-price calculation, group multipliers, common pricing pitfalls, model availability by group, and practical cost-control habits.
1. Why the Bill Looks “Off”
When developers connect AI coding assistants to large-model APIs, a common confusion is that the same model can cost different amounts through different access channels or groups. Sometimes the final bill is several times higher than a manual estimate. To resolve this, it helps to understand the full billing chain:
Usage measurement → four-category token counting → official list-price calculation → group multiplier → final credit deduction
Each step has clear rules. Once you understand them, cost estimation becomes a simple multiplication exercise.
2. Four Token Categories: The Basic Billing Units
In a large-model API response, the usage field usually splits the tokens consumed by a request into four categories, each with a different unit price:
- Non-cached input: prompt content that enters the model for the first time in this request; one of the higher-priced categories.
- Output: the model-generated response; usually the highest-priced category.
- Cache read: the portion that hits the prompt cache and reuses previously processed context; its unit price is far lower than non-cached input, often around one-tenth of the input price.
- Cache write: the portion written to the prompt cache for the first time; its unit price is usually slightly higher than normal input.
In coding scenarios, system prompts and repository context are often long and repeated. Prompt caching can greatly reduce the cost of this portion. As a result, cache-read volume often accounts for most of the total input on real bills.
The list-price cost can be expressed with a general formula:
List-price cost = input tokens × input unit price+ output tokens × output unit price+ cache-read tokens × cache-read unit price+ cache-write tokens × cache-write unit price
For example, take a typical high-end model (prices are illustrative; always check the latest official list prices): input at $4 per million tokens, output at $20 per million tokens, and cache read at $0.2 per million tokens. If a request consumes 100,000 input tokens, 50,000 cache-read tokens, and 2,000 output tokens, then:
Cost = 0.1 × 4 + 0.05 × 0.2 + 0.002 × 20 = $0.45
3. Group Multipliers: Why the Same Model Has Different Prices
On relay gateways or aggregation platforms, the same model is often assigned to different “groups,” each with a multiplier. The key point is: token counting is exactly the same, and the base unit prices are the same; the only difference is the multiplier applied at the end.
The billing logic can be summarized in two steps:
- The gateway first calculates the “list-price cost” of the request using the upstream official list prices.
- It then multiplies that cost by the multiplier of the group to which your API Key belongs, producing the amount actually deducted from your balance.
Deduction = list-price cost × group multiplier
Different groups have different sources, so their multipliers naturally differ. Common group types include:
- Channel-optimized groups: reduce costs through a specific access method; the multiplier may be below 1, meaning cheaper than the official price.
- Subscription-pool groups: provide service based on a subscription credit pool; stability depends on the pool status, and the multiplier may be above 1.
- Official direct-connect stability groups: use official Keys to ensure availability; the multiplier is usually the highest.
- Enterprise custom groups: designed for high-concurrency scenarios; the multiplier is customized by agreement.
Multipliers are not fixed. Platforms adjust them dynamically as upstream costs change. Before checking prices, go to the platform’s model catalog or pricing page, select the group for your Key, and read that day’s actual value rather than relying on historical impressions.
4. Three Details That Are Easy to Misread
1. The multiplier applies to the official list price, not to the token count. Some people assume different groups count tokens differently. In fact, the counting method is identical; the multiplier only affects the final price. For example, if a model’s official input price is $4 per million tokens and the group multiplier is 2, the input price shown for that group is $8 per million tokens.
2. The default view on a platform may not show the official original price. Many platforms, when no group is selected, display prices using a default multiplier, commonly 2. If you compare the default view directly with the official price, it may look “twice as expensive,” leading to a misjudgment. The correct approach is to confirm your Key’s group first, then switch to that group’s view and read the price.
3. The “$” in an account may be platform credit, not real USD. Some platforms use internal credit units rather than actual US dollars. A bill showing a $9 deduction may correspond to 9 units of local-currency balance, not 9 USD. If you want to compare with the real US-dollar cost of direct official access, check the unit definition and any exchange rate first; otherwise you may draw the wrong conclusion.
5. Model Availability: Groups Affect More Than Price
An often-overlooked fact is: not every group includes every model. Different groups have different upstream channel capabilities and support different model lists. For example, one group may offer several mainstream large models but not the latest release or certain lightweight models.
If your code specifies a model that the current group does not support, the request will fail directly. The platform will not automatically fall back to another group and charge you there. Before integration, it is recommended to:
- Confirm the target model’s availability in the current group.
- Manage model names through configuration in your code so they can be adjusted when switching groups.
- Add fallback handling for error messages to avoid interrupting tasks.
6. Practical Advice: Build Cost Estimation into Your Workflow
For teams using AI coding tools, it is worth establishing these habits:
- Read the
usagefield: every response contains precise token usage for that turn, enabling per-request accounting instead of relying on after-the-fact reconciliation. - Build a cost model: maintain an estimator in a spreadsheet or script using the formula above; input the four token counts and the group multiplier to predict costs.
- Improve cache hit rate: keep system prompts stable and place long context where it can be cached; this can significantly reduce actual spending.
- Check multipliers regularly: multipliers change dynamically, so monthly cost reviews should use current values.
If you use a cloud platform’s model service, check its model catalog for model- and version-specific pricing. Baidu AI Cloud, for example, provides such pricing information; the billing logic is the same: first calculate from token usage and list prices, then determine the final cost based on the selected service tier or group multiplier.
Once you understand the core mechanism of “list price × multiplier,” token billing is no longer a confusing account.
