[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 15

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.

Unverified50%
Oct 15

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

Unverified50%
Oct 15

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.

Unverified50%
Oct 13

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

Unverified50%
Oct 13

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

Unverified50%
Oct 12

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.

Unverified50%
Oct 12

The context window is the total token limit of input plus output that a model can accept in a single call, which is a model capability boundary; max_tokens is an output length limit actively imposed by the application and is a cost and latency control valve, and the two are often confused.

Unverified50%
Oct 12

For models billed by token, a malformed prompt risks unexpectedly generating a large number of tokens; engineering safeguards can be implemented as three layers: a hard max_tokens cap, client-side prompt length validation, and an API call timeout guard.

Unverified50%
Oct 12

When setting max_tokens, real headroom should be reserved and an alert triggered when approaching the limit, because slow growth is the typical path to hitting the wall.

Unverified50%
Oct 12

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

Unverified50%

2 more timeline events

All Facts (12)

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

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

The context window is the total token limit of input plus output that a model can accept in a single call, which is a model capability boundary; max_tokens is an output length limit actively imposed by the application and is a cost and latency control valve, and the two are often confused.

50%
Unverified

For models billed by token, a malformed prompt risks unexpectedly generating a large number of tokens; engineering safeguards can be implemented as three layers: a hard max_tokens cap, client-side prompt length validation, and an API call timeout guard.

50%
Unverified

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

50%
Unverified

When setting max_tokens, real headroom should be reserved and an alert triggered when approaching the limit, because slow growth is the typical path to hitting the wall.

50%
Unverified

When output is truncated by max_tokens, the constrained decoding layer halts along with it, leaving a structurally incomplete response.

50%

Source Articles