LLM tokens and cost

Context window fill checker.

Add up what goes into a request and see how full the window is. You enter the window size for your model.

Context used = system + history + retrieved chunks + user message + tools + output reserve. That is 31,600 tokens in a 128,000-token window (24.7% full) in the example, with room for up to 168 chunks of 600 tokens. In a 30,000-token window the same request is over by 1,600.

Advertisement

Your numbers

Your numbers
From your model's documentation. 128000 is an example.
Space kept free for the reply, including any reasoning tokens.

Result

Worked example

A 128,000-token window (an example size) with a 1,500-token system prompt, 20,000 tokens of history, 8 retrieved chunks of 600 tokens (4,800), a 300-token user message, 1,000 tokens of tool definitions and a 4,000-token output reserve. Total: 1,500 + 20,000 + 4,800 + 300 + 1,000 + 4,000 = 31,600 tokens, which is 24.7% of the window with 96,400 left. Chunks that fit: (128,000 - 26,800) / 600 = 168.7, rounded down to 168. With a 30,000-token window the same request totals 31,600 and is over by 1,600, so trim the history or the chunks.

How it works

Anthropic's context window documentation says that with extended thinking all input and output tokens, including thinking tokens, count toward the context window limit, so the output reserve should cover the longest reply you allow, reasoning included. Leave a margin, because the counts you enter are usually estimates.

The token counts you enter should come from real counts where possible; the token estimator gives a rough figure for text. OpenAI notes that tool schemas and message structure add tokens that are hard to count locally, which is why there is a field for tools and other overhead.

Sources and basis (opened 2026-10-08): Context windows - Claude Platform Docs; Counting tokens | OpenAI API. Everything else is arithmetic on your inputs.

All prices on this page are examples you can overwrite, not any provider's current prices. Check your provider's pricing page before you rely on a number. Results are planning estimates, not a quote or financial advice. Everything runs in your browser. Nothing you type is sent or stored.

FAQ

How do I know if my prompt fits the context window?

Add the system prompt, history, retrieved chunks, user message, tool definitions and the output you want to reserve, then compare the total to the window. In the example that is 31,600 tokens against 128,000.

Do output tokens count toward the context window?

Anthropic's documentation says all input and output tokens, including thinking tokens, count toward the context window limit. Reserve space for the longest reply you allow.

How many RAG chunks can I add?

Divide the space left after everything else by the chunk size and round down. In the example 168 chunks of 600 tokens fit. Retrieving more than you need adds cost and can add noise.

What window size should I enter?

Use the context window listed in your provider's documentation for the exact model. The default here is only an example.

Advertisement
Advertisement