Token Estimates Make Requests Easier to Trust
A useful token count starts with the whole request
A prompt that looks short on screen can still produce a surprisingly large API request. Your application may also send earlier messages, system instructions, tool definitions, and documents. Counting tokens before sending helps you spot that hidden weight, check whether the request fits, and make a more realistic spending estimate.
A token is a piece of text represented in a model’s vocabulary. It might be a word, part of a word, punctuation, or a space combined with nearby text. Tokens are not the same as words, and different models can divide the same sentence differently.
For ordinary English prose, one token often corresponds to roughly four characters. That is a planning shortcut, not a dependable measurement. Numbers, unusual names, source code, and other languages can behave differently. Use the shortcut to judge scale, then use a model-appropriate counting method when precision matters.
The model determines the right counting method
Start by selecting the model you intend to call. A tokenizer designed for another model can return a plausible number that is still wrong for your request. Even related models may use different tokenization or request formatting.
If the provider offers a token-counting endpoint for that model, it is generally the best starting point. Submit the same supported request content you plan to send for generation. Check its documentation for coverage and limitations, especially around tools, images, and other non-text inputs.
A supported local tokenizer is another useful option for text. It can help you measure drafts without sending their contents to a remote service. However, counting only the visible message text may omit formatting or metadata that the API includes. Treat the result as an estimate unless the provider documents an exact match.
Conversation history can outweigh your newest message
Count everything your application will actually transmit, not just the latest question. In many chat applications, each turn resends earlier conversation messages. A short follow-up can therefore carry a long input.
- Include system instructions and any other instruction messages your API supports.
- Include conversation history, retrieved passages, and attached text.
- Include tool definitions and tool results when they are part of the request.
- Use provider guidance for images, audio, and other inputs that need more than a text tokenizer.
This inventory often reveals the simplest improvement: remove duplicated instructions, irrelevant search results, or old tool output. Keep information needed for a correct answer. Trimming without regard to meaning can reduce token use while making the response less useful.
Your input budget must leave room for output
A model’s context window is the capacity available for processing a request and its continuation, subject to that model’s rules. Filling it with input can leave too little room for a useful reply. Models may also have a separate maximum output limit.
Suppose your estimated input is 12,000 tokens and you want up to 2,000 tokens of output. Plan for both, then leave a margin for counting differences and model-specific overhead. For models that use reasoning tokens, check how those tokens affect output limits and billing. An output allowance is a ceiling, not a promise that every response will consume it.
Estimated tokens and billed usage serve different purposes
A preflight count supports planning; the response’s usage report records actual consumption under the provider’s accounting rules. Input, output, cache reads, and cache writes can have different prices. A token total alone is therefore not a complete cost estimate, and a cache hit should not be assumed before the request runs.
BestRelay forwards each request to the official model named in it, without substitution, across Claude, GPT, Gemini, DeepSeek, Kimi, GLM, Qwen, Grok, and more. It works with Claude Code, Codex, Gemini CLI, and any OpenAI SDK. Its pay-as-you-go billing uses provider-reported token counts, with cache reads and writes priced separately.
Create a BestRelay account to try this workflow. Members can also earn a referral commission when invited users top up. For everyday budgeting, keep your estimated count beside the returned usage, investigate recurring differences, and adjust your margin as your application evolves.
Want to try the models discussed here? Sign up