How Many Tokens Is Your Prompt? A Practical Guide to LLM Costs
Every LLM invoice comes down to one number: tokens. Miscount them by 20% and you'll be off by 20% on cost, latency and how much context you can actually pack into a request. This post is the plain-English guide: what a token is, how to count it accurately, and five levers that cut your spend without hurting output.
What a token is (and isn't)
A token is a chunk of text the model treats as a single unit. It is not a word, a character or a syllable. Models split text using byte-pair encoding (BPE) or SentencePiece, which learns common substrings from the training data.
Rules of thumb for English:
- 1 token ≈ 4 characters.
- 1 token ≈ 0.75 words.
- 100 tokens ≈ 75 words ≈ a short paragraph.
- Rare words and non-Latin scripts (Arabic, CJK, emoji) use more tokens per character.
Input vs output tokens
You pay for both, but at different rates. Output tokens are almost always more expensive — often 3–5× the input price — because generation is more compute-intensive than reading. When you estimate cost, compute the two halves separately and add them.
Rough 2026 rates (check the official pricing page for the latest):
- GPT-4o Mini — $0.15 / M input, $0.60 / M output.
- GPT-4o — $2.50 / M input, $10.00 / M output.
- Claude 3.5 Sonnet — $3.00 / M input, $15.00 / M output.
- Gemini 1.5 Flash — $0.075 / M input, $0.30 / M output.
How to count tokens accurately
Each family uses a different tokenizer, so counts vary between GPT, Claude and Gemini for the same input. The right way to check is with the model's own tokenizer:
- OpenAI GPT-4o / 4o mini:
o200k_baseencoding viatiktoken. - Claude: Anthropic's
count_tokensendpoint or the shipped tokenizer. - Gemini:
countTokensin the Gemini SDK.
If you don't want to install SDKs, paste the text into our Token Counter and pick the model — it runs the correct tokenizer in your browser and shows both input and estimated output cost.
Five levers to cut token spend
- Shorten the system prompt. System prompts are paid for on every call. Trim examples, delete role-play preambles, and move rarely-used rules into few-shot examples that only run when needed.
- Cap max output length. Setting
max_tokensis a hard ceiling — the model can't spend more even if it wants to. - Retrieve, don't stuff. Instead of sending a 50-page manual, chunk it, embed it, and retrieve the top 3 passages. You'll cut prompt tokens 10–100×.
- Use a cheaper model for the easy 80%. Route simple classification and rewriting to GPT-4o Mini or Gemini Flash. Reserve GPT-4o and Claude Sonnet for hard tasks.
- Cache what's stable. Providers now offer prompt caching — repeated system prompts and long documents can drop to 10% of the input rate on cache hits.
Common mistakes
- Estimating tokens as words. You'll be off by 25–40% depending on the tokenizer and the language.
- Forgetting the conversation history. In a chat loop, each turn re-sends every prior message. Tokens grow quadratically unless you summarize or truncate.
- Ignoring image and audio tokens. Vision inputs are billed by tile size; audio by seconds. Both convert to token-equivalents your text-only estimate misses.
Check any prompt right now
Paste your prompt into the Token Counter, pick the model you plan to use, and see tokens plus a monthly cost projection based on your request volume. Everything runs in your browser — no key upload.
Keep reading
How to Format JSON in JavaScript (2026 Guide)
Learn every practical way to format, pretty-print, indent, and validate JSON in JavaScript — with copy-paste examples for Node.js and the browser.
Base64 Encoding Explained: What It Is and When to Use It
Base64 in one plain-English guide: how it works, when to use it, when NOT to, and how to encode and decode it in every major language.