GPT Image edit with a mask and several images: which is masked?

OpenAI applies the mask to the first of several input images. Sume forwards input_references in order with mask_url, so put the image to edit first.

4 min readSume
All posts

OpenAI's guide says that with multiple input images the mask is applied to the first image. Sume's docs state no such rule, but the provider adapter forwards your input_references in the order you send them together with mask_url, so put the image you want edited first and the extra references after it.

OpenAI's rule is from its image generation guide; Sume's from the Image API docs and adapter code, read 2026-09-30. Sume does not document which reference the mask binds to, so this is the cautious choice, not a documented guarantee.

What are OpenAI's mask rules?

The guide says the image to edit and the mask must be the same format and size (under 50MB), and that the mask must contain an alpha channel. It also notes masking with GPT Image is prompt-based, so the model uses the mask as guidance.

What does Sume accept?

Mask and reference fields on Sume, read 2026-09-30: https://docs.sume.com/models/images
FieldDocumented behavior
input_referencesUp to 16 images on ChatGPT Image 2.5; must be public HTTPS URLs
mask_urlOptional public HTTPS mask URL for ChatGPT Image 2.5 edits
More than 16 referencesAdapter error: GPT Image accepts at most 16 reference images

How should I order the request?

Put the image to edit at index 0 of input_references, then style or object references. Build the mask to match that first image's size and format, following OpenAI's rule. If you do not need extra references, send one image and the mask to avoid the question.

const body = {
  model: "openai/gpt-image-2.5",
  prompt: "replace the masked sofa with a green armchair",
  input_references: [
    { type: "image_url", image_url: { url: "https://example.com/room.png" } },
    { type: "image_url", image_url: { url: "https://example.com/chair.png" } },
  ],
  mask_url: "https://example.com/room-mask.png",
};
console.log(JSON.stringify(body));

What else should I check?

Read the alpha-channel details in mask alpha channel and mask_url, and test with a small mask first. Unlisted parameters are rejected with 400 unsupported_parameter, so confirm the model's supported_parameters include mask_url.

Sources

Related posts

More in Developers

All Developers posts

Written by Sume