SECURITY WARNING: Never run commands you don't understand. Always review code before execution. Use at your own risk.
AI New Added 8 September 2026

OpenAI: Unsupported parameter: 'max_tokens' is not supported with this model

Newer OpenAI models reject max_tokens and expect max_completion_tokens, because reasoning tokens are billed and counted separately from the visible answer. Code written against an older model fails the moment the model name is swapped, with a 400 rather than a warning.

Quick fix

Read the commands before running them. Anything that restarts a service, deletes data or changes permissions should be tried on a non-production system first.

Quick fix
# Old
client.chat.completions.create(model="gpt-4o", max_tokens=1024, messages=msgs)

# New
client.chat.completions.create(
    model="gpt-5",
    max_completion_tokens=1024,
    messages=msgs,
)

# Budget for reasoning: the limit covers reasoning plus the reply,
# so a value that was generous before can now truncate the answer.

How to diagnose AI errors

AI and LLM errors cluster into four families: quota and rate limiting (429s, insufficient_quota), context window overflow (the prompt plus the requested completion exceeds the model's limit), accelerator memory (CUDA OOM, KV-cache exhaustion), and content policy (a refusal or safety stop rather than a transport failure). The first thing to establish is which family you are in, because the fixes have nothing in common: a 429 wants backoff and a quota increase, a context overflow wants truncation or chunking, and a CUDA OOM wants a smaller batch or a quantised model.

If the quick fix above does not resolve it, work through these steps. They apply to this whole class of error, not just to this one message, which is usually what saves the time.

  1. Read the error body, not just the status code. Providers put the real reason in a JSON error.type / error.code field: rate_limit_exceeded and insufficient_quota are both HTTP 429 but mean completely different things.
  2. Count your tokens before you send. Use the provider's tokenizer (tiktoken, Anthropic's count-tokens endpoint) rather than guessing from character length, and remember that max_tokens for the response is reserved inside the context window.
  3. For local inference, watch VRAM live with nvidia-smi -l 1 while the request runs. Memory that peaks during the forward pass rather than at load time points at batch size or sequence length, not at model weights.
  4. Distinguish a refusal from a failure. A stop_reason of refusal, or a finishReason of SAFETY, is a successful HTTP 200. Retrying identical input will produce the same result.
  5. Always implement exponential backoff with jitter and honour the retry-after header. Most production LLM incidents are self-inflicted retry storms.

Tools worth reaching for

  • tiktoken
  • nvidia-smi
  • curl -i
  • provider status pages

Authoritative references

Primary documentation for this error, worth reading before applying any fix in production.

platform.openai.com

Related AI errors

See all 35 AI errors →

Browse other categories

Something missing or wrong?

This entry is maintained by hand. If the fix is out of date, incomplete, or you have a better one, email a correction and it will be reviewed.