max_tokens
A parameter in large language model APIs that specifies the maximum number of tokens used when generating a response, including both thinking and output tokens.
Core Facts
A finish_reason value of length or MAX_TOKENS means the model was forcibly interrupted rather than concluding on its own.
Thinking tokens for reasoning models are typically billed, and setting a token budget cap can prevent runaway costs from a single request.
Timeline (last 90 days)
Context truncation is the most common source of confounding in long-input experiments: when the concatenated prompt exceeds the model's context window or the server-side max_tokens limit, the system usually silently discards content from the tail or the head.
Different vendors' model list endpoints differ in parameter naming, for example some use max_tokens and others use max_completion_tokens.
Above 6KB, the empty-output rate does not rise linearly with file size but shows a cliff-like jump: once consumption approaches the max_tokens limit, whether the output is empty depends on the random fluctuation (variance) of that run's chain-of-thought length.
In models that support reasoning, max_tokens limits the total tokens of the visible answer and the invisible chain-of-thought; when the chain of thought fills the budget, the model has no room left to output the final answer, and the API returns empty or truncated content.
By connecting directly to each route and issuing a request with max_tokens=1, you can obtain the HTTP status code and error body at minimal cost for liveness probing.
Setting a max_tokens cap is necessary engineering discipline; agent loops plus runaway output length are among the most common sources of cost incidents.
In the OpenAI Chat Completions API, max_tokens is an early field used to limit the total number of tokens in the generated content; OpenAI introduced max_completion_tokens in the o1 series and later reasoning models to constrain the token upper limit of the entire completion, and gradually recommends that new models use the latter.
Azure OpenAI's parameter support pace is not synchronized with the OpenAI main site, and some older deployments (such as gpt-35-turbo) still only accept max_tokens; the compatibility layer must route by model family, otherwise requests may be rejected by the gateway with a 400.
Cline SDK v0.0.95 modified the parameter handling logic for OpenAI-compatible requests: for the model IDs gpt-6-sol, gpt-6.1-sol, gpt-6-1-sol and gpt-5 through gpt-9, the SDK now sends max_completion_tokens instead of max_tokens, in order to stop OpenAI and Azure from rejecting these requests.
In Anthropic's Claude 3.7 and later series, the model's internal reasoning (thinking) and the final reply share the same max_tokens budget, and max_tokens is the total upper limit of 'thinking + output'.
15 more timeline events
All Facts (20)
A finish_reason value of length or MAX_TOKENS means the model was forcibly interrupted rather than concluding on its own.
65%VerifiedThinking tokens for reasoning models are typically billed, and setting a token budget cap can prevent runaway costs from a single request.
65%UnverifiedContext truncation is the most common source of confounding in long-input experiments: when the concatenated prompt exceeds the model's context window or the server-side max_tokens limit, the system usually silently discards content from the tail or the head.
50%UnverifiedDifferent vendors' model list endpoints differ in parameter naming, for example some use max_tokens and others use max_completion_tokens.
50%UnverifiedAbove 6KB, the empty-output rate does not rise linearly with file size but shows a cliff-like jump: once consumption approaches the max_tokens limit, whether the output is empty depends on the random fluctuation (variance) of that run's chain-of-thought length.
50%UnverifiedIn models that support reasoning, max_tokens limits the total tokens of the visible answer and the invisible chain-of-thought; when the chain of thought fills the budget, the model has no room left to output the final answer, and the API returns empty or truncated content.
50%UnverifiedBy connecting directly to each route and issuing a request with max_tokens=1, you can obtain the HTTP status code and error body at minimal cost for liveness probing.
50%UnverifiedSetting a max_tokens cap is necessary engineering discipline; agent loops plus runaway output length are among the most common sources of cost incidents.
50%UnverifiedAzure OpenAI's parameter support pace is not synchronized with the OpenAI main site, and some older deployments (such as gpt-35-turbo) still only accept max_tokens; the compatibility layer must route by model family, otherwise requests may be rejected by the gateway with a 400.
50%UnverifiedCline SDK v0.0.95 modified the parameter handling logic for OpenAI-compatible requests: for the model IDs gpt-6-sol, gpt-6.1-sol, gpt-6-1-sol and gpt-5 through gpt-9, the SDK now sends max_completion_tokens instead of max_tokens, in order to stop OpenAI and Azure from rejecting these requests.
50%UnverifiedIn the OpenAI Chat Completions API, max_tokens is an early field used to limit the total number of tokens in the generated content; OpenAI introduced max_completion_tokens in the o1 series and later reasoning models to constrain the token upper limit of the entire completion, and gradually recommends that new models use the latter.
50%UnverifiedIn Anthropic's Claude 3.7 and later series, the model's internal reasoning (thinking) and the final reply share the same max_tokens budget, and max_tokens is the total upper limit of 'thinking + output'.
50%UnverifiedThe maximum output tokens (max_tokens) is a parameter used during API calls to limit the length of a single response, and it is two independent dimensions from the context window.
50%UnverifiedExplicitly setting max_tokens for each task type and using JSON mode or structured output constraints: on flagship models, the cost difference between a 200-token and a 2,000-token output is about 10x, and this alone can save $20 to $30 per month.
50%UnverifiedThe OpenAI API measures RPM and combined TPM by model series, and on each request checks whether the estimated prompt tokens plus the requested max_tokens fall within the remaining TPM pool.
50%UnverifiedIn a test with max_tokens set to 16, Gemini 2.5 Flash-Lite reported 12 reasoning tokens, with an empty visible reply.
50%UnverifiedThe reasoning tokens produced by reasoning models share the same max_tokens budget as the final output, and they are billed as usual even if the visible reply is an empty string.
50%Unverifiedmax_tokens is the maximum number of tokens the model can generate in a single reply, and it affects both latency and cost
50%UnverifiedClaude Code's recovery limit for max_tokens errors is three attempts, with the constant named MAX_OUTPUT_TOKENS_RECOVERY_LIMIT = 3.
50%Unverifiedtemperature, top_p, and max_tokens are common across most models, but some reasoning models do not accept temperature, or have special semantics for max_tokens.
50%