Headroom you reserved but never used
Step 1 · The pattern
A token budget per minute
The provider allows so many tokens per minute. Each request uses some of it (amber): the prompt plus the answer, about 300 tokens here. The budget refills every minute and the app sits well inside it. (All numbers are illustrative.)
- a request
- tokens counted
- answered
In short
Headroom you reserved but never used: how it works and how it breaks
Every request to a model API sets max_tokens, the most it may generate. Providers check tokens-per-minute limits before the answer exists, so they have to estimate. OpenAI documents that the rate limit is calculated from the larger of max_tokens and the estimated tokens; Anthropic documents that max_tokens does not factor into its output-token limit, and Azure OpenAI counts actual tokens. So a generous max_tokens of 8,000 on a route whose answers are 300 tokens long is harmless on one provider, and on another reserves more than twenty times what it uses: the per-minute limit is reached at a small fraction of the real traffic, and requests are refused while the dashboard of tokens actually used shows plenty of room. The fix: set max_tokens per route from the real distribution of answer lengths, make gateway admission aware of each provider's counting rule, and compare reserved with used tokens.
What this simulation simplifies
- A 'minute' is three seconds in the animation.
- Token counts are whole units; real requests vary by prompt and answer length.
How this comes up in interviews
"Your LLM traffic is throttled at 15% of your token quota. What would you check?"
Then they ask
- How does the provider count tokens before the request runs?
- What is max_tokens set to?
- How do you set it per route?
A strong answer covers
- Some providers reserve max(max_tokens, estimate) against TPM.
- Generous max_tokens reserves far more than answers use.
- Size max_tokens per route from the answer-length distribution.
- Gateway admission must follow each provider's counting rule.
- Track reserved vs used tokens and the 'length' finish rate.
Points to cover, not a script. Say them in your own words and tie them to a system you have worked on.
On one page: the track cheat sheet.
Sources: OpenAI API docs: Rate limits (max_tokens and the estimate) ↗ · Anthropic API docs: Rate limits (max_tokens and OTPM) ↗ · Report a problem
Diagrams are our own simulations: the timings, rates and counts in them are illustrative, not measurements. Captions are original wording.