A prompt is billed by the token, and a token is not a character, a word, or a syllable. It is whatever one model's tokenizer decided to keep together. That is why an estimate made with "four characters per token" can be 30% wrong on the code you are about to send ten thousand times, and why the first step of any serious cost model is counting the prompt the way the provider will count it.
What a token actually is
Every current frontier model reads text through a byte-pair encoding (BPE). The tokenizer starts from raw bytes and repeatedly merges the most frequent neighbouring pairs until it has a vocabulary of somewhere between a hundred thousand and a few hundred thousand entries. OpenAI's o200k_base, used by GPT-4o and the GPT-6 family, has roughly 200,000 entries. Anthropic and Google use their own vocabularies, trained on their own mix of text.
Two consequences follow. First, common words are single tokens: the, model,
price. Second, rare or compound strings are split: tokenization becomes two tokens,
antidisestablishmentarianism becomes six, and a random identifier like usr_7f3a91c becomes
eight. The vocabulary is a frequency table of human language, and your prompt is billed at the resolution
of that table.
Why "characters divided by four" fails
The rule of thumb exists because ordinary English prose really does average about four characters per token. The moment the text stops being ordinary prose, the rule drifts:
- Code runs at roughly 3.3–3.6 characters per token in our samples, because indentation, brackets and camelCase names all break into pieces.
- JSON is worse: repeated keys, quotes and braces push it toward 2.5–3.5 characters per token, and pretty-printed JSON wastes tokens on whitespace that carries no meaning.
- Korean measured about 1.7 characters per token and Chinese about 1.35 in our tests — the same paragraph translated costs two to three times as many tokens as it did in English.
- Numbers are grouped in runs of up to three digits, so
2026costs two tokens and20261118costs three — and a formatted amount like$1,284.50costs six.
None of this is exotic. A retrieval-augmented app that pastes five JSON documents into every request is paying for JSON tokenization on every call, and a multilingual support bot can be spending most of its budget on scripts the pricing page never mentions.
The parts of a request you forget to count
The prompt you typed is not the whole input. Providers bill every token in the request, which usually includes:
- A system prompt or instruction block, often hundreds of tokens, repeated on every call.
- Conversation history, which grows with each turn of a chat and is resent in full unless you truncate or summarise it.
- Tool and function schemas: the JSON describing your tools is input on every single call, even when no tool is used.
- Retrieved context from a vector store or a search step.
- For images and audio, a token cost that depends on resolution or duration rather than text length.
A support assistant with a 600-token system prompt, a 900-token policy excerpt and three 400-token tool schemas starts every conversation at 2,700 input tokens before the customer says anything. Multiply that by a million conversations and the "prompt length" you were optimising is a minority of the bill.
How to count before you spend
There are three honest methods, in increasing order of exactness:
- Estimate with a calibrated model. TokenLedger's fast estimator weights word lengths, punctuation, digits, whitespace runs and script mix, fitted against real o200k_base counts. On 286 mixed samples its mean absolute error was 4.6%. Good enough to decide whether a design costs ten dollars or a thousand, not good enough to reconcile an invoice.
- Count with the real vocabulary. For OpenAI models the page loads the o200k_base vocabulary once and runs the same byte-pair merges tiktoken does, locally. That is an exact count, and it also proves the estimate's error on your own text.
- Read the provider's numbers. Every response includes a usage object; both Anthropic and Google offer a counting endpoint. Once you have a week of production usage, stop estimating and paste the measured averages into the simulator.
A worked comparison
Take a prompt of 1,200 input tokens and a 350-token answer, sent 1,000 times a day. On GPT-6.2 Sol ($2 input, $10 output per million) that is $0.004988 per call and about $150 a month. The same workload on GPT-6.2 Astra ($8 / $40) is $0.019952 per call, or about $599 a month — four times the price for the same token count, because the output rate dominates. Now shorten the prompt by 400 tokens through better retrieval: the Sol bill falls to roughly $126, while the Astra bill falls to about $503. The absolute saving is larger on the expensive model, which is the useful lesson: prompt hygiene pays in proportion to the price you pay per token.
Where estimates still go wrong
Even an exact tokenizer cannot tell you the bill by itself. Retries, agent loops, reasoning tokens billed as output, cache writes, long-context multipliers and images all sit outside the token count. Use the count to compare designs, then add a buffer — 10% for a stable workload, 30% for an agent that retries — before the number goes into a budget. The calculator's job is to make the comparison honest, not to promise the invoice.