Retrieval Augmented Generation Token Budget Planner

This Retrieval Augmented Generation Token Budget Planner estimates the token load and model-input cost of a RAG request. It combines prompt overhead, retrieved passages, and expected output length, then checks the total against a selected context-window limit. Developers can use the result to size chunk retrieval, prevent context overflow, and compare retrieval depth with cost. Token counts are estimates; actual tokenization varies by model, language, formatting, and content.

Inputs

tokens
chunks
tokens
tokens
tokens
USD
Result
Estimated total tokens
Retrieval tokens
Context tokens remaining
Context utilization
Estimated input cost

1. Estimate prompt overhead
Enter the combined token count for system instructions, conversation history, and the current user message.

2. Set retrieval depth
Provide the number of chunks returned by the retriever.

3. Estimate chunk size
Use the average tokens in each chunk after any metadata or formatting is added.

4. Reserve output space
Enter the maximum or expected completion tokens you want to leave available.

5. Set the model limit and price
Use the context-window limit and current input-token price for the model being evaluated.

6. Review capacity
Check total tokens, remaining room, utilization, and estimated input cost.

Retrieval tokens = Number of chunks × Average tokens per chunk
Total tokens = Prompt tokens + Retrieval tokens + Reserved output tokens
Input cost = (Prompt tokens + Retrieval tokens) ÷ 1,000,000 × Input price

The estimate assumes all retrieved chunks are inserted in full. Actual tokenizer counts and provider billing rules may differ.

What the result means

Use the main result together with the supporting metrics to compare scenarios and identify the assumptions with the largest effect.

The estimate assumes all retrieved chunks are inserted in full. Actual tokenizer counts and provider billing rules may differ.

Given
Given: 1,200 prompt tokens, 8 chunks at 450 tokens each, 1,000 output tokens, a 128,000-token window, and $2.50 per million input tokens.

Calculation
Retrieval tokens = 8 × 450 = 3,600. Total tokens = 1,200 + 3,600 + 1,000 = 5,800. Remaining context = 128,000 − 5,800 = 122,200. Input cost = 4,800 ÷ 1,000,000 × $2.50 = $0.012.

Result
The request uses about 4.53% of the context window before generation completes.

Are token counts exact?

No. They are planning estimates. Use the model’s tokenizer on representative content for precise counts.

Should output tokens count against the context window?

For models with a shared input-output context limit, reserve output tokens within the total budget. Check the provider’s current documentation.

What is a safe utilization target?

Leave headroom for variable chunk sizes, formatting, tool messages, and longer-than-expected prompts. The appropriate buffer depends on the application.

How can I reduce the budget?

Retrieve fewer chunks, shorten chunks, compress context, remove redundant metadata, or use reranking to keep only the most relevant passages.

Does the cost include output tokens?

No. This page estimates input cost only because output pricing is often different. Add a separate output-cost calculation when needed.