feat(provider/openai): add gpt-image-2 model support#14680
Merged
Conversation
Adds gpt-image-2 to the OpenAI image model type union, prefix list used to skip response_format (which the model rejects), and the Gateway image model ID union. Includes a regression test and example.
felixarntz
approved these changes
Apr 21, 2026
Contributor
|
✅ Backport PR created: #14682 |
gr2m
added a commit
that referenced
this pull request
Apr 21, 2026
gpt-image-2 (added in #14680) is sufficient — no dated alias needed.
3 tasks
Contributor
|
Please release this |
Merged
6 tasks
DeJeune
added a commit
to CherryHQ/cherry-studio
that referenced
this pull request
Apr 22, 2026
…14488) ### What this PR does Before this PR: Calling the newly-released `gpt-image-2` model (shipped 2026-04-21) via OpenAI image generation fails with `400 Unknown parameter: 'response_format'`. `@ai-sdk/openai@3.0.49` (our current AI SDK v6 line dep) unconditionally sends `response_format: 'b64_json'` for any model not in its `defaultResponseFormatPrefixes` allow-list, and `gpt-image-2` is not in that list. After this PR: `@ai-sdk/openai@3.0.49` is patched to add `gpt-image-2` to both `modelMaxImagesPerCall` and `defaultResponseFormatPrefixes` in all four compiled dist entry points (`dist/index.{js,mjs}`, `dist/internal/index.{js,mjs}`). This mirrors vercel/ai#14680, which was backported to `release-v6.0` via vercel/ai#14682 on 2026-04-21 but has not yet been published to npm. The patch is registered in `pnpm.patchedDependencies` alongside the existing AI SDK patches. Fixes #14485 ### Why we need it and why it was done in this way The upstream fix (vercel/ai#14680 / #14682) is already merged into the `release-v6.0` branch, so a patch is a stable, low-risk equivalent of the forthcoming `@ai-sdk/openai@3.0.54+`. Once that version ships on npm, this patch can be dropped and replaced with a dependency bump. The following tradeoffs were made: - Patching compiled `dist/` files instead of source: matches the repository's existing convention (see `patches/@ai-sdk__google@3.0.55.patch`, `patches/@ai-sdk__openai-compatible@2.0.37.patch`) and avoids rebuilding the package. - Not touching `.d.ts` type declarations: the upstream `OpenAIImageModelId` union already accepts `(string & {})`, so runtime behavior is the only thing that needs correcting. The following alternatives were considered: - Waiting for the npm release of `@ai-sdk/openai@3.0.54` — rejected because users are actively hitting the bug today. - Using a pnpm `overrides` entry pointing at the `release-v6.0` git branch — rejected because it pulls an unversioned moving target and conflicts with the locked semver range. - Stripping `response_format` in an `aiCore` plugin — rejected because the fix belongs at the provider layer and a plugin would permanently mask similar issues for other models. Links to places where the discussion took place: vercel/ai#14680, vercel/ai#14682 ### Breaking changes None. ### Special notes for your reviewer - The patch adds `gpt-image-2` at the expected positions in each of the four dist files; diff is small and mechanical. Verified locally: `node_modules/@ai-sdk/openai/dist/index.js:1753,1761` now contain `gpt-image-2` after `pnpm install`. - UI model picker changes are intentionally out of scope. Users select `gpt-image-2` by model ID today; once upstream publishes, a follow-up can refresh `src/renderer/src/config/models/default.ts` and friends. ### Checklist - [x] PR: The PR description is expressive enough and will help future contributors - [x] Code: [Write code that humans can understand](https://en.wikiquote.org/wiki/Martin_Fowler#code-for-humans) and [Keep it simple](https://en.wikipedia.org/wiki/KISS_principle) - [x] Refactor: You have [left the code cleaner than you found it (Boy Scout Rule)](https://learning.oreilly.com/library/view/97-things-every/9780596809515/ch08.html) - [x] Upgrade: Impact of this change on upgrade flows was considered and addressed if required - [ ] Documentation: A [user-guide update](https://docs.cherry-ai.com) was considered and is present (link) or not required. Check this only when the PR introduces or changes a user-facing feature or behavior. - [x] Self-review: I have reviewed my own code (e.g., via [`/gh-pr-review`](/.claude/skills/gh-pr-review/SKILL.md), `gh pr diff`, or GitHub UI) before requesting review from others ### Release note ```release-note fix(ai-sdk/openai): patch @ai-sdk/openai to support OpenAI's gpt-image-2 model, resolving "Unknown parameter: 'response_format'" errors. ``` --------- Signed-off-by: suyao <sy20010504@gmail.com>
sb0404l
pushed a commit
to sb0404l/cherry-studio
that referenced
this pull request
Apr 23, 2026
…herryHQ#14488) ### What this PR does Before this PR: Calling the newly-released `gpt-image-2` model (shipped 2026-04-21) via OpenAI image generation fails with `400 Unknown parameter: 'response_format'`. `@ai-sdk/openai@3.0.49` (our current AI SDK v6 line dep) unconditionally sends `response_format: 'b64_json'` for any model not in its `defaultResponseFormatPrefixes` allow-list, and `gpt-image-2` is not in that list. After this PR: `@ai-sdk/openai@3.0.49` is patched to add `gpt-image-2` to both `modelMaxImagesPerCall` and `defaultResponseFormatPrefixes` in all four compiled dist entry points (`dist/index.{js,mjs}`, `dist/internal/index.{js,mjs}`). This mirrors vercel/ai#14680, which was backported to `release-v6.0` via vercel/ai#14682 on 2026-04-21 but has not yet been published to npm. The patch is registered in `pnpm.patchedDependencies` alongside the existing AI SDK patches. Fixes CherryHQ#14485 ### Why we need it and why it was done in this way The upstream fix (vercel/ai#14680 / #14682) is already merged into the `release-v6.0` branch, so a patch is a stable, low-risk equivalent of the forthcoming `@ai-sdk/openai@3.0.54+`. Once that version ships on npm, this patch can be dropped and replaced with a dependency bump. The following tradeoffs were made: - Patching compiled `dist/` files instead of source: matches the repository's existing convention (see `patches/@ai-sdk__google@3.0.55.patch`, `patches/@ai-sdk__openai-compatible@2.0.37.patch`) and avoids rebuilding the package. - Not touching `.d.ts` type declarations: the upstream `OpenAIImageModelId` union already accepts `(string & {})`, so runtime behavior is the only thing that needs correcting. The following alternatives were considered: - Waiting for the npm release of `@ai-sdk/openai@3.0.54` — rejected because users are actively hitting the bug today. - Using a pnpm `overrides` entry pointing at the `release-v6.0` git branch — rejected because it pulls an unversioned moving target and conflicts with the locked semver range. - Stripping `response_format` in an `aiCore` plugin — rejected because the fix belongs at the provider layer and a plugin would permanently mask similar issues for other models. Links to places where the discussion took place: vercel/ai#14680, vercel/ai#14682 ### Breaking changes None. ### Special notes for your reviewer - The patch adds `gpt-image-2` at the expected positions in each of the four dist files; diff is small and mechanical. Verified locally: `node_modules/@ai-sdk/openai/dist/index.js:1753,1761` now contain `gpt-image-2` after `pnpm install`. - UI model picker changes are intentionally out of scope. Users select `gpt-image-2` by model ID today; once upstream publishes, a follow-up can refresh `src/renderer/src/config/models/default.ts` and friends. ### Checklist - [x] PR: The PR description is expressive enough and will help future contributors - [x] Code: [Write code that humans can understand](https://en.wikiquote.org/wiki/Martin_Fowler#code-for-humans) and [Keep it simple](https://en.wikipedia.org/wiki/KISS_principle) - [x] Refactor: You have [left the code cleaner than you found it (Boy Scout Rule)](https://learning.oreilly.com/library/view/97-things-every/9780596809515/ch08.html) - [x] Upgrade: Impact of this change on upgrade flows was considered and addressed if required - [ ] Documentation: A [user-guide update](https://docs.cherry-ai.com) was considered and is present (link) or not required. Check this only when the PR introduces or changes a user-facing feature or behavior. - [x] Self-review: I have reviewed my own code (e.g., via [`/gh-pr-review`](/.claude/skills/gh-pr-review/SKILL.md), `gh pr diff`, or GitHub UI) before requesting review from others ### Release note ```release-note fix(ai-sdk/openai): patch @ai-sdk/openai to support OpenAI's gpt-image-2 model, resolving "Unknown parameter: 'response_format'" errors. ``` --------- Signed-off-by: suyao <sy20010504@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
gpt-image-2to theOpenAIImageModelIdtype union,modelMaxImagesPerCall(10, matchinggpt-image-1.5), and thedefaultResponseFormatPrefixeslist so the provider does not sendresponse_format: 'b64_json'to OpenAI — which the model rejects with400 Unknown parameter: 'response_format'.openai/gpt-image-2toGatewayImageModelId.gpt-image-1/chatgpt-image-latestcases to assert noresponse_formatis sent.examples/ai-functionsentry for the new model.