ERROR CODES / ENGLISH

Token counts do not match: why estimates run low

Why token estimates differ from actual usage, how tokenizers vary across models, and how much headroom to reserve.

Reviewed 2026-11-13 · ERROR CODES / ENGLISH · Chinese detail: 完整中文页

What it means

Different models use different tokenizers, and Chinese text differs especially. Do not use one estimate for all models.

Typical symptoms:

报错提示 context 超限,但你自己算没超

计费比预估高

The first line says the error reports a context overflow even though your own count says it fits. The second says billing is higher than estimated.

Common causes

ShareCause
60%Wrong tokenizer
25%Chinese token efficiency is low
15%System prompt and tool definitions were not counted

How to confirm

Recount the same text with the tokenizer of the model you are actually calling. If the counts then agree, your estimation method was the issue. If they still differ a lot, the text is probably Chinese, where token efficiency is lower. Check whether the request includes a system prompt and tool definitions that your estimate omitted.

Fix

On your side:

  1. Estimate with the target model's own tokenizer.
  2. Reserve 20% headroom.
  3. Count tool definitions as well.

On the service side:

  1. The relay may rewrite the request, which changes the token count.

If it still fails

SymptomResponsible party
Counts match when you use the target model's tokenizerEstimation method
Large differenceChinese token efficiency
Exceeds only when tools are includedTool definitions

Billing and window checks should both use the target model's tokenizer. An estimate from another model family is not a reliable budget.

General guidance, not a statement about any specific provider. For measured data, see the relay directory and method.