A token is the chunk of text — usually a word, part of a word, or punctuation — that an LLM processes in one step. Billing, context limits, and speed are all measured in tokens.
Before a model sees text, a tokenizer splits it into numeric IDs the network can understand. Different models use different tokenizers — OpenAI's GPT-4 uses tiktoken (cl100k_base), Anthropic uses a variant of BPE, Google uses SentencePiece (OpenAI tiktoken docs, 2024).
The word "hamburger" may be 1 token in one tokenizer and 3 tokens ("ham", "bur", "ger") in another. Emojis, Chinese characters, and code symbols often cost more tokens than plain English.
Tokenization uses byte pair encoding (BPE) or similar. The algorithm scans a huge text corpus and merges the most common character pairs into single tokens. Frequent words like "the" become one token. Rare words split into subword pieces.
The model then maps each token ID to an embedding vector and processes them all in parallel through attention layers.
python\nprint(1)" = ~8 tokens (code is token-heavy)| Unit | Average size |
|---|---|
| Character | 1 |
| Token | ~4 characters |
| Word | ~1.3 tokens |
Languages without spaces (Chinese, Japanese, Thai) and non-Latin scripts (Arabic, Hindi) often cost 2-3x more tokens per character, which is a fairness concern flagged by Stanford HAI (2023).
How do I count tokens? Use OpenAI's tiktoken library or Anthropic's token counter API.
Are input and output tokens priced the same? No — output tokens are usually 3-5x more expensive.
Does a space count as a token? Usually a leading space is merged into the next token (" cat" is one token).
Do images or audio use tokens? Yes — multimodal models convert images into image tokens (often 85-1500 per image).
What is the biggest context window in 2026? Several models offer 1M+ tokens.
Why do non-English prompts cost more? Because tokenizers are trained mostly on English text.
Can I reduce tokens? Yes — strip whitespace, avoid markdown decoration, use short variable names.
Tokens are the currency of LLMs. Understanding them is the difference between a $10 bill and a $1000 bill. Read more primers on Misar Blog.
Free newsletter
Join thousands of creators and builders. One email a week — practical AI tips, platform updates, and curated reads.
No spam · Unsubscribe anytime
The top free AI prompt libraries of 2026 — curated collections of tested prompts for ChatGPT, Claude, Gemini, and open m…
A complete list of 25 free AI writing tools in 2026 — Claude, ChatGPT, Gemini, Grammarly, QuillBot, Hemingway, and more…
The top free AI image generators in 2026 — DALL-E via Bing, Gemini, Ideogram, Leonardo, Stable Diffusion, Flux — with qu…
Comments
Sign in to join the conversation
No comments yet. Be the first to share your thoughts!