Tokens

Tokens are the small chunks of text, often word pieces, that a language model actually reads and generates; they are the unit used to measure context windows, speed and usage billing.

Also known as: Tokenization, subword tokens

Related terms in this glossary

How it works

Before a model sees text, a tokenizer splits it into pieces from a fixed vocabulary, commonly using byte-pair encoding. Common words are often a single token, while rare words, code and numbers split into several. OpenAI's documentation gives a rule of thumb that one token is about four characters or three quarters of a word in English. Each model family has its own tokenizer, so the same text can produce different counts on different models.

  • Input tokens: everything sent, including system prompt, history and documents.
  • Output tokens: everything generated, usually billed at a higher rate than input.
  • Reasoning tokens: internal thinking some models produce before answering, also billed.
  • Image and audio tokens: media converted into token equivalents.

Why it matters

Tokens drive three things a buyer cares about: cost, latency and what fits in the context window. Non-English text often needs noticeably more tokens for the same meaning, which affects both cost and speed for Indian-language applications and should be checked per model. Practical steps to control token use include trimming long system prompts, retrieving fewer but better passages, capping output length, caching stable prefixes and routing simple requests to smaller models. Use the provider's token-counting tool or tokenizer library to measure real prompts rather than estimating. Gepton works on this in AI cost optimization.

Tokens in depth

Counting and budgeting tokens

Token usage is easiest to control when it is measured per part of the request. A practical breakdown for each AI feature:

  • System prompt and tool definitions: fixed per request; long tool lists add up quickly.
  • Retrieved context: often the largest input, driven by how many passages are sent and how long each is.
  • Conversation history: grows with every turn unless summarized or trimmed.
  • User input: usually small, unless users paste documents.
  • Output and reasoning: controlled by maximum output settings, instructions about length and the reasoning effort chosen.

Measure these with the provider's token counting endpoint or the model's tokenizer library, such as tiktoken for OpenAI models, and log actual usage returned in every response.

Example: trimming an assistant's token use

Example: a support assistant's traces show that a typical request sends a long system prompt, twenty retrieved passages and the full conversation history. The team makes four changes: it moves rarely used instructions into a tool the model can call when needed, adds reranking and sends the best five passages instead of twenty, summarizes conversation turns older than the last few, and enables prompt caching for the stable prefix. Each change is evaluated on the same test set to confirm answer quality holds. Input tokens per request fall substantially, latency improves and quality scores stay level. The team adds a dashboard showing tokens per resolved conversation, not just per request.

Tokens and Indian languages

Tokenizers are built from training text, and many were built from English-heavy data. As a result, Hindi in Devanagari and other Indian scripts can need several times more tokens than English for the same meaning on some models, while newer tokenizers have narrowed the gap. Romanized Hindi behaves differently again. For Indian-language products:

  1. Count tokens for real sample messages in each language on each candidate model.
  2. Factor the difference into context limits, latency and running cost estimates.
  3. Consider whether replies can be shorter, and whether retrieved passages can stay in English while answers are in Hindi.

Measuring token efficiency

MeasureWhy
Input and output tokens per request, by featureShows where usage comes from
Tokens per completed taskAgents may take many calls per task; per-call numbers hide that
Cached input shareConfirms caching works
Output tokens at high percentilesFinds runaway responses

Our agent running cost tool turns token estimates into a running cost picture for an agent.

Set alerts on token usage as well as reports. A sudden rise in tokens per request often signals a bug, such as a loop in an agent, a retrieval step returning whole documents, or a prompt template duplicating history, and catching it within hours avoids a surprise at month end.

Typical problems are estimating tokens from word counts, ignoring tool definitions and reasoning tokens, unbounded conversation history, and no maximum output setting. Tokens define the context window, drive AI latency, are shaped by temperature at generation time, and are the target of model routing and caching. Gepton reduces token spend in AI cost optimization.

Questions about Tokens

Something else? Send us your question and an engineer replies with next steps.

Do images count as tokens?

Yes, for models that accept images. The provider converts each image into a number of tokens, usually based on its resolution, and bills them as input. The conversion rules differ between providers and models, and some offer low-detail modes that use fewer tokens. Resizing or cropping images before sending them often reduces usage without hurting accuracy. Check usage reports to see actual token counts for your images.

Why does the same text have different token counts on different models?

Each model family uses its own tokenizer, with its own vocabulary of text pieces learned from its training data. A tokenizer with more pieces for a language, such as Hindi or code, splits that text into fewer tokens. So the same paragraph can produce noticeably different counts on different models, which affects context limits and running cost. Always count with the tokenizer of the model you plan to use.

Articles that mention Tokens

All articles

Jump to

↑↓ to move↵ to open