Mindket

What is a token in AI, and how do models count them?

A dark blue banner titled "What is a token in AI, and how do models count them?" over "Understand tokens, context windows and AI usage." Beside it, the question is cut into tokens under a 200,000-token context window and a counter of 120 input and 80 output tokens.

A token is the piece of text a language model reads and writes: a whole word, part of one, a single character or a byte. Models measure both their context window and their price in tokens, and the same text splits into a different number of them depending on the model and the language. For English, OpenAI's rule of thumb is about four characters per token.

In short

  • Before you budget, count a real request on the model you'll use.
  • Keep your tool list the same from one request to the next, or the prompt cache starts over.
  • Start a new session when the topic changes, and turn off the skills and MCP servers you don't use.
On this page
  1. Tokens are pieces of text, not words
  2. How to count tokens before you send a request
  3. Input tokens, output tokens and the context window
  4. Prompt caching, for the part of a prompt that repeats
  5. Do installed skills and MCP servers cost tokens?
  6. From token counts to a monthly estimate
  7. Reference: the cache fields in usage, and each model's minimum
  8. Frequently asked questions
  9. Sources

Tokens are pieces of text, not words

Give Claude the system prompt "You are a scientist" and the message "Hello, Claude", and Anthropic's token counting page documents a count of 14 input tokens for those six words.

Before the model sees your text, a tokenizer cuts it into these units, the smallest a language model works with. Short common words are usually one token each, and a word's first token typically starts with the space before it.

An English rule of thumb doesn't carry over to Chinese or German, and even in English the vendors differ. Claude's newest models use a new tokenizer that cuts the same text into about 30 percent more tokens than the Claude models before them.

Rules of thumb for English text, from each vendor's documentation
ModelsAbout one token perSource
OpenAI models4 characters, or 0.75 wordsOpenAI API concepts page
Claude models before Claude 4.73.5 charactersAnthropic glossary
Claude 4.7 and laterAbout 30 percent more tokens than earlier Claude models for the same textAnthropic glossary and token counting page

How to count tokens before you send a request

That count came from Anthropic's token counting endpoint, which returns the input tokens a request would use without sending it. The count is an estimate and can differ from the real request by a small amount. Tokens Anthropic adds for system optimizations can show up in the count, and those aren't billed. Anthropic lists counting itself as free to use. It has its own requests-per-minute limit, set by your usage tier and separate from the limit on creating messages, so it doesn't eat into your sending allowance.

curl https://api.anthropic.com/v1/messages/count_tokens \
    -H "x-api-key: $ANTHROPIC_API_KEY" \
    -H "content-type: application/json" \
    -H "anthropic-version: 2023-06-01" \
    -d '{
      "model": "claude-opus-5-5",
      "system": "You are a scientist",
      "messages": [{
        "role": "user",
        "content": "Hello, Claude"
      }]
    }'
  1. Build the request exactly as you plan to send it: the model ID, the system prompt, the messages and every tool definition.
  2. Post it to /v1/messages/count_tokens instead of /v1/messages. The reply is one number, { "input_tokens": 14 } for the request above.
  3. Send images and PDFs as base64, since the endpoint refuses blocks that point to a URL or an uploaded file.
  4. Count again before you switch models: Anthropic suggests counting the same request on both and comparing the two input_tokens values.
  5. In Claude Code, run /context for a live breakdown of the session by category. /usage lists the input, output and cache tokens each model has used in the session.

Input tokens, output tokens and the context window

On the Claude API, input means the system prompt, every message with its tool results, images and documents, and your tool definitions. Extended thinking counts as output, and each response reports both in a usage field.

Input and output share the context window: all the text the model can refer to while it writes a response, the response included.

Chats grow because the history goes out again on every turn. One turn's reply becomes the next turn's input, and Claude Code sends your full conversation with every request. A one-line question at the end of a day-long session still draws usage for everything before it.

How much one request can hold, per Anthropic

1M

tokens of context in Claude Opus 5.5 and the other current models Anthropic lists

Source: Claude Platform docs: Context windows (read November 3, 2026)

128k

output tokens at most in one request to those models

Source: Claude Platform docs: Context windows (read November 3, 2026)

200k

