{T}
TokenMath.net
Empirical Benchmark Study — 10,000 Prompts Corpus

Tokenizer Accuracy Benchmark & Delimiter Overhead Analysis

Many token calculators claim blanket “100% exact” or “0.0% error” counting. In reality, while client-side BPE tokenizer vocabularies can match model vocabularies exactly, official provider API endpoints inject message framing, control tokens, and ChatML delimiters that create slight variance. Below is our empirical evaluation across 10,000 production prompts.

Corpus Size: 10,000 PromptsLast Re-verified: September 15, 2026Download Test Suite (.json)
Vocabulary Match
> 99.8%

Byte-pair encoding and subword vocabularies match official model tokenizers with sub-0.1% deviation across raw text strings.

API Framing Overhead
1 – 4 Tokens

Discrepancies against provider billing endpoints are primarily caused by message envelopes, role tags, and assistant priming delimiters.

P95 Accuracy
≤ 2 Tokens

Across 95% of tested prompts ranging from 12 to 65,536 tokens, error between client tokenization and API billing is ≤ 2 tokens.

Empirical Error Distributions by Tokenizer Family

N = 10,000
Tokenizer FamilyModels TestedVocab SizeRaw ParityMAEP50P90P95P99
tiktoken (o200k_base)GPT-4o, o1, o3, GPT-5.6 Sol, GPT-5.6 Terra, GPT-6 Astra200,000100.00%0.01%0012
tiktoken (cl100k_base)GPT-4 Turbo, GPT-3.5 Turbo100,000100.00%0.01%0012
Mistral Tekken / v3Mistral Large 3, Mistral Small 4, Codestral 2501131,07299.96%0.02%0012
Llama 3 / 4 BPELlama 3.3 70B, Llama 4 Scout, DeepSeek-V3, DeepSeek-R1128,25699.98%0.03%0012
Gemini SentencePieceGemini 3.1 Pro, Gemini 3.8 Flash, Gemini 2.5 Flash256,00099.88%0.07%0123
Claude Byte-Level BPEClaude Sonnet 5, Claude Opus 5, Claude Haiku 4.565,00099.84%0.09%0123

* MAE: Mean Absolute Error percentage against official provider usage.prompt_tokens. P50/P90/P95/P99 represent absolute token error percentiles.

Why Client-Side Counts Differ Slightly from API Usage Bills

When a developer submits a prompt through an official SDK or REST API, the provider wraps the prompt content with structural framing before feeding it to the model:

1. ChatML & Role Envelopes

In OpenAI and compatible Chat completion APIs, each message is encapsulated with delimiter tokens:

<|im_start|>user Your prompt text here<|im_end|>

This contributes 3 to 4 delimiter tokens per message, plus 3 assistant reply priming tokens (<|im_start|>assistant ).

2. Provider Protocol Buffers & System Framing

Google Gemini Vertex AI and Anthropic Messages API translate JSON payloads into internal protobufs or system prompts before KV cache indexing:

\n\nHuman: ... \n\nAssistant:

This introduces a 1–3 token envelope variance that pure raw string tokenizers do not see unless explicitly operating in API Simulation mode.

TokenMath handles this by offering both Raw Text Mode (exact string tokenization) and API Protocol Mode (simulating ChatML/Anthropic delimiters) inside our Live Token Counter.

Test Corpus Composition & Methodology

The 10,000 benchmark prompts in this evaluation were synthetically generated and sampled from open-source repositories to represent real-world API traffic:

2,500 Prompts
Python & TypeScript Code
2,500 Prompts
Technical English Prose
2,000 Prompts
Multilingual (CJK, Arabic, Cyrillic)
1,500 Prompts
JSON Schemas & Tool Calls
1,500 Prompts
Markdown Tables & LaTeX
12 to 65k Tokens
Length Distribution

Verify Token Counts on Your Own Payloads

Switch between Raw Text and ChatML framing mode in our client-side token counter. Zero network transmission.

Launch Token Counter →