---
title: Masked edits — FLUX 3.1 Image | Runware Docs
url: https://runware.ai/docs/models/bfl-flux-3-1-image/guides/masked-edits
description: "How to aim a FLUX 3.1 Image edit with a mask: picking one of two identical objects, placing something new and putting a reference onto a product."
---
### [Introduction](https://runware.ai/docs/models/bfl-flux-3-1-image/guides/masked-edits#introduction)

A sentence names a thing. When the frame holds **two of that thing**, the sentence can only pick one by describing its position, and the model may read the position differently than you meant it.

`inputs.maskImage` picks it by pointing. You send a black and white image at the source's aspect ratio, **white where the edit may happen and black where the image stays as it is**, and FLUX 3.1 Image applies the instruction inside the white area.

**Source and mask**:

![A kitchen with a long white marble island and two identical matte white dome pendant lamps above it, with the masked area over the right lamp highlighted](https://runware.ai/docs/assets/source-kitchen.B0r_pZxq_14MdGA.jpg)

> **Prompt**: A modern kitchen with a long white marble island across the lower half of the frame and two identical pendant lamps hanging above it, each a matte white metal dome on a thin black cord, one centered on the left third of the frame and one centered on the right third, both hanging at the same height in the upper half. Pale oak cabinets and a plain white wall behind, three bar stools tucked under the island. Soft daylight from a window out of frame on the left. Straight-on shot at standing height, 35mm lens. Photoreal kitchen interior photography, bright neutral palette.

**Result**:

![The same kitchen with the right pendant now in brushed brass and the left one still matte white](https://runware.ai/docs/assets/output-kitchen-masked.BxZGqdWp_RpVim.jpg)

> **Prompt**: Change the pendant lamp to brushed brass with a warm satin finish. Keep its dome shape, its size, its cord and its height above the island unchanged, and keep everything else in the image exactly the same.

The prompt says "the pendant lamp" and never says which, so **the mask carries all of the targeting**. That is what lets one instruction run across a whole catalog of room photos, with a mask drawn per photo.

This guide covers the request, picking one object out of several, placing something new, combining a mask with a reference, making a mask and when to leave it out.

### [The request](https://runware.ai/docs/models/bfl-flux-3-1-image/guides/masked-edits#the-request)

The mask goes in `inputs.maskImage`, next to the image it edits in `inputs.referenceImages`:

**TypeScript**:

```typescript
import { createClient } from '@runware/sdk'

const client = await createClient({ apiKey: process.env.RUNWARE_API_KEY })

const [result] = await client.run({
  model: 'bfl:flux@3.1-image',
  positivePrompt: 'Change the pendant lamp to brushed brass with a warm satin finish. Keep its dome shape, its size, its cord and its height above the island unchanged, and keep everything else in the image exactly the same.',
  inputs: {
    referenceImages: [
      'https://assets.runware.ai/guides/bfl-flux-3-1-image/masked-edits/source-kitchen.jpg'
    ],
    maskImage: 'https://assets.runware.ai/guides/bfl-flux-3-1-image/masked-edits/mask-kitchen.png'
  },
  width: 1248,
  height: 832
})
```

**Python**:

```python
import asyncio
import os

from runware import Runware

async def main():
    async with Runware(api_key=os.environ["RUNWARE_API_KEY"]) as client:
        results = await client.run({
            "model": "bfl:flux@3.1-image",
            "positivePrompt": "Change the pendant lamp to brushed brass with a warm satin finish. Keep its dome shape, its size, its cord and its height above the island unchanged, and keep everything else in the image exactly the same.",
            "inputs": {
                "referenceImages": [
                    "https://assets.runware.ai/guides/bfl-flux-3-1-image/masked-edits/source-kitchen.jpg"
                ],
                "maskImage": "https://assets.runware.ai/guides/bfl-flux-3-1-image/masked-edits/mask-kitchen.png"
            },
            "width": 1248,
            "height": 832
        })

asyncio.run(main())
```

**cURL**:

```bash
curl https://api.runware.ai/v1 \
  -H "Authorization: Bearer $RUNWARE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '[
    {
      "taskType": "imageInference",
      "taskUUID": "6e2c9a41-3f7b-4d18-a5c0-8b4e1f7d2a93",
      "model": "bfl:flux@3.1-image",
      "positivePrompt": "Change the pendant lamp to brushed brass with a warm satin finish. Keep its dome shape, its size, its cord and its height above the island unchanged, and keep everything else in the image exactly the same.",
      "inputs": {
        "referenceImages": [
          "https://assets.runware.ai/guides/bfl-flux-3-1-image/masked-edits/source-kitchen.jpg"
        ],
        "maskImage": "https://assets.runware.ai/guides/bfl-flux-3-1-image/masked-edits/mask-kitchen.png"
      },
      "width": 1248,
      "height": 832
    }
  ]'
```

**CLI**:

```bash
runware run bfl:flux@3.1-image \
  positivePrompt="Change the pendant lamp to brushed brass with a warm satin finish. Keep its dome shape, its size, its cord and its height above the island unchanged, and keep everything else in the image exactly the same." \
  inputs.referenceImages.0=https://assets.runware.ai/guides/bfl-flux-3-1-image/masked-edits/source-kitchen.jpg \
  inputs.maskImage=https://assets.runware.ai/guides/bfl-flux-3-1-image/masked-edits/mask-kitchen.png \
  width=1248 \
  height=832
```

**JSON**:

```json
{
  "taskType": "imageInference",
  "taskUUID": "6e2c9a41-3f7b-4d18-a5c0-8b4e1f7d2a93",
  "model": "bfl:flux@3.1-image",
  "positivePrompt": "Change the pendant lamp to brushed brass with a warm satin finish. Keep its dome shape, its size, its cord and its height above the island unchanged, and keep everything else in the image exactly the same.",
  "inputs": {
    "referenceImages": [
      "https://assets.runware.ai/guides/bfl-flux-3-1-image/masked-edits/source-kitchen.jpg"
    ],
    "maskImage": "https://assets.runware.ai/guides/bfl-flux-3-1-image/masked-edits/mask-kitchen.png"
  },
  "width": 1248,
  "height": 832
}
```

Five rules govern the pair:

- **A mask needs a reference.** `inputs.maskImage` without `inputs.referenceImages` is rejected, since there is nothing for it to point at.
- **It applies to the first reference.** With several references, the image you are editing goes at the front of the array.
- **It has the first reference's aspect ratio.** A mask more than 3% off that ratio is rejected. Draw it at the image's pixel size and the white area lands on the object you drew it over.
- **The output keeps the first reference's shape.** `width` and `height` have to sit within 3% of its aspect ratio, so sending the source's own size, as above, keeps the result aligned with it pixel for pixel.
- **Nine references at most.** The mask takes the tenth slot, so a masked request carries one reference fewer than an unmasked one.

### [Picking one object out of several](https://runware.ai/docs/models/bfl-flux-3-1-image/guides/masked-edits#picking-one-object-out-of-several)

The same instruction on the same kitchen, sent **without the mask**:

**Source**:

![The kitchen with two identical matte white dome pendants over the marble island](https://runware.ai/docs/assets/source-kitchen.B0r_pZxq_14MdGA.jpg)

> **Prompt**: A modern kitchen with a long white marble island across the lower half of the frame and two identical pendant lamps hanging above it, each a matte white metal dome on a thin black cord, one centered on the left third of the frame and one centered on the right third, both hanging at the same height in the upper half. Pale oak cabinets and a plain white wall behind, three bar stools tucked under the island. Soft daylight from a window out of frame on the left. Straight-on shot at standing height, 35mm lens. Photoreal kitchen interior photography, bright neutral palette.

**Without a mask**:

![The kitchen after the unmasked edit, with both pendant lamps changed to brushed brass](https://runware.ai/docs/assets/output-kitchen-unmasked.BDoybcdQ_2b7qOB.jpg)

> **Prompt**: Change the pendant lamp to brushed brass with a warm satin finish. Keep its dome shape, its size, its cord and its height above the island unchanged, and keep everything else in the image exactly the same.

Without the mask the model has to decide which lamp "the pendant lamp" means, and here **it changed both**. Rewording to "the pendant on the right" is the other fix, and it holds only as long as every photo in the set has the lamps in the same arrangement. A mask works **the same whatever the wording**, which matters once the instruction is a template and the photos vary.

### [Placing something new](https://runware.ai/docs/models/bfl-flux-3-1-image/guides/masked-edits#placing-something-new)

When the edit adds an object, the white area marks **where it goes and how big it is**. The instruction below asks for a framed print and says nothing about its position or size.

**Source and mask**:

![A hotel bedroom with a white-linen king bed, a gray upholstered headboard and brass reading lamps on oak bedside tables, with the masked area on the empty wall above the headboard highlighted](https://runware.ai/docs/assets/source-bedroom.BDl19qdw_O8uV3.jpg)

> **Prompt**: A hotel bedroom with a king bed made up in crisp white linen and a wide gray upholstered headboard across the lower half of the frame, a white oak bedside table with a small brass reading lamp on each side. The wall above the headboard is plain warm white and completely empty, from the top of the headboard to the ceiling. Soft daylight from a window out of frame on the right. Straight-on shot at standing height from the foot of the bed, 35mm lens, the bed centered. Photoreal hospitality photography, calm neutral palette.

**Result**:

![The same bedroom with a framed abstract landscape print in sand and sage tones hung above the headboard](https://runware.ai/docs/assets/output-bedroom.pa3PDRyc_ZjXPvm.jpg)

> **Prompt**: Hang a framed print on the wall: a large abstract landscape in soft sand and sage tones behind glass in a thin natural oak frame, hung level with a faint shadow along its lower edge. Keep the bed, the headboard, the bedside tables, the lamps, the framing and the lighting unchanged.

**The white area sets the object's size**, so draw it as big as the object you want. The print fills the rectangle edge to edge, which makes the mask the layout decision and the prompt only has to describe the print and how it hangs. For a hotel that wants to preview artwork options across its rooms, the mask stays fixed per room photo and the prompt changes per piece.

### [Masks with a reference](https://runware.ai/docs/models/bfl-flux-3-1-image/guides/masked-edits#masks-with-a-reference)

A mask combines with more references, which is how a specific design lands **on an exact spot of a product**. The mask still applies to image 1, and image 2 supplies what goes inside it.

**Source and mask**:

![A woman's hand holding a black smartphone with a blank glossy screen in front of a blurred green park, with the masked area over the screen highlighted](https://runware.ai/docs/assets/source-phone.BP-sZH6L_Z1pyvbM.jpg)

> **Prompt**: A close-up of a woman's hand holding a black smartphone upright in the center of the frame, the screen facing the camera, switched off and glossy black, the phone filling the middle third of the frame width. A softly blurred city park with green trees behind. Soft daylight from the left, natural skin tones, a short neutral manicure. Straight-on shot at hand height, 85mm lens, shallow depth of field. Photoreal lifestyle product photography for an app store listing, fresh palette.

**Result**:

![The same hand and phone with the fitness app screen showing on the display, a coral step ring and two stat cards visible](https://runware.ai/docs/assets/output-phone.DNHrl0WM_BHLQj.jpg)

> **Prompt**: Show the app screen from image 2 on the display of the phone in image 1, filling the display edge to edge, with a faint glass reflection across it. Keep the hand, the phone body, the blurred park, the framing and the lighting unchanged.

**App screen**:

![A fitness app screen with the greeting Good morning, Maya, a coral progress ring reading 7,842 of 10,000 steps, and cards for heart rate and sleep](https://runware.ai/docs/assets/reference-app.B6FGUFx3_Z1SplOm.jpg)

> **Prompt**: A flat mobile app screenshot of a fitness tracking app, with no phone frame, filling the image edge to edge on a white background. At the top, a greeting reading "Good morning, Maya" in bold dark sans-serif. Below it, a large circular progress ring in coral with "7,842" in the center and "of 10,000 steps" beneath it. Then two rounded cards side by side, one reading "Heart rate" over "68 bpm" and one reading "Sleep" over "7h 20m". A bottom navigation bar with four simple line icons. Clean modern interface design, generous spacing, crisp legible text.

The prompt **assigns roles and leaves the screen to the reference**: it never describes the ring or the cards, because image 2 already carries them. The mask places the screen and the reference fills it, while "a faint glass reflection" makes it read as a photographed display. One hand shot then serves every screen of an app store listing.

**TypeScript**:

```typescript
import { createClient } from '@runware/sdk'

const client = await createClient({ apiKey: process.env.RUNWARE_API_KEY })

const [result] = await client.run({
  model: 'bfl:flux@3.1-image',
  positivePrompt: 'Show the app screen from image 2 on the display of the phone in image 1, filling the display edge to edge, with a faint glass reflection across it. Keep the hand, the phone body, the blurred park, the framing and the lighting unchanged.',
  inputs: {
    referenceImages: [
      'https://assets.runware.ai/guides/bfl-flux-3-1-image/masked-edits/source-phone.jpg',
      'https://assets.runware.ai/guides/bfl-flux-3-1-image/masked-edits/reference-app.jpg'
    ],
    maskImage: 'https://assets.runware.ai/guides/bfl-flux-3-1-image/masked-edits/mask-phone.png'
  },
  width: 832,
  height: 1248
})
```

**Python**:

```python
import asyncio
import os

from runware import Runware

async def main():
    async with Runware(api_key=os.environ["RUNWARE_API_KEY"]) as client:
        results = await client.run({
            "model": "bfl:flux@3.1-image",
            "positivePrompt": "Show the app screen from image 2 on the display of the phone in image 1, filling the display edge to edge, with a faint glass reflection across it. Keep the hand, the phone body, the blurred park, the framing and the lighting unchanged.",
            "inputs": {
                "referenceImages": [
                    "https://assets.runware.ai/guides/bfl-flux-3-1-image/masked-edits/source-phone.jpg",
                    "https://assets.runware.ai/guides/bfl-flux-3-1-image/masked-edits/reference-app.jpg"
                ],
                "maskImage": "https://assets.runware.ai/guides/bfl-flux-3-1-image/masked-edits/mask-phone.png"
            },
            "width": 832,
            "height": 1248
        })

asyncio.run(main())
```

**cURL**:

```bash
curl https://api.runware.ai/v1 \
  -H "Authorization: Bearer $RUNWARE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '[
    {
      "taskType": "imageInference",
      "taskUUID": "d2f81b6a-4c37-4e90-8a15-3b9c7e0f5d42",
      "model": "bfl:flux@3.1-image",
      "positivePrompt": "Show the app screen from image 2 on the display of the phone in image 1, filling the display edge to edge, with a faint glass reflection across it. Keep the hand, the phone body, the blurred park, the framing and the lighting unchanged.",
      "inputs": {
        "referenceImages": [
          "https://assets.runware.ai/guides/bfl-flux-3-1-image/masked-edits/source-phone.jpg",
          "https://assets.runware.ai/guides/bfl-flux-3-1-image/masked-edits/reference-app.jpg"
        ],
        "maskImage": "https://assets.runware.ai/guides/bfl-flux-3-1-image/masked-edits/mask-phone.png"
      },
      "width": 832,
      "height": 1248
    }
  ]'
```

**CLI**:

```bash
runware run bfl:flux@3.1-image \
  positivePrompt="Show the app screen from image 2 on the display of the phone in image 1, filling the display edge to edge, with a faint glass reflection across it. Keep the hand, the phone body, the blurred park, the framing and the lighting unchanged." \
  inputs.referenceImages.0=https://assets.runware.ai/guides/bfl-flux-3-1-image/masked-edits/source-phone.jpg \
  inputs.referenceImages.1=https://assets.runware.ai/guides/bfl-flux-3-1-image/masked-edits/reference-app.jpg \
  inputs.maskImage=https://assets.runware.ai/guides/bfl-flux-3-1-image/masked-edits/mask-phone.png \
  width=832 \
  height=1248
```

**JSON**:

```json
{
  "taskType": "imageInference",
  "taskUUID": "d2f81b6a-4c37-4e90-8a15-3b9c7e0f5d42",
  "model": "bfl:flux@3.1-image",
  "positivePrompt": "Show the app screen from image 2 on the display of the phone in image 1, filling the display edge to edge, with a faint glass reflection across it. Keep the hand, the phone body, the blurred park, the framing and the lighting unchanged.",
  "inputs": {
    "referenceImages": [
      "https://assets.runware.ai/guides/bfl-flux-3-1-image/masked-edits/source-phone.jpg",
      "https://assets.runware.ai/guides/bfl-flux-3-1-image/masked-edits/reference-app.jpg"
    ],
    "maskImage": "https://assets.runware.ai/guides/bfl-flux-3-1-image/masked-edits/mask-phone.png"
  },
  "width": 832,
  "height": 1248
}
```

The order of the array is what makes this work. The phone is image 1 because **the mask always lands on the first reference**, and the screen is image 2 because it only supplies content.

### [Making a mask](https://runware.ai/docs/models/bfl-flux-3-1-image/guides/masked-edits#making-a-mask)

Drop in your source image, paint over the area you want to change and download the mask. It comes out **white on black at the source's own size**, which is the format `inputs.maskImage` expects.

Interactive component not available in Markdown.

For a templated shot, where the product sits in the same place in every photo, **draw the mask in code** instead. A rounded rectangle over the known area is enough, as in this ImageMagick command for the phone mask above:

```bash
magick -size 832x1248 xc:black -fill white -draw "roundrectangle 240,238 594,988 36,36" mask-phone.png
```

Leave **a small margin around the object**. Its edge, its shadow and the point where it meets a surface sit just outside its outline, and the edit needs room to redraw them.

### [When to leave the mask out](https://runware.ai/docs/models/bfl-flux-3-1-image/guides/masked-edits#when-to-leave-the-mask-out)

A mask limits where the edit can happen, so it works against **changes meant to touch the whole frame**. A relight or a new season has to rebuild shadows and reflections everywhere, and a mask around one object stops them at its edge. Those edits belong in [editing images](https://runware.ai/docs/models/bfl-flux-3-1-image/guides/editing-images.md).

When the target appears once and has a clear name, **the instruction already finds it**, and the mask only adds a file to maintain. When you need to move an object or place several at set coordinates, [bounding boxes](https://runware.ai/docs/models/bfl-flux-3-1-image/guides/bounding-boxes.md) describe the positions directly.

### [Tips for best results](https://runware.ai/docs/models/bfl-flux-3-1-image/guides/masked-edits#tips-for-best-results)

1. **Put the image you are editing first.** The mask applies to the first reference, and there is no way to aim it at another.
    
2. **Match the first reference's aspect ratio.** Draw the mask at that image's pixel size so the white area lands where you drew it.
    
3. **Send the source's own size.** A masked edit keeps the first reference's shape, and `width` and `height` more than 3% off it are rejected.
    
4. **Keep naming the target.** The mask chooses the area and the instruction still says what happens inside it.
    
5. **Size the area for a new object.** An added object fills the white area, so its shape is the object's shape.
    
6. **Leave a margin.** The edge, the shadow and the contact point need room just outside the object.
    
7. **Let the reference carry the design.** With a mask and a reference, say what to take from image 2 and leave its contents undescribed.
    
8. **Count your references.** Nine at most with a mask, ten without.