[KongchangAI]
Concept

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

Timeline (last 90 days)

Oct 19

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.

Unverified50%
Oct 18

Different vendors' model list endpoints differ in parameter naming, for example some use max_tokens and others use max_completion_tokens.

Unverified50%
Oct 18

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.

Unverified50%
Oct 18

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.

Unverified50%
Oct 18

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.

Unverified50%
Oct 18

Setting a max_tokens cap is necessary engineering discipline; agent loops plus runaway output length are among the most common sources of cost incidents.

Unverified50%
Oct 17

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.

Unverified50%
Oct 17

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.

Unverified50%
Oct 17

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.

Unverified50%
Oct 16

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'.

Unverified50%

15 more timeline events

All Facts (20)

Verified

A finish_reason value of length or MAX_TOKENS means the model was forcibly interrupted rather than concluding on its own.

65%
Verified

Thinking tokens for reasoning models are typically billed, and setting a token budget cap can prevent runaway costs from a single request.

65%
Unverified

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.

50%
Unverified

Different vendors' model list endpoints differ in parameter naming, for example some use max_tokens and others use max_completion_tokens.

50%
Unverified

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.

50%
Unverified

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.

50%
Unverified

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.

50%
Unverified

Setting a max_tokens cap is necessary engineering discipline; agent loops plus runaway output length are among the most common sources of cost incidents.

50%
Unverified

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.

50%
Unverified

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.

50%
Unverified

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.

50%
Unverified

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'.

50%
Unverified

The 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%
Unverified

Explicitly 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%
Unverified

The 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%
Unverified

In a test with max_tokens set to 16, Gemini 2.5 Flash-Lite reported 12 reasoning tokens, with an empty visible reply.

50%
Unverified

The 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%
Unverified

max_tokens is the maximum number of tokens the model can generate in a single reply, and it affects both latency and cost

50%
Unverified

Claude Code's recovery limit for max_tokens errors is three attempts, with the constant named MAX_OUTPUT_TOKENS_RECOVERY_LIMIT = 3.

50%
Unverified

temperature, 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%

Source Articles