Skip to content

fix(responses): Auto-add text config for gpt-5-mini models to prevent empty output_text #2548

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/openai/resources/responses/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@
__all__ = ["Responses", "AsyncResponses"]


def _ensure_text_config_for_gpt5_mini(
model: ResponsesModel | NotGiven, text: ResponseTextConfigParam | NotGiven
) -> ResponseTextConfigParam | NotGiven:
"""Ensure gpt-5-mini models have text configuration to avoid empty output_text."""
if is_given(model) and str(model).startswith("gpt-5-mini") and not is_given(text):
return {"format": {"type": "text"}}
return text


class Responses(SyncAPIResource):
@cached_property
def input_items(self) -> InputItems:
Expand Down Expand Up @@ -815,7 +824,7 @@ def create(
"stream": stream,
"stream_options": stream_options,
"temperature": temperature,
"text": text,
"text": _ensure_text_config_for_gpt5_mini(model, text),
"tool_choice": tool_choice,
"tools": tools,
"top_logprobs": top_logprobs,
Expand Down