Skip to content

fix(types): add missing fields to ImageGenerationCall response types#3233

Open
xodn348 wants to merge 1 commit into
openai:mainfrom
xodn348:fix/image-generation-call-missing-fields
Open

fix(types): add missing fields to ImageGenerationCall response types#3233
xodn348 wants to merge 1 commit into
openai:mainfrom
xodn348:fix/image-generation-call-missing-fields

Conversation

@xodn348
Copy link
Copy Markdown

@xodn348 xodn348 commented May 13, 2026

Summary

The ImageGenerationCall model in the Responses API type stubs is missing several fields that the API actually returns. When the API response contains background, output_format, quality, revised_prompt, or size, accessing those attributes raises AttributeError because Pydantic's BaseModel (and the corresponding TypedDict param type) doesn't know about them.

Fixes #2649, closes #2580.

Fields added to ImageGenerationCall in all four affected files:

Field Type
background Optional[Literal["transparent", "opaque", "auto"]]
output_format Optional[Literal["png", "webp", "jpeg"]]
quality Optional[Literal["low", "medium", "high", "auto"]]
revised_prompt Optional[str]
size Optional[Literal["1024x1024", "1024x1536", "1536x1024", "auto"]]

The Literal values are consistent with ImageGenCompletedEvent (already present in src/openai/types/image_gen_completed_event.py) and with the live API spec.

Files changed:

  • src/openai/types/responses/response_output_item.py
  • src/openai/types/responses/response_input_item.py
  • src/openai/types/responses/response_item.py
  • src/openai/types/responses/response_input_item_param.py

Checklist

  • All fields are Optional with = None default (non-breaking)
  • Literal values match those in ImageGenCompletedEvent
  • TypedDict param variant also updated (response_input_item_param.py)
  • ruff check — no issues
  • ruff format --check — already formatted
  • pytest tests/test_models.py tests/test_utils — 179 passed
$ python -m pytest tests/test_models.py tests/test_utils -x -q
179 passed in 1.51s

=== LOCAL_TEST_PASSED ===

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.
@xodn348 xodn348 requested a review from a team as a code owner May 13, 2026 05:33
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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"]]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add all fields to ImageGenerationCall type ImageGenerationCall does not have all fields that API returns

1 participant