TokenPad
Reference

max_tokens Planner

Set the ceiling from your data, not from the model maximum.

Settings
Max Tokens PlannerExact
0Token change
Token change0no change
Input tokens0what you pasted
Output tokens0what you would send
Token cost of this result
Output tokens0
As input$0.00
× 100K requests$0.00

Everything on this page runs in your browser. Nothing you paste is transmitted, because there is no server here to transmit it to.

Result
 

The model maximum is the wrong default

Setting max_tokens to the model maximum "to be safe" reserves context window you could have retrieved into, and on providers that count the ceiling against your rate limit it consumes quota you never use.

Deriving it from the 95th percentile of your observed answer lengths with a margin gives you the same safety at a fraction of the cost.

Handle the stop reason

A response truncated at the ceiling is not an error. If you do not check the stop reason, a cut-off answer reaches your user mid-sentence and nothing in your logs says why.

Checking it is a few lines and turns a silent product defect into a handled case.

Frequently asked questions

Do all providers count max_tokens against quota?
No, and it is worth checking yours. Where they do, the setting is a throughput lever as well as a safety one — an inflated ceiling can halve your effective rate limit.
What margin should I use over the p95?
Around 30% is a reasonable default. Enough that legitimate long answers survive, small enough that the reservation stays meaningful.

More reference tools