Skip to content
mathbehind

LLM Context Window Calculator

See how a system prompt, chat history and documents fill an LLM's context window, how many turns fit before it overflows, and what each request costs.

Your numbers

Prices and fees in this tool are in US dollars.

Check the limit in your model's documentation. Some models also cap output length separately.

Per-token prices checked 20 September 2026 against provider pricing pages.

tokens
words

Files, RAG chunks or pasted text sent with each request. A 10-page report is roughly 5,000 words.

One turn = one user message plus one reply.

tokens
tokens

The reply is part of the same window, so the input must leave space for it.

Share of the context window used

29.0%

Status
Fits comfortably.
Input tokens per request
53,900
Tokens left after the reply
142,100
More turns that fit
236
Tokens from documents
39,900
Cost of this request
$0.1478
Cost per 1,000 requests like it
$147.80
The math behind it
  1. Documents in tokens

    30,000 words × 1.33equals39,900

  2. Input tokens

    2,000 + 39,900 + 20 × 600equals53,900

  3. Share of the window

    (53,900 + 4,000) ÷ 200,000equals29%

  4. Cost of the request

    (53,900 × $2.00 + 4,000 × $10.00) ÷ 1Mequals$0.1478

A model's context window is the total number of tokens it can handle in one request: your instructions, the whole conversation so far, any documents you attach, and the reply it writes. Once that fills up, older messages must be dropped or summarised. This calculator adds up each part, shows how close you are to the limit, and prices the request, because every token in the window is billed again on every call.

Figures checked against OpenAI API pricing, Claude API pricing and Gemini API pricing. Prices and rules change, so confirm with the official source before relying on them.

How it works

Input tokens are the system prompt, plus documents converted from words to tokens, plus chat turns multiplied by their average size. The space reserved for the reply is added on top, because the output shares the same window.

Word-to-token ratios are estimates. English averages about 1.33 tokens per word. Arabic and Urdu usually take 2 to 3 tokens per word, because most tokenizers were trained mostly on English text. Code and numbers vary widely.

Chat applications resend the full history with every message. A conversation that has reached 50,000 tokens costs the price of 50,000 input tokens on each new turn, which is why long chats get expensive and slow even before they hit the limit.

Cost per request uses the selected model's input price for everything you send and the output price for the reserved reply. It is a ceiling: if the reply is shorter than the reserve, the output cost is lower. Prompt caching can cut the cost of a repeated system prompt or document by a large share, and the AI API Cost Calculator models that.

A worked example

A support assistant has a 2,000-token system prompt, a 30,000-word English knowledge document (about 39,900 tokens), and 20 turns of chat at 600 tokens each (12,000 tokens). That's 53,900 input tokens. Leaving 4,000 tokens for the reply uses 57,900 of a 200K window, or 29%, with room for 236 more turns. On Claude Sonnet 5 each request costs about $0.1478.

Questions people ask

What is a context window in an LLM?

It's the maximum number of tokens a model can read and write in one request. Everything counts toward it: system instructions, previous messages, attached documents, tool results and the reply itself.

What happens when a conversation exceeds the context window?

The API rejects the request, or the application silently drops the oldest messages. Either way the model loses earlier details. Most chat apps summarise old turns or keep only the most recent ones to stay under the limit.

How many words fit in a 128K or 200K context window?

In English, roughly 96,000 words fit in 128K tokens and about 150,000 words in 200K, before leaving room for the reply. In Arabic or Urdu, expect roughly half as many words, since each word takes more tokens.

Does a bigger context window cost more?

The window size itself doesn't, but filling it does: you pay for every input token on every request. Some providers also charge a higher rate once a prompt goes past a certain length, so check the pricing page for long-context tiers.

Should I put whole documents in the prompt or use RAG?

If the documents fit comfortably and you query them often, prompt caching makes putting them in the prompt simple and affordable. If they're large or change often, retrieval (RAG) sends only the relevant chunks, which keeps each request smaller and cheaper.