fix(types): add missing fields to ImageGenerationCall response types#3233
fix(types): add missing fields to ImageGenerationCall response types#3233xodn348 wants to merge 1 commit into
Conversation
Add background, output_format, quality, revised_prompt, and size fields to the ImageGenerationCall class in response_output_item, response_input_item, response_item, and response_input_item_param. These fields are returned by the API but were absent from the type definitions, causing AttributeError at runtime.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 150c955109
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| type: Required[Literal["image_generation_call"]] | ||
| """The type of the image generation call. Always `image_generation_call`.""" | ||
|
|
||
| background: Optional[Literal["transparent", "opaque", "auto"]] |
There was a problem hiding this comment.
Add the fields to the primary response input type
This updates response_input_item_param.py, but the main client.responses.create(...) overloads import ResponseInputParam from src/openai/types/responses/response_input_param.py, which contains a duplicate ImageGenerationCall TypedDict that still lacks these keys. In the common case of feeding a returned image_generation_call item back through responses.create(input=[...]), type checkers will still reject background, output_format, quality, revised_prompt, and size; add the same fields to the duplicate response_input_param.py definition as well.
Useful? React with 👍 / 👎.
| type: Literal["image_generation_call"] | ||
| """The type of the image generation call. Always `image_generation_call`.""" | ||
|
|
||
| background: Optional[Literal["transparent", "opaque", "auto"]] = None |
There was a problem hiding this comment.
Keep ConversationItem's image call model in sync
The conversations item endpoints cast returned items to src/openai/types/conversations/conversation_item.py::ConversationItem, which has its own duplicate ImageGenerationCall model that was not updated here. When an image generation call is retrieved or listed via client.conversations.items.*, these newly documented attributes are still absent from the typed model/autocomplete for that API surface, so the type fix remains incomplete for conversation-stored response items.
Useful? React with 👍 / 👎.
Summary
The
ImageGenerationCallmodel in the Responses API type stubs is missing several fields that the API actually returns. When the API response containsbackground,output_format,quality,revised_prompt, orsize, accessing those attributes raisesAttributeErrorbecause Pydantic'sBaseModel(and the correspondingTypedDictparam type) doesn't know about them.Fixes #2649, closes #2580.
Fields added to
ImageGenerationCallin all four affected files:backgroundOptional[Literal["transparent", "opaque", "auto"]]output_formatOptional[Literal["png", "webp", "jpeg"]]qualityOptional[Literal["low", "medium", "high", "auto"]]revised_promptOptional[str]sizeOptional[Literal["1024x1024", "1024x1536", "1536x1024", "auto"]]The Literal values are consistent with
ImageGenCompletedEvent(already present insrc/openai/types/image_gen_completed_event.py) and with the live API spec.Files changed:
src/openai/types/responses/response_output_item.pysrc/openai/types/responses/response_input_item.pysrc/openai/types/responses/response_item.pysrc/openai/types/responses/response_input_item_param.pyChecklist
Optionalwith= Nonedefault (non-breaking)ImageGenCompletedEventTypedDictparam variant also updated (response_input_item_param.py)ruff check— no issuesruff format --check— already formattedpytest tests/test_models.py tests/test_utils— 179 passed