BrainyBeeBrainyBee
ExploreBlogStart Studying
HomeDeveloping AI Apps and Agents on Azure (AI-103)Configure image-editing workflows, including inpainting, mask-based edits, and prompt-driven modifications
Lesson2,607 words

Configure image-editing workflows, including inpainting, mask-based edits, and prompt-driven modifications

AI-103 › Unit 3: Implement computer vision solutions › Design and implement image- and video-generation solutions › Configure image-editing workflows, including inpainting, mask-based edits, and prompt-driven modifications

Configure image-editing workflows, including inpainting, mask-based edits, and prompt-driven modifications

Editing uses a different endpoint from generation, a different content type, and one parameter whose semantics are the reverse of most people's intuition: in a mask, the transparent pixels mark what gets edited. Getting that backwards produces a plausible image with everything changed except the part you meant.

Why This Matters

The mask convention is inverted relative to intuition. "The mask parameter defines the area of the image that you want the model to edit, using fully transparent pixels (alpha of zero) in those areas." Transparent means edit here.

Editing is a different endpoint. /images/edits, with Content-Type: multipart/form-data — not the JSON generation call.

input_fidelity is what keeps the rest of the image intact. It "enables subtle edits to an image without changing unrelated areas", which is exactly the property an editing workflow needs — and mini does not support it.

Mask rules, verbatim

The mask must be a PNG, must have the same dimensions as the input image, and marks the editable region with fully transparent pixels (alpha of zero). The input image must be less than 50 MB and PNG or JPG. Four facts, all commonly tested.

Prerequisites

  • The image models and their size rules from the generation objective.
  • What an alpha channel is, and that JPEG has none.
  • multipart/form-data as a file-upload content type.
  • input_fidelity and its role in preserving style and faces.

Learning Objectives

By the end of this lesson you will be able to:

  1. Call the edits endpoint with the correct content type and fields.
  2. Construct a mask that edits the intended region.
  3. Distinguish inpainting, variations, and prompt-driven edits.
  4. Preserve unrelated areas with input_fidelity.
  5. Apply the model, size, and format constraints that carry over from generation.

Building Blocks

The endpoint.

https://<resource>.openai.azure.com/openai/deployments/<deployment>/images/edits?api-version=<version>

Headers: Content-Type: multipart/form-data and api-key. Fields are supplied as form parts — image[], prompt, model, mask, size, n, quality.

Model support. All current image models support editing: GPT-Image-2 ("improved editing performance with inpainting and variations"), GPT-Image-1.5, GPT-Image-1, and GPT-Image-1-Mini ("inpainting and variations with mask + prompt").

The mask.

RuleDetail
MeaningFully transparent pixels (alpha of zero) mark the area to edit
FormatMust be a PNG
DimensionsSame as the input image
Input imageLess than 50 MB, PNG or JPG

input_fidelity. Controls "how much effort the model puts into matching the style and features, especially facial features, of input images". High "preserves faces more accurately than standard mode" and "enables subtle edits to an image without changing unrelated areas". Not supported by gpt-image-1-mini.

Carried-over constraints. quality (low/medium/high), output_format (png/jpeg, no WEBP), output_compression (JPEG only, 0–100, default 100), background: transparent (GPT-image-1 only, requires PNG), the size rules per family, base64 responses, and 5 images per minute default quota.

Three kinds of edit

Attribute
Mask supplied

Yes

No

No

Scope of change

Only the transparent region

The whole image, reinterpreted

Whatever the prompt implies

Fits

Replace one object; remove a defect

Alternative takes on the same subject

Global restyle, colour or lighting change

Control

Highest — you draw the region

Lowest

Medium — via input_fidelity

Deep Dive

The mask, and why it is inverted

The mask is a PNG the same size as the input image, and the region you want changed is marked by fully transparent pixels — alpha of zero.

The intuition most people bring is the opposite: paint the area you care about in white or black, leaving the rest clear. Under that convention the model edits everything except the intended region, and because the output is a coherent image rather than an error, the mistake is not obvious from the response — the subject changes and the background stays, when you wanted the reverse.

Two structural consequences follow.

The mask must carry an alpha channel, which is why it must be a PNG. A JPEG mask cannot express the instruction at all.

Dimensions must match exactly. A mask drawn at a different scale, or exported after a resize, targets the wrong pixels. Since the source image must also be under 50 MB and PNG or JPG, an application that accepts user uploads needs a normalisation step — check size, convert format, and generate the mask against the normalised image, not the original.