tokens of context in the other Claude models

Source: Claude Platform docs: Context windows (read November 3, 2026)

More context isn't automatically better. As token count grows, accuracy and recall degrade, a phenomenon known as context rot. This makes curating what's in context just as important as how much space is available.

Anthropic, in its documentation · Claude Platform docs, Context windows (read November 3, 2026)
Claude's post on X: Claude Sonnet 4 now supports 1 million tokens of context on the Anthropic API, a 5x increase, enough for over 75,000 lines of code, posted 12 August 2025
Claude on X, 12 August 2025

Both X posts on this page are screenshots of X's own embeds, taken on 3 November 2026, with times in US Pacific time.

Prompt caching, for the part of a prompt that repeats

Most of the opening of an agent's request is the same every time: the system prompt, the tool definitions, the instruction file and the start of the conversation. Prompt caching lets the API resume from that stored prefix instead of processing it again, which Anthropic says cuts processing time and cost. The window doesn't grow, though: a cached prefix still takes its place there, and only the price of those tokens changes.

The prefix is built in a fixed order: tools first, then the system prompt, then messages, and it has to match exactly. Change one level and that level is invalidated along with every level after it, so editing a single tool definition clears the whole cache. An entry lives 5 minutes by default. Each hit refreshes it, and a 1-hour lifetime is also offered.

The "You are a scientist" request is far too short to be cached. A request under the model's minimum length runs without the cache even when it's marked for caching, and no error says so. Claude Haiku 4.5 has one of the highest minimums.

Alex Albert's post on X announcing that prompt caching has rolled out in the Anthropic API, with its claimed cuts to input cost and latency, posted 14 August 2024
Alex Albert of Anthropic on X, 14 August 2024

In Claude Code v2.1.251 or later, the Session block of /usage adds a Prompt cache line: the share of input tokens served from cache, and the number of misses.

Do installed skills and MCP servers cost tokens?

Yes, even in a session where none of them runs.

Every installed Agent Skill keeps its name and description in context from the start, so the agent knows it exists. The Agent Skills specification puts that at about 100 tokens a skill, and the body loads only when a task matches. In Claude Code, each agent and command Claude can call on its own has its name and description in context on every turn too.

Claude Code caps that list. Each skill's description, with its when_to_use text, is cut at 1,536 characters, and the whole listing gets a budget of 1% of the model's context window. Past that budget, Claude Code drops the descriptions of the skills you call least, and with them the words that would have triggered those skills. A rarely used skill can stop firing that way while it's still installed. /doctor estimates what the listing costs, and /skill-doctor finds skills worth turning off.

An MCP server adds tools, and each tool definition is input like any message. Claude Code defers them by default, so only tool names and server instructions enter context until Claude uses a specific tool. On the API, tool search does the same job: instead of 50 tool schemas up front, you send one tool_search tool and Claude looks up the rest on demand. Anthropic suggests it once a toolset grows past roughly 20 tools.

A CLAUDE.md loads whole at the start of every Claude Code session, which is why Anthropic suggests keeping it under 200 lines.

What sits in context before you ask anything
CLAUDE.mdAgent Skill Our pickMCP server
In context in a session where none of it runsYesYesYes
What sits thereThe whole file, from the start of every sessionEach skill's name and description, about 100 tokensTool names and server instructions, in Claude Code
The rest loads only when a task needs itNoYesIn Claude Code by default, on the API with tool search
Anthropic's size adviceKeep it under 200 linesA description is cut at 1,536 charactersAdd tool search past roughly 20 tools

Our pick: Agent Skill. Anthropic suggests moving workflow-specific instructions out of CLAUDE.md and into skills that load only when used.

Sources: Claude Code docs: Manage costs effectively (read November 3, 2026), Claude Code docs: Skills (read November 3, 2026), Claude Platform docs: Manage tool context (read November 3, 2026), Agent Skills specification (read November 3, 2026)

From token counts to a monthly estimate

Anthropic prices input, output and cache reads separately per million tokens, so a monthly estimate needs all three counts. Writing a cached part the first time costs more, which the calculator's page says makes the real saving a little lower.

