How this AI token calculator works
Large language model APIs usually bill by tokens rather than by words. This page estimates token usage from your prompt, adds the expected output length, and applies the selected model's per-million-token input and output prices.
The token count is an approximation. English text, code, punctuation, whitespace and CJK characters can be split differently by each provider's tokenizer, so the final billed number may not match this estimate exactly.
Use the estimate to compare prompt sizes, model choices and expected output length before sending production traffic. For final budgeting, check the provider's current pricing, tokenizer behaviour, caching rules and account-specific settings.
The estimation method
The same rule is used for every model: each consecutive run of Latin letters, combining marks or digits contributes the larger of 1.33 or its Unicode character count divided by 4. Each Chinese, Japanese or Korean character adds 1.5; each punctuation character adds 1; other Unicode characters add 2 each. Whitespace adds 1/8 per character. The total is rounded up; an empty or whitespace-only prompt returns zero.
This is a rough text heuristic, not a measured accuracy guarantee. Repeated strings, code, emoji and languages can differ substantially from a model's tokenizer. The estimate omits message wrappers, system messages you have not pasted, tools, images and audio. It cannot confirm that a request fits a model's context window. Selecting another model changes the stored prices, not the token estimate.
Check the calculation yourself
- With expected output set to 0, Hello world produces 3 estimated input tokens: 1.33 + 1/8 + 1.33, rounded up. 你好世界 produces 6: four CJK characters × 1.5.
- A run of 10,000 letter a characters produces 2,500 estimated input tokens (10,000 ÷ 4). These are reproducible examples of this page's rule, not official token counts.
For a non-empty prompt, cost = (estimated input tokens × displayed input price + expected output tokens × displayed output price) ÷ 1,000,000. The batch figure multiplies this by 1,000; it does not apply a batch discount.
Official prices and token counting
Check model availability and current rates at the provider. Use its counting tools and the full request for a model-specific count, then check actual usage in the API response.
Local processing note
The prompt estimate runs in your browser. This page does not require API keys and does not call the selected model to calculate the estimate.
Good use cases
- Compare the size of prompt drafts; use the provider's counter to check a context limit.
- Compare high-quality and low-cost models before building an API workflow.
- Estimate the cost of a batch job with hundreds or thousands of similar calls.
- Adjust expected output length to understand why generated text can dominate cost.
How accurate is this AI token calculator?
It is a planning estimate, not an official tokenizer. Exact token counts depend on the model tokenizer, message format, system prompts and provider billing rules.
Why are output tokens often more expensive?
Generating text is usually priced higher than reading input. That is why long answers can cost more than the prompt that triggered them.
Does this include cached tokens or batch discounts?
No. The main calculation uses standard input and output token prices only. Cached tokens, batch mode, regional processing and tool usage can change the final cost.