Skip to content
Sunset

OpenAI parameter error

“max_tokens is not supported”: fix the request, not just the model name

OpenAI currently marks max_tokens as deprecated in Chat Completions, recommends max_completion_tokens instead, and documents max_tokens as incompatible with o-series models.

What to check

Step 1

Find every max_tokens call site

Search direct SDK calls, shared request builders, wrappers, tests, and configuration. One hidden default can keep the same error alive after you fix the obvious request.

Step 2

Use the parameter supported by the target model

For Chat Completions, OpenAI documents max_completion_tokens as the replacement for the deprecated max_tokens field. Validate the target model and endpoint before changing shared code.

Step 3

Re-test output behavior

A token-limit migration can change how much visible output you receive because newer reasoning models may account for reasoning tokens differently. Test real workloads, not only a successful HTTP response.

Do not apply a blind search-and-replace across every provider. Scope the change to OpenAI request paths and verify the SDK and endpoint you actually use.

Check the rest of the repository

Fixing the first error does not prove the rest of the codebase is clear. Sunset scans source text for scheduled OpenAI shutdown risk and shows severity before you pay.