Building an inpainting workflow

  1. 1

    Normalise the input

    Under 50 MB, PNG or JPG, at a size the target model accepts.

Three kinds of edit, and choosing between them

The distinction is whether a mask is supplied and how much of the image is in scope.

Inpainting supplies a mask, so only the transparent region is regenerated. This is the highest-control option and the right answer whenever the requirement names a specific area — replace the object on the table, remove the blemish, change the sign text. The prompt should describe what belongs in that region, not restate the whole scene, because everything outside the mask is fixed.

Variations supply no mask: the model reinterprets the image as a whole, producing alternative takes on the same subject. Useful for exploring, useless when a specific region must change and the rest must not.

Prompt-driven modification also supplies no mask but directs the change through the prompt — restyle, relight, change the palette. Scope is whatever the prompt implies, and the lever for restraint is input_fidelity: set high, it "enables subtle edits to an image without changing unrelated areas".

A useful rule: if you can draw the region, mask it. A mask is a precise, deterministic instruction; a prompt asking the model to change only one thing is a request it may interpret broadly.

Preserving what should not change

The characteristic editing failure is collateral change — the requested edit lands, and the face, the branding, or the background shifts slightly too.

input_fidelity is the documented control. It governs "how much effort the model puts into matching the style and features, especially facial features, of input images", preserves faces more accurately at high, and enables subtle edits without changing unrelated areas.

Two consequences for design.

Mini is excluded from fidelity-sensitive editing, since input_fidelity is not supported by gpt-image-1-mini — and mini also defaults to medium quality where the others default to high, so a cost comparison that ignores both is misleading.

There is a trade-off. Higher fidelity to the input means less freedom to follow a divergent prompt. A large stylistic change with fidelity pinned high will be resisted; the combination to reach for is a mask plus high fidelity, where the mask grants freedom exactly where you want it and fidelity protects everything else.

An inverted mask fails silently

Because the service returns a valid image either way, an inverted mask produces a confident wrong result: the surroundings are regenerated and the target is untouched. There is no error to catch, so the check belongs in the workflow — assert that the region you intend to edit has alpha zero before submitting, and review early outputs against the intended region rather than assuming success.

What carries over from generation

Editing inherits the generation constraints, and forgetting them is a common source of failed calls.

Size rules by family. The gpt-image-1 series accepts 1024x1024, 1024x1536, 1536x1024; GPT-Image-2 accepts arbitrary resolutions under its four simultaneous constraints — edges multiples of 16 px, long edge to 3,840 px, ratio to 3:1, pixels 655,360–8,294,400.

Format rules. output_format is png or jpeg with WEBP unsupported; output_compression (0–100, default 100) is JPEG only; background: transparent requires PNG and is GPT-image-1 only — which matters for editing a product shot into a transparent cutout.

Response and throughput. The GPT-image-1 series always returns base64, and default quota is 5 images per minute — a bulk retouching workflow will hit that first.

Worked Examples

Example 1 — the wrong half changed. A workflow masks a product on a table intending to replace it. The output keeps the product and changes the table and background.

The mask is inverted. Transparent pixels — alpha of zero — mark the area to edit, so the product region must be transparent and the surroundings opaque. Note this produced a valid image rather than an error, which is why the assertion belongs in the workflow.

Example 2 — a blemish removal that alters the face. Retouching removes a mark but subtly changes facial features.

Raise input_fidelity, which controls matching of "style and features, especially facial features" and "enables subtle edits without changing unrelated areas". Combine it with a tight mask covering only the blemish. If the workflow is on gpt-image-1-mini, move off it — mini does not support input_fidelity.

Example 3 — a mask that will not apply. A user uploads a 60 MB TIFF; the application resizes it for display and generates a mask from the resized version.

Two failures. The input must be under 50 MB and PNG or JPG, so the TIFF needs converting. And the mask must have the same dimensions as the input image — a mask built from the display-sized copy does not match the submitted original. Normalise first, then mask against the normalised image.

Visual Explanations

Mask semantics:

Loading Diagram...
Figure 1 — Mermaid diagram

Choosing the edit type:

Loading Diagram...
Figure 2 — Mermaid diagram

Common Mistakes

Inverting the mask. Transparent = edit; the error is silent.

Using a JPEG mask. It has no alpha channel; the mask must be PNG.

Mask dimensions not matching the input image.

Submitting an image of 50 MB or more, or an unsupported format.

Sending JSON to the edits endpoint. It takes multipart/form-data.

Describing the whole scene in an inpainting prompt. Describe the masked region.

