Repository navigation
Conversation
This was referenced Oct 30, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Summary
max_output_tokensasmax_tokens. OpenAIdeprecated that parameter in favor of
max_completion_tokensand documentsit as incompatible with o-series models
(Chat Completions reference).
GPT-5 reasoning models reject it as well
(openai/openai-dotnet#737).
Callers who set
max_output_tokenswith those models get a 400 today.max_completion_tokens, the documented replacement,when requests go to OpenAI's API: no
base_url,https://api.openai.com,or a regional
*.api.openai.comhost. It keepsmax_tokensfor any otherbase_url, because some OpenAI-compatible servers accept only the oldername.
OPENAI_BASE_URLis checked too, since the OpenAI SDK falls back toit when
base_urlis unset. The Batch API path uses the same requestbuilder.
max_output_tokensfor o-series models. It still applies to reasoning models behind a custom
base_url, such as Azure OpenAI deployments.first; this branch then rebases to one commit.
Bug fix
How Has This Been Tested?
Tests
test_max_output_tokens_request_parameterwithopenai_api,custom_base_url,openai_base_url_env,explicit_openai_base_url,regional_openai_base_urlandlookalike_openai_hostcases. Theopenai_apicase fails onmain(
KeyError: 'max_completion_tokens').pytest -m 'not live_api and not requires_pip and not integration':991 passed, 25 deselected.
pylintis clean on thechanged files.
max_output_tokensistest_medication_extraction_with_schema_constraints(512). On this PR it sendsmax_completion_tokenstogpt-4o-mini; on Move OpenAI live tests off retiring GPT-4o models #601 it sends it togpt-6-luna. The opt-in Batchlive test is skipped in CI. Pending; added once this run finishes.
Checklist
pylintover theaffected code.