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

> 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.

Mindket editors · Published 2026-10-10 · Updated 2026-11-03 · https://mindket.com/blog/what-are-tokens-in-ai

## 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.

## 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](https://platform.claude.com/docs/en/build-with-claude/token-counting) 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](https://platform.claude.com/docs/en/about-claude/glossary). Short common words are usually one token each, and a word's first token [typically starts with the space before it](https://developers.openai.com/api/docs/concepts).

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.

| Models | About one token per | Source |
| --- | --- | --- |
| OpenAI models | 4 characters, or 0.75 words | OpenAI API concepts page |
| Claude models before Claude 4.7 | 3.5 characters | Anthropic glossary |
| Claude 4.7 and later | About 30 percent more tokens than earlier Claude models for the same text | Anthropic glossary and token counting page |

## How to count tokens before you send a request

That count came from Anthropic's [token counting endpoint](https://platform.claude.com/docs/en/build-with-claude/token-counting), 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.

````bash
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](https://platform.claude.com/docs/en/build-with-claude/context-windows). 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](https://code.claude.com/docs/en/costs). 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](https://platform.claude.com/docs/en/build-with-claude/context-windows), read 2026-11-03)
- **128k** output tokens at most in one request to those models (Source: [Claude Platform docs: Context windows](https://platform.claude.com/docs/en/build-with-claude/context-windows), read 2026-11-03)
- **200k** tokens of context in the other Claude models (Source: [Claude Platform docs: Context windows](https://platform.claude.com/docs/en/build-with-claude/context-windows), read 2026-11-03)

> 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](https://platform.claude.com/docs/en/build-with-claude/context-windows) (read 2026-11-03)

[![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](https://mindket.com/blog/shots/x-claudeai-sonnet-1m-context.webp?v=2c3ba5b35238)](https://x.com/claudeai/status/1955299573620261343)

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](https://platform.claude.com/docs/en/build-with-claude/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](https://mindket.com/blog/shots/x-alexalbert-prompt-caching.webp?v=1f8657e54cef)](https://x.com/alexalbert__/status/1823751966893465630)

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](https://mindket.com/blog/what-are-agent-skills) 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](https://code.claude.com/docs/en/skills). 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](https://mindket.com/blog/what-is-mcp) 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](https://platform.claude.com/docs/en/agents-and-tools/tool-use/manage-tool-context) 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](https://mindket.com/blog/claude-md-file) 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.md | Agent Skill (Our pick) | MCP server |
| --- | --- | --- | --- |
| In context in a session where none of it runs | ✓ Yes | ✓ Yes | ✓ Yes |
| What sits there | The whole file, from the start of every session | Each skill's name and description, about 100 tokens | Tool names and server instructions, in Claude Code |
| The rest loads only when a task needs it | ✗ No | ✓ Yes | In Claude Code by default, on the API with tool search |
| Anthropic's size advice | Keep it under 200 lines | A description is cut at 1,536 characters | Add 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](https://code.claude.com/docs/en/costs) (read 2026-11-03), [Claude Code docs: Skills](https://code.claude.com/docs/en/skills) (read 2026-11-03), [Claude Platform docs: Manage tool context](https://platform.claude.com/docs/en/agents-and-tools/tool-use/manage-tool-context) (read 2026-11-03), [Agent Skills specification](https://agentskills.io/specification) (read 2026-11-03)

## 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.

| Field | Where to find the number |
| --- | --- |
| AI sessions a day, days a month | Your 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 model** In tokens. The highlighted bar is the model the text names.

- Claude Opus 5.5: 512 tokens
- Claude Sonnet 5.5: 512 tokens
- Claude Haiku 5.5: 512 tokens
- Claude Sonnet 5: 1,024 tokens
- Claude Opus 4.8: 1,024 tokens
- Claude Opus 4.7: 2,048 tokens
- Claude Opus 4.6: 4,096 tokens
- Claude Haiku 4.5: **4,096 tokens**

Source: [Claude Platform docs: Prompt caching](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) (read 2026-11-03)

> 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

- [Claude Platform docs: Glossary](https://platform.claude.com/docs/en/about-claude/glossary) (read 2026-11-02)
- [Claude Platform docs: Token counting](https://platform.claude.com/docs/en/build-with-claude/token-counting) (read 2026-11-02)
- [Claude Platform docs: Context windows](https://platform.claude.com/docs/en/build-with-claude/context-windows) (read 2026-11-03)
- [Claude Platform docs: Prompt caching](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) (read 2026-11-03)
- [Claude Platform docs: Manage tool context](https://platform.claude.com/docs/en/agents-and-tools/tool-use/manage-tool-context) (read 2026-11-03)
- [OpenAI API docs: Key concepts](https://developers.openai.com/api/docs/concepts) (read 2026-11-02)
- [Claude Code docs: Manage costs effectively](https://code.claude.com/docs/en/costs) (read 2026-11-03)
- [Claude Code docs: Explore the context window](https://code.claude.com/docs/en/context-window) (read 2026-11-02)
- [Claude Code docs: Skills](https://code.claude.com/docs/en/skills) (read 2026-11-03)
- [Claude Code docs: Plugins overview](https://code.claude.com/docs/en/plugins) (read 2026-11-02)
- [Agent Skills specification](https://agentskills.io/specification) (read 2026-11-03)

[Open the calculator](https://mindket.com/calculator)
