Skip to content

fix(images): restrict webp for gpt-image-2 and add missing model#1865

Open
Deepakhub202 wants to merge 3 commits intoopenai:masterfrom
Deepakhub202:API-ignores-it-and-return-PNG
Open

fix(images): restrict webp for gpt-image-2 and add missing model#1865
Deepakhub202 wants to merge 3 commits intoopenai:masterfrom
Deepakhub202:API-ignores-it-and-return-PNG

Conversation

@Deepakhub202
Copy link
Copy Markdown

@Deepakhub202 Deepakhub202 commented May 4, 2026

Changes being requested

Fix incorrect output_format typing for image generation.

Instead of removing webp globally, this change restricts webp only for gpt-image-2 using conditional types.

  • gpt-image-2 → allows only png | jpeg
  • other models → still allow webp

Also updates related types to work with the new union-based structure.

Additional context & links

Related issue: #1850

The API ignores output_format: "webp" for gpt-image-2 and always returns PNG, so the SDK should reflect this behavior accurately.

@Deepakhub202 Deepakhub202 requested a review from a team as a code owner May 4, 2026 17:27
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: 2c729c04ed

ℹ️ 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 thread src/resources/images.ts Outdated
* supported for the GPT image models. Must be one of `png`, `jpeg`, or `webp`.
*/
output_format?: 'png' | 'jpeg' | 'webp' | null;
output_format?: 'png' | 'jpeg' | null;
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 Restore webp in image-generate output_format typing

This change narrows ImageGenerateParamsBase.output_format to png|jpeg for all models, which blocks valid requests for models that still support WebP (for example, the same file still documents WebP in generation responses/events and allows it for edits). In practice, TypeScript users can no longer pass output_format: 'webp' even when using non-gpt-image-2 models, so the SDK type now under-represents supported API behavior; this should be modeled conditionally by model instead of removing webp globally.

Useful? React with 👍 / 👎.

@Deepakhub202
Copy link
Copy Markdown
Author

Hi, I’ve updated the fix to use conditional typing so that webp is only restricted for gpt-image-2 while remaining available for other models. Let me know if any further changes are needed. @pedrobarretocw

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.

1 participant