Prompts & AI use

Max Tokens

AI-assisted editorial review:

A maximum-token parameter sets an upper bound on generated tokens for a model request. Its name and what it counts depend on the API and model; it is not a requested exact answer length.[1][2]

What does Max Tokens mean in simple terms?

It is a ceiling, like a maximum page allowance. The model can stop earlier. Tokens are pieces of encoded text, not a universal number of characters or words. A small ceiling may cut off a useful answer.

How can Max Tokens be explained with an analogy?

A maximum page allowance on a reply, rather than an instruction to fill every page.

Where is Max Tokens used?

Case 1

Responses API

OpenAI’s guidance uses max_output_tokens to cap generation in Responses.[1] Pair the cap with a clear request such as a brief summary.

Case 2

Chat Completions

max_completion_tokens counts generated completion tokens, including reasoning and visible output. Legacy max_tokens differs in compatibility.[2] Check the model’s reference rather than renaming the field blindly.

Case 3

Claude Messages

Claude’s Messages API documents max_tokens as the maximum to generate.[3] Use the supported limit for the selected model.

Case 4

Application testing

Try representative short and long requests, record actual usage, and detect truncated output. This is an illustrative test, not a guaranteed percentage saving.

Learning steps, limitations and developments

  1. Confirm the exact API field.
  2. Measure actual outputs on representative tasks.
  3. Set a cap with room for required content.
  4. Handle truncation or incomplete status explicitly.
  5. Recheck after changing the model.

The ceiling alone does not control input size or all costs. Lowering it does not automatically reduce a bill by the same ratio. For reasoning models, distinguish internal reasoning from visible text.[2] Check complete responses, including structured data or tool calls, before displaying them.

Which concepts are related to Max Tokens?

  • Related concept
    Prompt VersionA related concept within the same category.
  • Related concept
    Prompt LibraryA related concept within the same category.
  • Related concept
    Persona PromptingA related concept within the same category.

Which sources explain Max Tokens?

  1. OpenAI response-length guidance — https://help.openai.com/en/articles/5072518-controlling-the-length-of-openai-model-responses
  2. OpenAI Chat API reference — https://developers.openai.com/api/reference/resources/chat/subresources/completions/methods/create
  3. Claude Messages API — https://platform.claude.com/docs/en/api/messages/create