Cost a sequential prompt chain accurately
A “waterfall” chain feeds each step’s output into the next step’s input. That makes the carried context grow at every step, and because input tokens are billed each time, the total cost rises faster than people expect. This calculator shows the per-step token growth and cumulative bill so you can size a pipeline before you build it.
How context accumulates
At step n, the input is the system prompt plus the original input plus every prior step’s output:
input(n) = system + initial_input + sum(output(1..n-1))
cost(n) = input(n)/1M x in_price + output_per_step/1M x out_price
total = sum(cost(1..steps))
The system prompt and initial input are re-sent on every step, and each new output is permanently added to the carried context, so the input grows linearly while the cost grows roughly quadratically with the number of steps.
Where costs hide in long chains
When you design a multi-step pipeline, the temptation is to look at the cost of a single API call and multiply by the number of steps. That underestimates the real bill substantially because it ignores context accumulation.
For example, consider a 5-step chain where the system prompt is 1,000 tokens, the initial input is 500 tokens, and each step produces 800 tokens of output:
| Step | Input tokens | Output tokens |
|---|---|---|
| 1 | 1,500 | 800 |
| 2 | 2,300 | 800 |
| 3 | 3,100 | 800 |
| 4 | 3,900 | 800 |
| 5 | 4,700 | 800 |
Total input tokens: 15,500. Total output tokens: 4,000. If you had naively estimated 5 × 1,500 input = 7,500 input tokens, you would have underestimated input token usage by more than half. The calculator builds this table precisely so there are no surprises when the invoice arrives.
The cost curve by step count
The quadratic growth comes from the fact that each new step adds its output to the context that every subsequent step must re-read. A 10-step chain does not cost twice a 5-step chain — it costs substantially more, because the later steps are each paying to re-read all the earlier outputs. Use this calculator to compare a 5-step chain versus a 10-step chain before deciding on your pipeline structure.
Practical architecture decisions this unlocks
Summarization breaks: If step 3 produces a verbose 2,000-token analysis that step 4 only needs in distilled form, adding a summarization step that compresses it to 300 tokens saves on every step that follows. The calculator lets you model that compression explicitly — set step 3’s output to 300 tokens after summarization and watch the downstream costs drop.
Model mixing: Early steps in a chain often do simpler work — extraction, classification, formatting. A cheaper, faster model for steps 1 through 3 and a more capable model for steps 4 and 5 can deliver the same quality at a fraction of the full-chain cost. Run two scenarios in the calculator with different per-step pricing to quantify the saving.
Context resets: If each chain step is genuinely independent (for example, analyzing five different documents rather than building on previous reasoning), a context reset between steps eliminates the accumulation entirely. Each step starts fresh with only the system prompt and the new input. The cost becomes purely step-count times single-call cost — no quadratic growth.
Caching: Some LLM providers offer prompt caching that reduces the per-token price for repeatedly-sent prefixes like a long system prompt. If your provider supports caching, a long shared system prompt may be nearly free to re-send after the first request. Factor this in when modeling long chains with stable system prompts.
Tips for cheaper chains
- Summarise between steps. Replacing a long output with a short summary before passing it on flattens the input-growth curve dramatically.
- Use a cheap model for high-volume early steps and reserve the expensive model for the final reasoning step.
- Reset when you can. If later steps do not truly need the full history, start a fresh request with only the relevant carry-over.
- Model the break-even. A summarization step costs tokens to run; it only pays off if the tokens saved across subsequent steps exceed the cost of the summary itself. Use the calculator to verify the trade-off.
- Watch output length. Each extra token of output from step n becomes an extra input token for every step from n+1 to the end. Instructions to be concise in intermediate steps pay compound dividends.