DEVELOPER TOOL

RAG Context Budget Planner

Reserve instructions, history, tools, output and safety margin before choosing how many retrieved chunks fit a model.

Runs locallyRuns locally in your browser. Your data is not uploaded.
RAG context allocation

Reserve before retrieval

Whole token counts up to 1 billion; chunk size 1–1,000,000; top-k 0–1,000,000. Average chunks are a planning assumption. Include message wrappers and retrieval separators in overhead. Safety margin is an explicit token reserve.

Retrieval capacity

Plan retrieval to inspect whole-chunk capacity.

This model shares its context window between input and reserved output. Cached tokens still consume logical context. Cost and caching are not part of this calculation.

Ready. Reserve fixed overhead before adding retrieved chunks.

Model limits source · Reviewed 2026-10-08.

Enable JavaScript to plan locally.

Reserve first, retrieve second.

The planner subtracts fixed instructions, history, query, tool schemas and other overhead from the model context. It also reserves a token safety margin and, for combined input/output windows, the requested output. Maximum whole chunks is the remaining retrieval budget divided by average chunk size, rounded down.

Average chunks are an assumption.

For an 8,000-token retrieval budget and 1,500-token average chunks, at most five whole chunks fit. Real retrieved chunks vary: use conservative sizes and include citation wrappers, separators and message overhead. A 90% allocation warning is a local planning convention, not a provider guarantee.

Context is separate from billing.

Cached input still occupies logical context. Gemini input-only windows keep output separate, while combined windows reserve output within context. Output maxima are checked independently. The planner uses numeric counts, never actual prompt content, and performs no retrieval or inference.

Find a tool or category

Tools & categories12 results