fix(client): normalize and strip model names before request #2633
+8
−0
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.
Summary
This change improves how model names are handled inside
_base_client.py
.Previously, if a developer passed a model name with uppercase letters (e.g.
"GPT-4O-MINI"
) or extra spaces (e.g." gpt-4o-mini "
), the client would send it directly to the API. Since the backend is strict and only accepts exact lowercase identifiers (like"gpt-4o-mini"
), this would cause:Changes
BaseClient._build_request
:Why
This small improvement:
"GPT-4"
," gPt-4 "
, and"gpt-4"
all resolve correctly.Examples
Before (OpenAI model)
After (OpenAI model)
Before (Gemini model used with
OpenAIChatCompletionsModel
)After (Gemini model with fix applied)
Impact
🔑 Why This Matters
Whether using standard OpenAI models (
gpt-4o
,gpt-4o-mini
, etc.) or integrating Google Gemini models via the OpenAI Agent SDK, developers will no longer run into frustrating case/format errors just because of casing or whitespace.This makes the SDK robust, cross-compatible, and beginner-friendly.
Changes being requested
Additional context & links
"I’m aware this repo is auto-generated. If this should instead be fixed in the generator or spec, I’m happy to move the patch there. Please advise."