Editing on mini where fidelity matters. input_fidelity is unsupported there.

Expecting high fidelity and a large stylistic change together. Use a mask to grant freedom locally.

Forgetting the generation constraints carry over. Sizes, formats, base64, 5 images/minute.

Practice Exercises

  1. State the four mask and input rules.
  2. Which pixels are edited, and why does an inverted mask not produce an error?
  3. Distinguish inpainting, variations, and prompt-driven edits.
  4. Which parameter preserves unrelated areas, and which model lacks it?
  5. A user uploads a 60 MB TIFF. List every problem before an edit can run.
▶Answers
  1. The mask must be a PNG; it must have the same dimensions as the input image; the editable area is marked with fully transparent pixels (alpha of zero); and the input image must be less than 50 MB in PNG or JPG.
  2. The fully transparent pixels are edited. An inverted mask still describes a valid instruction, so the service returns a coherent image with the surroundings regenerated and the target untouched — no error is raised, which is why the check must live in the workflow.
  3. Inpainting supplies a mask and regenerates only the transparent region — highest control, right when a specific area must change. Variations supply no mask and reinterpret the whole image. Prompt-driven edits supply no mask and direct a global change via the prompt, restrained with input_fidelity.
  4. input_fidelity — it "enables subtle edits to an image without changing unrelated areas" and preserves facial features at high. It is not supported by gpt-image-1-mini.
  5. The file exceeds the 50 MB limit and TIFF is not an accepted input format (PNG or JPG only). Additionally, generating the mask from a resized display copy breaks the same-dimensions rule — normalise the image first, then build the mask against the normalised version.

Summary & Concept Map

Editing runs through /images/edits with multipart/form-data, and every current image model supports inpainting and variations with mask plus prompt. The mask is the crux: a PNG of identical dimensions whose fully transparent pixels (alpha zero) mark the region to edit — inverted, it silently regenerates the surroundings instead. Inputs must be under 50 MB in PNG or JPG. Choose inpainting whenever the region can be drawn, variations for alternatives, and prompt-driven edits for global change restrained by input_fidelity, which preserves style and facial features and enables edits without changing unrelated areas — and is unavailable on mini. All the generation constraints carry over: family size rules, output_compression on JPEG only, transparency on GPT-image-1 with PNG, base64 responses, and 5 images per minute.

Loading Diagram...
Figure 3 — Mermaid diagram
Loading flashcards…

Sources and freshness

Written against current Microsoft Learn documentation for the AI-103 skills measured (16 April 2026), reviewed 2026-08-20. Microsoft Learn controls every changing product contract — availability, preview status, quotas, limits, regional support, naming, and retirement dates all move independently of this lesson. Where a scenario turns on a specific number or a GA/preview boundary, confirm it against the product's own page before relying on it.

All Developing AI Apps and Agents on Azure (AI-103) Study Resources

Related Notes

  • Choose an appropriate method for retrieval and indexing2,778 words
  • Quick Note — Choose an appropriate method for retrieval and indexing888 words
  • Choose an appropriate model for each task, including LLMs, small language models, multimodal models, and Foundry Tools3,097 words
  • Quick Note — Choose an appropriate model for each task, including LLMs, small language models, multimodal models, and Foundry Tools1,041 words
  • Choose appropriate memory, tool, and knowledge integration services for agent solutions2,815 words
  • Quick Note — Choose appropriate memory, tool, and knowledge integration services for agent solutions949 words
  • Choose the appropriate Foundry services for generative tasks, grounding, vector search, agent workflows, or multimodal processing2,733 words
  • Quick Note — Choose the appropriate Foundry services for generative tasks, grounding, vector search, agent workflows, or multimodal processing901 words
  • Apply responsible AI instrumentation, including evaluators, safety evaluations, and explanation tooling2,891 words
  • Configure safety filters, guardrails, risk detection, and content moderation2,795 words
  • Govern agent behavior with oversight modes, constraints, and tool-access controls2,863 words
  • Implement auditing through trace logging, provenance metadata, and approval workflows2,624 words

Ready to study Developing AI Apps and Agents on Azure (AI-103)?

Practice tests, flashcards, and all study notes — free, no sign-up.

Start Studying

Ready to study Developing AI Apps and Agents on Azure (AI-103)?

Practice tests, flashcards, and all study notes — free, no sign-up needed.

Start Studying — Free
Developing AI Apps and Agents on Azure (AI-103) ResourcesExplore All HivesBlogHome

© 2026 BrainyBee. Free AI-powered exam prep.