The calculator's text and code fields, and where each number can come from
FieldWhere to find the number
AI sessions a day, days a monthYour own routine
Tokens read per session (thousands)/usage or /context in Claude Code, or input_tokens from the API
Tokens written per session (thousands)The output figure in /usage, thinking included
Share of what it reads that repeats (%)The Prompt cache line in /usage
Output you cut with shorter answers (%)A target you set, not a measurement
Sessions moved to the cheapest model (%)Your guess at the simple sessions a smaller model could take

Reference: the cache fields in usage, and each model's minimum

Each response's usage block splits the input three ways:

  • cache_read_input_tokens: tokens served from the cache on this request.
  • cache_creation_input_tokens: tokens written to the cache to create a new entry.
  • input_tokens: the rest, the tokens after the last cache breakpoint.
Smallest prompt that gets cached, by modelIn tokens. The highlighted bar is the model the text names.
  • Claude Opus 5.5512 tokens
  • Claude Sonnet 5.5512 tokens
  • Claude Haiku 5.5512 tokens
  • Claude Sonnet 51,024 tokens
  • Claude Opus 4.81,024 tokens
  • Claude Opus 4.72,048 tokens
  • Claude Opus 4.64,096 tokens
  • Claude Haiku 4.54,096 tokens

Source: Claude Platform docs: Prompt caching (read November 3, 2026)

We read the pages under Sources on November 2, 2026, and four of them again the next day, without testing anything hands-on. Model names, limits and Claude Code versions change often.

Frequently asked questions

How many words is 1,000 tokens?

About 750 English words, going by OpenAI's rule of thumb.

Do thinking tokens from earlier turns count again later?

On recent models, yes. They keep earlier thinking blocks in the conversation, where those blocks count as input on later turns, while older models strip them out. Thinking also comes out of your max_tokens and counts toward rate limits, since Anthropic bills it as output.

What happens when a conversation outgrows the context window?

The API refuses a request whose input alone is too long, with a 400 "prompt is too long" error. On Claude 4.5 models and newer, a request whose input fits but whose max_tokens would overflow is accepted. It stops with model_context_window_exceeded if it reaches the limit. Claude Code summarizes older history on its own as a session nears the limit.

Do CLI tools use fewer tokens than MCP servers?

Usually, yes. Tools such as gh, aws and gcloud add no per-tool listing, so Anthropic's Claude Code cost guide rates them as more context-efficient than MCP servers. Claude can run them in the shell, and /mcp lets you turn off servers you aren't using.

Sources

  1. Claude Platform docs: Glossary (read November 2, 2026)https://platform.claude.com/docs/en/about-claude/glossary
  2. Claude Platform docs: Token counting (read November 2, 2026)https://platform.claude.com/docs/en/build-with-claude/token-counting
  3. Claude Platform docs: Context windows (read November 3, 2026)https://platform.claude.com/docs/en/build-with-claude/context-windows
  4. Claude Platform docs: Prompt caching (read November 3, 2026)https://platform.claude.com/docs/en/build-with-claude/prompt-caching
  5. Claude Platform docs: Manage tool context (read November 3, 2026)https://platform.claude.com/docs/en/agents-and-tools/tool-use/manage-tool-context
  6. OpenAI API docs: Key concepts (read November 2, 2026)https://developers.openai.com/api/docs/concepts
  7. Claude Code docs: Manage costs effectively (read November 3, 2026)https://code.claude.com/docs/en/costs
  8. Claude Code docs: Explore the context window (read November 2, 2026)https://code.claude.com/docs/en/context-window
  9. Claude Code docs: Skills (read November 3, 2026)https://code.claude.com/docs/en/skills
  10. Claude Code docs: Plugins overview (read November 2, 2026)https://code.claude.com/docs/en/plugins
  11. Agent Skills specification (read November 3, 2026)https://agentskills.io/specification

Share this article

Put your token counts into the calculator

Enter your sessions, token counts and cache share, and see what caching, shorter answers and a cheaper model each take off a month. Each saving comes off what the one before it left, so the percentages don't simply add up, and the cache saving counts reads only. Prices are each maker's list prices, for Claude, GPT, Gemini, Grok, DeepSeek, Kimi and others.

Open the calculator

This article as Markdown · Blog RSS feed · All articles