What is a token in AI?

Updated 2026-08-02AI-assisted draft · citations disclosedPart of the 1,478-question editorial index· prompt engineering and LLM · Source & maintenance record
Short answer

An AI token is a model-specific piece of input or output—sometimes a character, word fragment, word, space or punctuation mark—that a tokenizer maps to an ID. Text models process token sequences, and many APIs report or bill input and output tokens separately. A token is not a universal word count: the exact number depends on the model, encoding, language, formatting and any images, audio, video or tools in the request.

Why — the first-principles explanation

A language model does not receive your sentence as a bag of ordinary words. A tokenizer turns the input into a sequence of pieces and maps those pieces to numeric IDs from a model’s vocabulary. Common pieces may be kept together; rarer words, punctuation, whitespace or unusual strings may be split differently. The model then operates on that sequence and generates another sequence of tokens that an application decodes back into text.

“Token” is therefore an implementation unit, not a universal measurement. The same visible text can produce different counts with different model families, encodings, languages, casing, spaces, JSON formatting or code. Rules of thumb such as “a few characters per English token” can orient you, but the exact count belongs to the target model and request format. Treat any shortcut as a rough estimate, never as an invoice.

Tokens matter because a request has a context window and a usage record. The context window is the provider-defined space for the current input, conversation history, system instructions, tool definitions, files or multimodal inputs, and the generated response. Longer input can leave less room for output or force chunking. Providers may report input, output, cached, reasoning, tool or modality-specific token counts, and prices can differ across those categories. A plan limit, API rate limit and context limit are related but not interchangeable.

Multimodal APIs may tokenize more than visible text. Google documents token accounting for text, images, video and audio; Anthropic’s counting endpoint accepts structured messages with system prompts, tools, images and PDFs. This is why “the paragraph is short” does not guarantee a cheap or small request. Tool schemas, retrieved passages, image resolution, conversation history and hidden service-added tokens can all affect usage.

The practical workflow is simple: identify the exact model and endpoint, count the complete request with the provider’s tokenizer or count endpoint, compare the estimate with response usage metadata, then budget input, output, caching, tool calls and retries separately. If a request is too large, retrieve only relevant passages, summarize or chunk it, and preserve the source for verification. A lower token count may save money, but it does not make an answer more accurate.

An example that makes it click

Imagine a work request with a system instruction, your question, a retrieved policy document, a function definition and a requested answer. The billable or rate-limited input is not just the sentence you typed: the provider may count the whole structured request. The response then adds output tokens. If you change models or rewrite the same content as verbose JSON, recount it with that model’s tokenizer before comparing cost or context fit.

How to do it

  1. Name the provider, model, endpoint and modality. A chat app, API, batch job and multimodal request can count tokens differently.
  2. Build the complete request you intend to send, including system or developer instructions, conversation history, tool schemas, retrieved text, files and formatting.
  3. Count it with the target provider’s tokenizer or count endpoint. Do not reuse a count from another model family or an older tokenizer.
  4. Set an output budget and check the model’s context-window and request-size limits. Input, output and reasoning budgets are separate controls even when they share a total window.
  5. Send a small representative request, then record the usage metadata returned by the API. Compare actual input, output, cached, reasoning and tool counts with your estimate.
  6. For long material, retrieve relevant sections, summarize in stages or chunk with overlap and source IDs. Keep enough context to verify the answer rather than truncating blindly.
  7. If the provider supports prompt caching, separate stable instructions from changing content and measure cache reads and writes; caching can change cost without removing context limits.
  8. Estimate cost per accepted result: include input, output, cached or reasoning charges, tool calls, retries, latency and human editing—not just the token line item.
  9. Protect the data inside the token stream. Review retention, training use, logging, access and deletion terms before sending personal, confidential or regulated material.

Key facts

Infographic: What is a token in AI — short answer and key facts
Visual summary — What is a token in AI?

Turn token counts into a usable AI budget

Compare models and workflows by exact token usage, context fit, data controls and cost per accepted result.

▶ The 60-second explainer (script)

What is an AI token? It is a model-specific piece of input or output that a tokenizer maps to a numeric ID. A token can be a character, word fragment, word, space or punctuation mark. The model processes token sequences and generates another sequence. Tokens matter for three reasons: context, limits and cost. Your request may include system instructions, conversation history, tool definitions, files and even image, audio or video inputs—not just the sentence you typed. Providers may report input, output, cached, reasoning and tool-use tokens separately. The shortcut of about four English characters per token is only a rough estimate. For a real budget, count the complete request with the target model’s tokenizer, compare it with usage metadata, then include retries, tools, caching and human review in the cost per accepted result.

What authoritative sources say

OpenAI Developers — Counting tokensofficial — OpenAI’s token-counting guide explains that an exact input count can include text, messages, images, files, tools and conversations, including formatting tokens added by request structure. source ↗
OpenAI Developers — Counting tokensofficial — OpenAI documents why local tokenizers can miss tools, schemas and model-specific behavior, and recommends the input-token counting interface for accurate request counts. source ↗
Anthropic Docs — Token countingofficial — Anthropic’s token-counting endpoint accepts structured messages with system prompts, tools, images and PDFs and returns an input-token estimate before sending a message. source ↗
Anthropic Docs — Context windowsofficial — Anthropic defines the context window as the input and generated response space, including system prompts, messages, tool results, images and documents, with model-specific limits. source ↗
Google AI for Developers — Understand and count tokensofficial — Google explains that Gemini tokenizes text and non-text inputs including images, video and audio, and exposes count-tokens and usage metadata for input, output, thinking, cached and tool-use tokens. source ↗
OpenAI — Pricingofficial — OpenAI’s pricing page is the current place to check plan and API pricing rather than relying on a static token-rate claim in an explainer. source ↗

People also ask

What is an AI token in one sentence?

It is a model-specific piece of input or output—such as a character, word fragment, word, space or punctuation mark—that a tokenizer maps to an ID.

How many words are in one token?

There is no universal conversion. A rough English shortcut can help you estimate, but the true count depends on the model, language, formatting and tokenizer; use the target model’s count endpoint for a real request.

Do spaces and punctuation count as tokens?

They can. Tokenizers may attach spaces to neighboring pieces or represent punctuation separately, so count the exact text with the tokenizer for the model you will use.

Is a token the same as a word?

No. Common words may be one token, while long, rare, misspelled or non-English strings can become multiple pieces. Some tokens also represent whitespace or punctuation.

What is a context window?

It is the provider-defined token capacity for the request’s context and generated response. It may include history, system instructions, tools, documents, images and other inputs; check the model-specific documentation.

What are input and output tokens?

Input tokens are what you send, including relevant structured context. Output tokens are what the model generates. Providers may also report cached, reasoning or tool-use tokens, with separate limits or prices.

Do images, audio and video use tokens?

Many multimodal APIs tokenize non-text inputs too. The conversion is provider- and model-specific, so use its count endpoint or usage metadata rather than a text-only estimate.

How can I count tokens before sending a prompt?

Use the provider’s tokenizer or count-tokens endpoint for the exact model, including system messages, history, tools and files. Then compare the estimate with the response usage field.

Why can the same paragraph have different token counts?

Different tokenizers, languages, scripts, capitalization, whitespace, code and serialization formats split the same visible text differently. Recount after changing the model or formatting.

Do more tokens make an AI answer better?

Not necessarily. More relevant context can help, but irrelevant or repetitive context can increase cost and reduce recall. Curate sources, chunk long material and verify the result.

The same question, asked other ways

This page answers one intent expressed in 6 phrasings. How the index is organized →

Related questions