Back to Tools

RAG Context Window Calculator

Retrieval adds chunks to the prompt before the model writes an answer. This calculator shows the context you have left and the cost of one RAG query.

Retrieval adds chunks to the prompt before the model writes an answer. This calculator shows the context you have left and the cost of one RAG query.

Sample rates are planning examples, not official prices. Confirm the current price on the provider’s pricing page. This page is not affiliated with OpenAI, Anthropic, Google, or DeepSeek, and it is not financial advice.

How to use the RAG Context Window Calculator

  1. Choose a context window: 128K, 200K, or 1M tokens. Replace it if your model publishes a different limit.
  2. Enter the system prompt, the user query, the reserved answer, the chunk size, and how many chunks you retrieve.
  3. Read remaining context. A warning appears when the pieces add up to more than the window.
  4. Read the estimated cost of that one query at the selected rate.

How token math works

Providers bill input tokens and output tokens separately, usually per 1 million tokens. This suite estimates English prose at 1 token per 4 characters (about 0.75 words per token), code and JSON at 1 token per 3 characters, and multilingual text at 1 token per 2 characters. Dollar figures use the rate you select. They update in the browser and are not a quote from a model provider.

Practical notes

  • Retrieved tokens = chunk size × top-k. Ten chunks of 500 tokens add 5,000 tokens before the question is counted.
  • Reserve the answer up front. A window that is full of chunks leaves the model no room to reply.
  • Next: Chatbot Context Growth Calculator.
  • Also compare with the Words to Tokens Converter.
  • Browse AI products in the AI tools directory when you want a tool listing rather than a token estimate.

FAQ

What counts as used context?

System prompt + user query + retrieved chunks + tokens you reserve for the answer. Remaining context is the window minus that sum.

What happens on overflow?

The badge warns you. The calculator still shows the cost of the tokens you entered. A real API may truncate, reject the call, or drop older text.

How is the query cost priced?

Prompt-side tokens use the input rate. Reserved output tokens use the output rate. Both are divided by 1 million and multiplied by your price.