What you can do with this calculator
Every model charges per token, so knowing your token count up front is the only way to predict cost before you call an API. This tool counts the input tokens in your text, estimates a realistic output length, and computes the cost for each provider so you can compare models side by side and pick the right price-performance fit.
- Exact GPT tokenization. The OpenAI family is counted with the real o200k tokenizer; other models use calibrated estimates (English text is typically within ±15%).
- Output presets. Switch between RAG / Q&A, Chat, Full response and Long generation, or override the output token count directly.
- Cached input pricing. Where providers publish a cache-read rate, it’s shown so you can model prompt-caching savings.
- Sort & copy. Rank providers cheapest-first and copy any estimate to share.
Current API prices (June 2026)
All prices are USD per 1M tokens, from official provider pricing pages.
| Provider | Model | Input | Cached in | Output |
|---|---|---|---|---|
| OpenAI | GPT-5.5 | $5.00 | $0.50 | $30.00 |
| OpenAI | GPT-5.5 Pro | $30.00 | — | $180.00 |
| Anthropic | Claude Opus 4.8 | $5.00 | $0.50 | $25.00 |
| Anthropic | Claude Fable 5 | $10.00 | $1.00 | $50.00 |
| Gemini 3.5 Flash | $1.50 | $0.15 | $9.00 | |
| Gemini 3.1 Pro | $2.00 | $0.20 | $12.00* | |
| xAI | Grok 4.3 | $1.25 | $0.20 | $2.50 |
| DeepSeek | V4-Pro | $1.74 | $0.0145 | $3.48 |
| DeepSeek | V4-Flash | $0.14 | $0.0028 | $0.28 |
| Alibaba | Qwen3.7-Max | $2.50 | $0.25 | $7.50 |
| Z.ai | GLM-5.2 | $1.40 | — | $4.40 |
| MiniMax | M3 | $0.30 | — | $1.20 |
| Mistral | Large 3 | $0.50 | — | $1.50 |
* Gemini 3.1 Pro output pricing varies by source ($4–12); we use $12 as a conservative default.
Programming language token efficiency, ranked
The same task costs wildly different token counts depending on the language. Terse functional and dynamic languages stay compact; verbose low-level and enterprise languages burn more tokens for identical work. Averages below use a RosettaCode task with GPT-family tokenization as the baseline.
| Language | Avg tokens | Types | Verdict for LLM agents |
|---|---|---|---|
| J | ~70 | Dynamic | Ultra-compact, niche tradeoff |
| Clojure | ~109 | Dynamic | Best for long agent sessions |
| Ruby | ~119 | Dynamic | Very token-efficient |
| Python | ~128 | Dynamic | Strong balance of cost & readability |
| Haskell | ~130 | Static | Lean despite static typing |
| F# | ~136 | Static | Efficient typed option |
| Lisp | ~145 | Dynamic | Compact, less mainstream |
| Scala | ~166 | Static | Acceptable overhead |
| JavaScript | ~177 | Dynamic | Usable, not especially lean |
| Go | ~182 | Static | Moderate token cost |
| C# | ~216 | Static | Noticeable token tax |
| Java | ~224 | Static | High token tax |
| C++ | ~250 | Static | Expensive in long contexts |
| C | ~283 | Static | Worst for token efficiency |
FAQ
What is a token?
Tokens are the chunks of text models read and write. One token is roughly four characters of English (about ¾ of a word) — so “ChatGPT” is about two tokens. Different models tokenize slightly differently, which is why counts vary per provider.
How accurate are the token counts?
The OpenAI family is exact (we run the real o200k tokenizer in your browser). Other providers don’t publish official JavaScript tokenizers, so those counts are calibrated estimates — usually within ±15% for English, with more variance for code and non-Latin scripts.
Why estimate output tokens?
Output tokens are usually the larger cost (often 3–6× the input rate), but you don’t know the exact length until the model responds. The presets give a realistic range by task type so your estimate is closer to the real bill.
What is cached input?
Many providers cache repeated prompt prefixes and bill cache reads at a steep discount (often ~10% of the input rate, and far less for DeepSeek). If you reuse a long system prompt, cached pricing can cut input cost dramatically.
Pricing snapshot: June 2026, compiled from official provider docs and our 2026 LLM landscape. Verify on the provider’s pricing page before relying on it. Runs entirely in your browser — no text is sent anywhere.