Max Tokens.

The maximum number of tokens an LLM can generate in a single response, separate from the context window that determines input capacity.

Max tokens is a critical parameter that limits how long an LLM's response can be, measured in tokens rather than words or characters. This setting prevents models from generating excessively long outputs and helps control computational costs and response times. Unlike the context window which determines how much input text a model can process, max tokens specifically constrains the output length, making it essential for applications where response size matters.

The max tokens parameter works by instructing the model to stop generating text once it reaches the specified limit, even if the response appears incomplete. Most API providers allow developers to set this value anywhere from a few tokens to several thousand, with different models having different maximum limits. The actual number of tokens generated may be less than the max if the model naturally concludes its response or encounters a stop sequence, but it will never exceed the specified maximum.

Setting appropriate max token limits requires balancing thoroughness with efficiency, as longer responses cost more and take longer to generate. Common misconceptions include confusing max tokens with context length or assuming that setting a high limit always produces better responses. In practice, many applications benefit from relatively modest limits that encourage concise, focused outputs while preventing runaway generation that could waste resources or overwhelm users with unnecessarily verbose responses.