This repository was archived by the owner on May 29, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 231
Fix generateImage edit mode for Azure OpenAI provider #1806
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -787,25 +787,38 @@ export async function OpenAIImageGeneration( | |
| quality, | ||
| style, | ||
| outputFormat, | ||
| image, | ||
| mask, | ||
| ...rest | ||
| } = req | ||
| const { trace } = options || {} | ||
| let url = `${cfg.base}/images/generations` | ||
|
|
||
| // Detect edit mode based on presence of image parameter | ||
| const isEditMode = !!image | ||
| let url = `${cfg.base}/images/${isEditMode ? 'edits' : 'generations'}` | ||
|
|
||
| const isDallE = /^dall-e/i.test(model) | ||
| const isDallE2 = /^dall-e-2/i.test(model) | ||
| const isDallE3 = /^dall-e-3/i.test(model) | ||
| const isGpt = /^gpt-image/i.test(model) | ||
|
|
||
| const body: any = { | ||
| model, | ||
| prompt, | ||
| size, | ||
| quality, | ||
| style, | ||
| ...rest, | ||
| } | ||
|
|
||
| // Add edit mode parameters if present | ||
| if (isEditMode) { | ||
| body.image = image | ||
| if (mask) body.mask = mask | ||
| // Model parameter is typically not used in edit mode for OpenAI | ||
| } else { | ||
| body.model = model | ||
| } | ||
|
|
||
| // auto is the default quality, so always delete it | ||
| if (body.quality === "auto" || isDallE2) delete body.quality | ||
| if (isDallE3) { | ||
|
|
@@ -846,12 +859,17 @@ export async function OpenAIImageGeneration( | |
| if (cfg.type === "azure") { | ||
| const version = cfg.version || AZURE_OPENAI_API_VERSION | ||
| trace?.itemValue(`version`, version) | ||
| url = | ||
| trimTrailingSlash(cfg.base) + | ||
| "/" + | ||
| body.model + | ||
| `/images/generations?api-version=${version}` | ||
| delete body.model | ||
| if (isEditMode) { | ||
| // Azure doesn't use model in the URL for edit mode | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. YES, model is needed in edits just like for generations!
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed! The model is now included in the Azure URL construction for edit mode, just like it is for generations. Commit: b8eb307 |
||
| url = trimTrailingSlash(cfg.base) + `/images/edits?api-version=${version}` | ||
| } else { | ||
| url = | ||
| trimTrailingSlash(cfg.base) + | ||
| "/" + | ||
| body.model + | ||
| `/images/generations?api-version=${version}` | ||
| delete body.model | ||
| } | ||
| } | ||
|
|
||
| const fetch = await createFetch(options) | ||
|
|
||
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it really the case?
I think we should always set the model
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're absolutely right! I've fixed this - the model parameter is now always set in the request body for both edit and generation modes. Commit: b8eb307