What Is a Token? Understanding How LLMs Measure Text, Cost, and Context
Tokens are the units large language models use to process text, calculate usage charges, and manage context limits. This article explains how tokenization works, why tokens do not map directly to words or characters, how input and output pricing differs, and how to estimate and control token consumption in AI applications.
1. What Is a Token?
In a large language model (LLM), a token is a basic unit of text processing. Whether you submit English prose, Chinese text, code, numbers, or symbols, a tokenizer first splits and encodes that content into a sequence of tokens. The model processes this encoded sequence rather than the text as you see it on screen.
Think of the model’s workspace as a table covered with standardized information cards. Your input is converted into cards, and the model performs its subsequent processing—understanding, reasoning, and generation—using those cards. Each card represents one token.
A token is not necessarily a word or a character. Tokenization methods, such as subword tokenization and byte-pair encoding, determine how text is divided. Common patterns include:
- A common English word, such as “apple,” may be represented by one token.
- A less common English word may be split into two or three tokens.
- Chinese characters do not have a fixed one-to-one relationship with tokens. With some tokenizers and texts, a rough estimate might be around 1.3–1.5 Chinese characters per token.
- Punctuation, spaces, and numbers also contribute to token usage, although they are not necessarily encoded as separate tokens.
These are estimation guidelines, not universal rules. The actual count depends on the tokenizer and the text.
2. A Common Mistake: Assuming One Token Equals One Character
A frequent mistake when estimating cost or capacity is to assume that one character always equals one token. This is especially unreliable for Chinese text, where a tokenizer may encode multiple characters together.
Using the approximate ratios above, illustrative estimates would be:
- A document containing 1,000 Chinese characters might use roughly 700 tokens.
- A report containing 300,000 Chinese characters might use roughly 200,000 tokens.
At scale, the difference can materially affect a project budget. Suppose you want to summarize an enterprise knowledge base containing 500,000 Chinese characters. At 1.5 characters per token, the input would be approximately 333,000 tokens. Estimating it as 500,000 tokens instead would overstate the token count—and the corresponding input cost—by about 50%.
However, a character-to-token ratio is not fixed. Chinese prose, mixed Chinese-English technical documents, code, and tables containing many numeric identifiers can have substantially different token densities. Depending on the tokenizer, actual counts may also be higher than these illustrative estimates.
Before integrating a model service, use its official token-counting tool to measure representative samples. Build your cost model from those measurements rather than relying solely on a general conversion ratio.
3. Token-Based Pricing: Input Versus Output
Many mainstream LLM services charge for text processing based on token usage rather than word count or elapsed time. Token charges generally distinguish between two categories:
- Input tokens: The questions, instructions, conversation history, and reference material submitted to the model.
- Output tokens: The responses and other content generated by the model.
Why Does Output Often Cost More?
Input processing can handle many token positions in parallel. Output generation, by contrast, is typically autoregressive: the model generates each new token based on the preceding context.
This sequential generation is more computationally demanding in ways that affect serving costs. Output token rates are therefore often higher than input token rates—sometimes around two to three times higher—although the actual ratio depends on the service and model.
The practical lesson is straightforward: managing both prompt length and output length is central to cost control.
For long-document question answering, avoid sending the entire document with every request. Instead, retrieve relevant sections and include only those sections in the context.
For long reports, generating an outline first and then producing individual sections can improve control over quality and make budgets easier to manage. This approach still requires tracking the tokens consumed across all calls.
4. The Context Window: How Much the Model Can Hold
Cost is only one constraint. Another is the context window, which limits the total number of tokens a model can accommodate in a single interaction.
Return to the workspace analogy: input cards occupy the table, and generated cards accumulate on that same table. The table has a finite capacity. Different models offer windows ranging from tens of thousands to hundreds of thousands of tokens.
In general, the input and generated output must fit within the model’s supported context limit.
This has several implications:
- A book containing a million characters may be too large to submit in full in a single request.
- In a multi-turn conversation, retained message history continues to consume context space.
- Very long content requires a processing strategy, such as summarizing sections and combining the summaries, or using retrieval-augmented generation (RAG).
When designing an application, reserve enough context capacity for the expected output. Also trim older conversation messages or compress them into summaries as needed.
Without this management, a request may exceed the context limit and fail, or earlier information may be removed when the application truncates its history.
5. A Simple Framework for Estimating Token Costs
Start with two measurements:
- Token density: How many tokens representative text consumes. For example, 1.4–1.5 Chinese characters per token might be a starting estimate for some samples, but it should be verified.
- Model pricing: The applicable input and output token rates.
Then use a basic cost model:
Estimated cost per call ≈(Input tokens × Input price per token)+ (Expected output tokens × Output price per token)Estimated daily cost ≈Cost per call × Daily call volume × (1 + Retry allowance)
If prices are quoted per thousand or per million tokens, convert them to per-token rates or scale the token counts accordingly before using the formula.
Alongside estimation, apply practical controls:
- Reuse and streamline prompts. Remove redundant instructions and irrelevant context.
- Use lighter models for preprocessing. Handle classification and routing with smaller models, reserving more capable models for the core reasoning tasks.
- Limit output length. Where supported, use
max_tokensto prevent unexpectedly long responses. - Track actual consumption. Log input and output token usage, then use production data to refine your estimates.
A measured token density and realistic output estimate provide a more useful budget than a character count alone.
6. Tokens Are an Engineering Resource
Understanding tokens means understanding how LLM services measure their work: how text is divided, how usage is billed, and how context capacity constrains application design.
Three principles matter most:
- Tokens do not map directly to words or characters.
- Input and output tokens can have different prices.
- The context window limits how much input and output can fit in one interaction.
Applying these principles helps you assess an AI application’s cost and feasibility before implementation. Even when token prices are affordable, treating tokens as a managed engineering resource can prevent estimation errors and improve operational efficiency.
