Repository navigation
[1.x] Support image masks for OpenAI image edits - #1260
Open
dwivedianuj9118 wants to merge 1 commit into
Open
dwivedianuj9118 wants to merge 1 commit into
dwivedianuj9118 wants to merge 1 commit into
Conversation
dwivedianuj9118
force-pushed
the
openai-image-edit-mask
branch
from
November 24, 2026 11:27
809b41f to
2be9eb2
Compare
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.
Closes #880.
OpenAI's
/v1/images/editsendpoint takes an optionalmaskfile for inpainting, but every attachment is sent asimage/image[]and provider options are sent as form fields, so there was no way to send one.This takes a
maskout of the provider options when editing and attaches it as the multipartmaskfile:As discussed on the issue, this keeps the
ImageGatewaycontract and the other image gateways unchanged. The mask is read the same way as the source images, so base64, remote, local, stored and uploaded images all work. A mask without an image to edit throws anInvalidArgumentExceptioninstead of being sent to the generations endpoint.Tests cover the mask on gpt-image and dall-e-2 models, an unsupported mask type, and a mask without an attachment.