Loading Diagram...
Flowchart, top to bottom. Mask PNG - same dimensions connects to Fully transparent pixels<br/>alpha = 0. Mask PNG - same dimensions] --> T[Fully transparent pixels<br/>alpha = 0 connects to Opaque pixels. T connects to REGENERATED by the model. O connects to KEPT unchanged. E connects to Invert these and the<br/>surroundings change instead -<br/>with no error returned.
Loading Diagram...
Flowchart, top to bottom. Editing requirement connects to Can you draw the region?. Q1 connects to INPAINTING with a mask<br/>highest control (Yes). Q1 connects to Global change or alternatives? (No). Q2 connects to Prompt-driven<br/>restrain with input_fidelity (Global change). Q2 connects to Variations<br/>no mask, whole image (Alternatives). IN connects to Add high input_fidelity<br/>to protect everything outside. PD connects to FID. FID connects to Not available on gpt-image-1-mini.
Loading Diagram...
Flowchart, top to bottom. Image editing connects to Endpoint. Image editing] --> EP[Endpoint connects to Mask. Image editing] --> EP[Endpoint connects to Kinds of edit. Image editing] --> EP[Endpoint connects to Preservation. Image editing] --> EP[Endpoint connects to Carried-over rules. EP connects to /images/edits. EP connects to multipart/form-data. MK connects to PNG, same dimensions. 13 more statements.

Image editing — retrieval

Card 1 of 6

Front of flashcard 1 of 6

What does the mask mark?

hard

The mask "defines the area of the image that you want the model to edit, using fully transparent pixels (alpha of zero) in those areas". Transparent = edit here. An inverted mask returns a valid image with the surroundings changed — no error.

mask

Image editing — retrieval

Card 1

Front

What does the mask mark?

Back

The mask "defines the area of the image that you want the model to edit, using fully transparent pixels (alpha of zero) in those areas". Transparent = edit here. An inverted mask returns a valid image with the surroundings changed — no error.

Card 2

Front

Mask and input constraints

Back

Mask must be a PNG with the same dimensions as the input image. Input image must be less than 50 MB and PNG or JPG. Normalise uploads before generating the mask.

Card 3

Front

The edits endpoint

Back

.../images/edits?api-version=... with Content-Type: multipart/form-data and api-key. Form parts include image[], prompt, model, mask, size, n, quality — not a JSON body.

Card 4

Front

Inpainting vs variations vs prompt-driven

Back

Inpainting — mask supplied, only the transparent region regenerates; highest control. Variations — no mask, whole image reinterpreted. Prompt-driven — no mask, global change directed by the prompt and restrained with input_fidelity. If you can draw the region, mask it.

Card 5

Front

Preserving unrelated areas

Back

input_fidelity — matches "style and features, especially facial features" and "enables subtle edits to an image without changing unrelated areas". Not supported by gpt-image-1-mini, which also defaults to medium quality.

Card 6

Front

Fidelity vs freedom

Back

High input_fidelity resists large stylistic changes. For a big local change with a protected surround, combine a mask (freedom exactly where you want it) with high fidelity (protection everywhere else).

Image editing — retrieval

Card 1

Front

What does the mask mark?

Back

The mask "defines the area of the image that you want the model to edit, using fully transparent pixels (alpha of zero) in those areas". Transparent = edit here. An inverted mask returns a valid image with the surroundings changed — no error.

Card 2

Front

Mask and input constraints

Back

Mask must be a PNG with the same dimensions as the input image. Input image must be less than 50 MB and PNG or JPG. Normalise uploads before generating the mask.

Card 3

Front

The edits endpoint

Back

.../images/edits?api-version=... with Content-Type: multipart/form-data and api-key. Form parts include image[], prompt, model, mask, size, n, quality — not a JSON body.

Card 4

Front

Inpainting vs variations vs prompt-driven

Back

Inpainting — mask supplied, only the transparent region regenerates; highest control. Variations — no mask, whole image reinterpreted. Prompt-driven — no mask, global change directed by the prompt and restrained with input_fidelity. If you can draw the region, mask it.

Card 5

Front

Preserving unrelated areas

Back

input_fidelity — matches "style and features, especially facial features" and "enables subtle edits to an image without changing unrelated areas". Not supported by gpt-image-1-mini, which also defaults to medium quality.

Card 6

Front

Fidelity vs freedom

Back

High input_fidelity resists large stylistic changes. For a big local change with a protected surround, combine a mask (freedom exactly where you want it) with high fidelity (protection everywhere else).