GenovaFlow GenovaFlow Services Blog Get my price in one call Get my price
AI Explained

What are tokens in AI? Costs, context windows and your bill

Cover with the article title beside Anthropic's diagram of a context window filling up turn by turn

Tokens are the unit every AI model reads, writes and bills

A token is a small chunk of text, often part of a word, and it is the unit every AI model reads, writes and bills you for. You pay per million tokens, separately for what you send and what comes back, and in a chat you pay again for the whole history on every turn. That last part is why a long conversation costs far more than its length suggests.

How much text fits in a token depends on the model. Google's rule of thumb for Gemini is about four characters per token, with 100 tokens coming to roughly 60 to 80 English words (Gemini API docs). The ratio moves even inside one vendor: Anthropic says Claude 4.7 and later models use a newer tokenizer that "produces approximately 30% more tokens for the same text" (Anthropic pricing). So the same prompt can cost more on a newer model before any per token price changes.

Text is not the only thing that turns into tokens. Google counts a small image as 258 tokens and audio at 32 tokens a second (Gemini API docs), and tool definitions, documents and earlier messages all count as input. If you want to compare models on window size and list price, how large language models differ covers that. This post covers what the definition leaves out: how the bill is built, why it grows, and how to estimate it before you commit.

If you are about to put an AI assistant in front of customers and have no idea what it will cost a month, we can work that out with you. Book a call with GenovaFlow AI

Output tokens cost five times as much as input tokens

Every price list splits tokens into at least two kinds. Input tokens are everything you send, output tokens are what the model writes back, and on the current Anthropic and OpenAI flagship price lists output costs five times as much as input (Anthropic, OpenAI). These are the Claude rates the worked example below uses, per million tokens:

ModelInputCached input (cache hit)Output
Claude Haiku 5.5 (prompts up to 100,000 tokens)$0.10$0.01$0.50
Claude Sonnet 5.5$2$0.10$10
Claude Opus 5.5$4$0.20$20

Cached input is the third kind, and it is where most of the savings live. When the start of a request is identical to a recent one, such as the same instructions and reference documents, the provider can read it from a cache: Anthropic charges 0.1x the base input price for cache reads, and 0.05x on Claude Opus 5.5 and Sonnet 5.5 (Anthropic pricing). Writing to the cache costs a little more than plain input, $2.50 instead of $2 per million on Sonnet 5.5 for a five minute cache. Batch requests, which you submit now and collect later, get a 50 percent discount on both input and output.

Thinking is output too. When a model reasons before it answers, Anthropic bills those thinking tokens as output tokens (context window docs), so a setting that makes the model think harder also makes its answers cost more.

The context window holds everything the model sees, every earlier turn included

The context window is the limit on how many tokens a model can handle in one request. Anthropic defines it as "all the text a language model can reference when generating a response, including the response itself", a working memory that is separate from what the model learned in training (Anthropic context window docs). Current Claude models have a window of 1M tokens and can write up to 128k tokens in one reply; older ones have 200k.

The part most explainers skip is what goes into each request. The model keeps nothing between calls, so your app sends the whole conversation every time: the docs describe each turn's input as "all previous conversation history plus the current user message", and say that "previous turns are preserved completely". The diagram at the top of this page is Anthropic's picture of exactly that. Instructions, tool results, images, documents and tool definitions all count toward the window as well.

When the input alone is bigger than the window, the API refuses it with a "prompt is too long" error. Chat apps handle the limit for you in other ways: Anthropic notes that interfaces such as claude.ai can drop the oldest messages on a rolling first in, first out basis. Caching does not free space either, because "prompt caching changes what you pay for those tokens, not whether they count" (Anthropic).

A chat costs more per turn the longer it runs

Because the history is resent, each turn's input is bigger than the last, and the total grows much faster than the number of turns. Take a simple assistant with a 1,500 token system prompt, user messages of about 100 tokens and replies of about 250. The input on turn n is the system prompt, every earlier exchange and the new message:

text
input on turn n = 1,500 + (n - 1) × 350 + 100

Add that up and a 10 turn chat sends 31,750 input tokens in total, while a 40 turn chat sends 337,000. Four times the turns costs about 10.6 times the input. These figures are arithmetic on the assumptions above, not a measurement, but the mechanism is the one Anthropic documents for every multi turn request (context window docs), and it is why starting a fresh conversation for a new task is the cheapest habit there is.

Worked example: one support assistant costs $7 or $268 a month depending on the model

Turning tokens into a monthly figure takes four numbers: conversations per month, turns per conversation, tokens per message, and the model's price. Here is the method on an illustrative website support assistant, with every assumption visible so you can replace it with your own. It handles 3,000 conversations a month, each six turns long, with the same 1,500 token system prompt and message sizes as above.

Each conversation then sends 14,850 input tokens and receives 1,500 output tokens, which is 44.55 million input and 4.5 million output tokens a month. At the list prices in the table above (Anthropic pricing), and again if the system prompt is read from cache on turns two to six:

ModelMonthly costWith the system prompt cached
Claude Haiku 5.5$6.71about $4.68
Claude Sonnet 5.5$134.10about $91.35
Claude Opus 5.5$268.20about $182.70

