Skip to content

fix(types): make ImageGenerationCall result and status optional - #3558

Open
okxint wants to merge 2 commits into
openai:mainfrom
okxint:fix/image-generation-call-required-fields
Open

fix(types): make ImageGenerationCall result and status optional#3558
okxint wants to merge 2 commits into
openai:mainfrom
okxint:fix/image-generation-call-required-fields

Conversation

@okxint

@okxint okxint commented Jul 31, 2026

Copy link
Copy Markdown

result (base64 image string) and status are output-only fields populated by the API. Marking them Required on an input TypedDict forces callers to supply values they don't have and wouldn't provide when referencing an existing image generation call by id and type.

- result: Required[Optional[str]]
+ result: Optional[str]

- status: Required[Literal["in_progress", "completed", "generating", "failed"]]
+ status: Literal["in_progress", "completed", "generating", "failed"]

Fixes #2648

okxint added 2 commits July 5, 2026 10:23
Filters out content items where `text` is None before joining, preventing
a TypeError crash when the API returns null for a text block (issue openai#3063).
result (base64 image string) and status are output-only fields populated
by the API response. Marking them Required on an input TypedDict forces
callers to provide values they don't have and wouldn't supply when
referencing an existing image generation call by id and type.

Fixes openai#2648
@okxint
okxint requested a review from a team as a code owner July 31, 2026 06:44

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

Copy link
Copy Markdown

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: 91f9172b37

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +196 to +199
result: Optional[str]
"""The generated image encoded in base64."""

status: Required[Literal["in_progress", "completed", "generating", "failed"]]
status: Literal["in_progress", "completed", "generating", "failed"]

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 Mirror optional image fields in ResponseInputParam

This only fixes the standalone ResponseInputItemParam; the primary responses.create(..., input=...) overload imports ResponseInputParam from response_input_param.py, which defines a separate ImageGenerationCall union member that still has result: Required[Optional[str]] and status: Required[...]. In the usual responses.create(input=[{"type": "image_generation_call", "id": ...}]) path, type checkers will still require those output-only fields, so the typing bug remains for the main Responses API unless the mirrored type in response_input_param.py is updated too.

Useful? React with 👍 / 👎.

@jbeckwith-oai jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed exact head 91f9172b377cf1fe48ef70a11acf6271647001af. Two blockers:

  • [P2] Apply the type fix to the primary Responses input alias. This changes ImageGenerationCall only in response_input_item_param.py, but client.responses.create(), .parse(), and .stream() use the duplicate definition in response_input_param.py, where result and status are still Required. A Pyright repro of the documented id-only input still fails for responses.create() while the changed input_tokens.count() path accepts it. Please update the source spec/codegen so both public aliases stay consistent and add a type-checked regression for the main ResponseInputParam path.

  • [P2] Drop or complete the unrelated null-output-text commit. Commit 9018ec5e is outside this PR's stated scope and only guards Response.output_text after a model exists. Its test uses model_construct() to bypass validation, while ResponseOutputText.text remains non-nullable and structured parsing still calls parse_text() with the null value. Strict validation and responses.parse(..., text_format=...) therefore remain broken for the issue this commit claims to address. Please rebase it out into a focused PR, or make the schema/parser fix complete with API-boundary and structured-parse tests.

Validation notes: git diff --check passes, but ruff check currently reports an unsorted import block in tests/lib/responses/test_responses.py, ruff format --check would reformat that file, hosted checks are absent, and the PR is currently merge-conflicted.

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.

ImageGenerationCall input param type incorrectly requires result and status

2 participants