GrepBoard/Manuals
605 manuals ·

Fix OpenAI "Unsupported parameter: 'max_tokens'" (400)

·Tested on OpenAI API official docs · 2026-10·Test scope ↓·5 steps

OpenAI 400 'max_tokens' is not supported: reasoning models reject the old key. Use max_completion_tokens (or max_output_tokens in Responses) and allow room.

text
Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead.

You sent the old Chat Completions max_tokens key to a reasoning model, and it answers 400. Rename the key to max_completion_tokens and raise the value so it covers reasoning tokens too.

A public issue shows the full response body. code is unsupported_parameter and param is max_tokens, so your code can detect this case from those two fields.

text
{  "error": {    "message": "Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead.",    "type": "invalid_request_error",    "param": "max_tokens",    "code": "unsupported_parameter"  }}

[1] Check which API you call. The key name differs per API.

EndpointOutput cap keyWhat the official API reference says
Chat Completions /v1/chat/completionsmax_completion_tokensUpper bound for visible output tokens plus reasoning tokens
(same) max_tokensdo not useDeprecated in favor of max_completion_tokens, not compatible with o-series models
Responses /v1/responsesmax_output_tokensUpper bound for visible output plus reasoning tokens, minimum 16

The Responses API reference has no max_tokens at all. If you are moving to Responses, use max_output_tokens, not max_completion_tokens.

[2] Rename the key in your Chat Completions request.

json
{  "model": "<reasoning-model>",  "messages": [{"role": "user", "content": "..."}],  "max_completion_tokens": 4000}

In the Python SDK only the argument name changes: client.chat.completions.create(..., max_completion_tokens=4000). When you call OpenAI's Chat Completions directly, settling on one name is simpler than switching keys per model, since the reference marks max_tokens as deprecated. If the same code also talks to OpenAI-compatible servers (self-hosted or other gateways), they may not know max_completion_tokens; check that server's docs and, if needed, pick the key per destination. That said, the reference's own image-input example still uses max_tokens, so not every model rejects the old key.

[3] Do not carry the old number over unchanged. Reasoning models produce hidden reasoning tokens before the answer, and those count against this cap. On the official forum, an OpenAI staff member explained the split: max_tokens used to mean both the tokens generated (and billed) and the tokens returned, and with reasoning models those two numbers differ.

So renaming max_tokens: 300 to max_completion_tokens: 300 can spend all 300 on reasoning and leave the visible answer empty or cut off. The official reasoning guide says a response that hits the cap comes back incomplete, that input and reasoning tokens are billed even if no visible output was produced, and recommends reserving at least 25,000 tokens for reasoning and output when you start experimenting (its examples use Responses). If you set a small value to control cost, first check whether answers come back empty, then lower it.

[4] Check temperature in the same request. The official latest-model guide says that for the GPT-6 family, when reasoning effort is not none, you remove temperature, top_p and top_logprobs, and in Chat Completions also logprobs. If the fixed request now fails with Unsupported value: 'temperature', go to Fix OpenAI "Unsupported value: 'temperature'".

[5] If you do not write the JSON yourself, look at the library or tool. A wrapper (an automation tool's OpenAI node, a CLI, a framework) is adding max_tokens.

  • Clear that tool's "max tokens" setting, or upgrade and check whether it now sends the new key.
  • In one public issue, a CLI sent max_tokens and got this 400; given a max_completion_tokens option instead, the tool itself refused with Extra inputs are not permitted before sending anything. When the tool does not know the new key, it needs a fix on its side; until then, the only workaround is to call it without a token cap.

If the key itself is rejected, see Fix OpenAI API 401 "Incorrect API key provided". If you hit 429 after fixing the cap, see OpenAI API 429 "exceeded your current quota".

#openai-api#400#max_tokens#reasoning