# Max Tokens

> The most tokens a model may write in one reply. It stops at the cap.

**Field:** Artificial Intelligence  
**Category:** LLMs  
**Also known as:** Maximum Output Tokens, max_tokens, Output Token Limit

## Think of it like

Think of it like a friend who can only talk till the bell rings.

## Definition

Max tokens is a setting that caps how many tokens a model may write in one reply. When the reply hits the cap, it stops, even mid-sentence. It guards you from long, costly answers and from runs that never end. The cap counts only the output. But the input and output together must still fit in the context window.

## Example

Lucy sets max tokens to 100 and asks for a full report. The answer stops after about 75 words, mid-sentence.

## Why it matters

Output tokens cost money and time. The cap keeps both under control.

## Common mistake

Setting it too low and thinking the model gave up. A reply cut at the cap ends mid-thought; check the stop reason the tool reports.

## Three principles

- **Caps the reply.** Counted in tokens.
- **Stops hard.** Even mid-sentence.
- **Saves cost.** No runaway answers.

## Related terms

- [Stop Sequence](https://learn.benibix.com/term/ai/stop-sequence)
- [Token (AI)](https://learn.benibix.com/term/ai/token)
- [Context Window](https://learn.benibix.com/term/ai/context-window)
- [Token Usage](https://learn.benibix.com/term/development/token-usage)

## Told apart from

- [Context Window vs Max Tokens](https://learn.benibix.com/compare/context-window-vs-max-tokens): People think max tokens is the size of the context window, and it is not. The context window is all the text a model can hold at once: what you send and what it writes. Max tokens is a cap you set on the reply alone. The reply has to fit in what is left of the window after your prompt.

## Taught in

- [The LLM Context Window](https://learn.benibix.com/learn/ai-llms/llm-context-window): LLMs, 4/15
- [Prompt Caching and Cost](https://learn.benibix.com/learn/ai-working-with-ai/prompt-caching-and-cost): Prompt Engineering, 11/16

![Two rows of tokens. In the top row the answer is cut off mid-sentence when it hits the token limit. In the bottom row the answer ends cleanly when the stop sequence appears.](https://learn.benibix.com/diagrams/llm-max-tokens-stop.svg)

---

Source: https://learn.benibix.com/term/ai/max-tokens
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-18
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
