Learn · general

Tokens

Tokens are the discrete units language models read and generate—commonly subword pieces—used for context limits, billing, and model input encoding.

Reviewed:

Short answer

A token is a chunk of text (often part of a word) converted to an ID the model understands. Context windows and API prices are usually measured in tokens.

Why it matters

Token budgets decide how much evidence you can include, how long answers can be, and what a feature will cost at scale.

Diagram

Diagram of text split into tokens before model input
Diagram of text split into tokens before model input

Article

Tokenization basics

Algorithms such as byte-pair encoding split text into subwords from a fixed vocabulary. Digits, whitespace, and non-English scripts may tokenize less efficiently than everyday English prose.

Code and JSON often consume more tokens than the same information in compact English.

Context and cost

Both input and output tokens usually count toward usage. System prompts, tool schemas, and retrieved chunks all spend budget before the user even sees an answer.

Practical counting

Use the model’s official tokenizer when accuracy matters. Rule-of-thumb word-to-token ratios are rough and language-dependent.

Product UX

Show users remaining capacity in human terms when possible (“about 20 pages”) while enforcing hard token limits server-side.

Security note

Extremely long inputs can be used for denial-of-wallet or context flooding. Enforce limits and authentication.

Working with Tokens in practice

Token budgets decide how much evidence you can include, how long answers can be, and what a feature will cost at scale.

Trailing whitespace, markdown fences, and repeated newlines can burn tokens silently—sanitize prompts in middleware.

Deeper intuition

A token is a chunk of text (often part of a word) converted to an ID the model understands. Context windows and API prices are usually measured in tokens.

Some languages tokenize to far more pieces per word than English; multilingual UX should budget accordingly.

Readers comparing approaches should keep Tokens connected to large-language-models, context-windows, tokenization, ai-apis, prompt-engineering, because isolated definitions rarely survive contact with production constraints.

Authoritative references for Tokens appear in the sources list—prefer primary papers, official documentation, and standards bodies over anonymous social threads when decisions have lasting impact.

Implementation checklist

Version prompts, model IDs, and retrieval configs as a unit.

Build a living eval set from real user failures, not only academic benchmarks.

Define quantitative and qualitative checks specific to Tokens before expanding scope.

Record known limitations of Tokens in your runbook so on-call responders do not rediscover them during incidents.

Evaluation and failure analysis

When Tokens underperforms, separate data issues, configuration mistakes, and true method limits. Jumping to a larger model without that triage repeats the same failures at higher cost.

Create a small gold set that represents the ugly cases—not only the demo cases—for Tokens. Re-run it on every prompt, model, or index change.

For user-facing features involving Tokens, track both helpful outcomes and harmful ones (privacy incidents, wrong actions, biased errors) so success metrics cannot hide safety debt.

Examples and FAQs in context

Budgeting RAG. You reserve 1,500 tokens for system+question, 6,000 for retrieved chunks, and 1,000 for the answer.

How many tokens are in a word? Often about 0.5–2 tokens for English words, but it varies widely; always measure with the real tokenizer.

What to read next

Continue from Tokens into large-language-models, context-windows, tokenization, ai-apis, prompt-engineering. If you are building a product, pair conceptual pages with the API, retrieval, and responsible-AI branches before wide rollout.

This article is educational and not legal, medical, or financial advice. Where Tokens intersects regulation or rights (privacy, copyright, employment decisions), consult qualified professionals and primary official sources for your jurisdiction.

Examples

Budgeting RAG

You reserve 1,500 tokens for system+question, 6,000 for retrieved chunks, and 1,000 for the answer.

FAQ

How many tokens are in a word?
Often about 0.5–2 tokens for English words, but it varies widely; always measure with the real tokenizer.

Related tools

  • OpenAI API Platform — Developer platform for GPT models, embeddings, tools, and multimodal APIs used to build AI products.
  • Anthropic API — Claude API for developers building apps with Anthropic models, tool use, and enterprise controls.
  • Google AI Studio — Google’s playground and gateway for prototyping Gemini models and obtaining developer API access.

Related rankings

  • Best AI API Platforms in 2026 — AI API platforms are for builders calling models in products. This ranking is distinct from coding IDEs and from…
  • Best AI Developer Tools in 2026 — Developer tools cover IDEs, app builders, and engineer search — adjacent to but broader than “best AI for coding”…

Related topics

  • Large Language Models — Large language models (LLMs) are neural networks trained on vast text corpora to predict tokens in context, enabling…
  • Context Windows — A context window is the maximum amount of text (tokens) a language model can consider at once—including the system…
  • AI APIs — AI APIs expose model capabilities—chat, embeddings, speech, images, and more—over programmatic interfaces so developers…
  • Prompt Engineering — Prompt engineering is the practice of designing instructions, examples, and context so generative models produce more…

Sources