Three things move the real number. The cached column ignores the small premium for writing the cache, and caching more of the growing history saves more again. Tools add tokens you never typed: in Anthropic's own examples a short message counts as 14 input tokens, and a short question with one tool defined counts as 403 (token counting docs). And the tokenizer note above means a count taken on an older model can undershoot a newer one by about 30 percent. For the same kind of math on a phone agent, see AI voice agent vs a human receptionist.

Long contexts cost more and work worse

A big window is not a reason to fill it. Anthropic's own docs say that "as token count grows, accuracy and recall degrade, a phenomenon known as context rot" (Anthropic). The research behind that is consistent. The 2023 Lost in the Middle paper found that performance "is often highest when relevant information occurs at the beginning or end of the input context" and drops when the model has to use information in the middle (Liu and colleagues, arXiv).

Chroma's Context Rot report tested 18 models in 2025 and reached the same conclusion: "Across all experiments, model performance consistently degrades with increasing input length", and even a single distracting passage lowered accuracy compared with the baseline (Chroma).

Chroma's Context Rot report: across all experiments, model performance consistently degrades with increasing input length
Chroma, Context Rot (Hong, Troynikov and Huber, July 2025).

Anthropic's engineering team explains why: models have an "attention budget", and context "must be treated as a finite resource with diminishing marginal returns" (Effective context engineering for AI agents). Its advice is to send the smallest set of tokens that carries what the model needs, which in practice means one conversation per task, a short summary instead of a long history, and only the relevant passages of a document. That last one is what retrieval augmented generation does. If you work in Claude Code, the same habits are in how we cut our Claude Code token usage.

Length can change the price as well as the quality. OpenAI bills prompts above 272K input tokens at long context rates, which for gpt-6-astra means $20 instead of $10 per million input tokens (OpenAI pricing). Anthropic includes the full 1M window at standard pricing on Claude 4.6 and later models, except Claude Haiku 5.5, whose prompts over 100,000 tokens cost more (Anthropic pricing).

Count the tokens before you pay for them

You do not have to guess. Anthropic's token counting endpoint takes the same request you would send and returns the input token count, and it is free to use within a rate limit (token counting docs). The docs' basic example is a few lines of Python:

text
client = anthropic.Anthropic()

response = client.messages.count_tokens(
    model="claude-opus-5-5",
    system="You are a scientist",
    messages=[{"role": "user", "content": "Hello, Claude"}],
)

print(response.json())   # { "input_tokens": 14 }

The count is an estimate, and the docs say plainly to recount on the model you plan to use rather than reuse counts from an older one. Google's Gemini API has its own count_tokens call for input, and every response from either vendor reports what it actually used, so after launch you can check the estimate against the real bill.

Anthropic's token counting docs: counts are an estimate, and Claude 4.7 and later models produce about 30 percent more tokens for the same text
Anthropic docs, Token counting: the estimate note and the newer tokenizer.

A budget for any AI feature comes down to five steps:

  1. Write down the system prompt, the typical message and reply, and how many turns a conversation takes.
  2. Count a real transcript with the counting endpoint on the model you intend to use.
  3. Multiply by conversations per month, remembering that each turn resends the history.
  4. Apply caching for the repeated instructions and batch pricing for anything that can wait.
  5. After the first month, compare the estimate with the usage the API reported and adjust.

The rest of the AI explained series covers the ideas underneath, and if you want the estimate done for a specific assistant before anything is built, that is part of our custom AI agents service.

Questions people ask

Are AI tokens the same as words?

No. A token is a chunk of text that is often shorter than a word. Google's rule of thumb for Gemini is about four characters per token, so 100 tokens is roughly 60 to 80 English words. The ratio changes by language and by model: Anthropic says its newer tokenizer, used from Claude 4.7, produces about 30 percent more tokens for the same text (Anthropic pricing).

Is the context window per chat?

It applies to each request, and in a chat each new message is a new request that carries the whole conversation so far. So a chat uses more of the window, and costs more, with every turn. A new chat starts empty. Chat apps such as claude.ai can also drop the oldest messages once the window is full, which is why early instructions can be forgotten in a very long conversation.

What happens when the context window is full?

Through the API, a request whose input is larger than the window is rejected with a "prompt is too long" error. Apps handle it for you: some drop the oldest messages first, and tools like Claude Code summarise the conversation automatically as it approaches the limit. Either way, detail from early in the conversation can be lost, so put rules that must last in the system prompt.

Does the context window include output tokens?

Yes. Anthropic defines the context window as all the text the model can reference when generating a response, including the response itself, and the model's thinking counts too. So a request needs room for its input plus the answer. On current Claude models a single reply can be up to 128k tokens inside a 1M token window.

How do you convert tokens to dollars?

Divide the token count by one million and multiply by the price per million, separately for input and output. For example, a request that reads 50,000 tokens on Claude Sonnet 5.5 at $2 per million input tokens costs $0.10 for the input, and 5,000 output tokens at $10 per million add $0.05. Prices are on each vendor's pricing page (Anthropic).

Sources

  1. Pricing, Claude API docs
  2. Context windows, Claude API docs
  3. Token counting, Claude API docs
  4. API pricing, OpenAI
  5. Understand and count tokens, Gemini API docs
  6. Lost in the Middle: How Language Models Use Long Contexts, Liu et al., arXiv
  7. Context Rot: How Increasing Input Tokens Impacts LLM Performance, Chroma
  8. Effective context engineering for AI agents, Anthropic