FLUX 3.1 Image

FLUX 3.1 Image is Black Forest Labs' image generation and editing model, built for speed at every size from 1 MP up to native 4K. It keeps people and objects consistent across multiple references, edits locally through masks and bounding boxes while leaving the rest of the image untouched, and changes or translates text in its original lettering. It suits high-volume work such as product catalogs, virtual try-on, storyboards and key art.

Complete technical specification for integration
Ready-to-use code snippets for common workflows
Step-by-step tutorials for advanced use cases
← All GuidesMasked edits
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
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.
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
The mask goes in inputs.maskImage, next to the image it edits in inputs.referenceImages:
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
})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 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
}
]'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{
"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
}Response
{
"data": [
{
"taskType": "imageInference",
"taskUUID": "6e2c9a41-3f7b-4d18-a5c0-8b4e1f7d2a93",
"imageUUID": "b47d0e85-1a6c-4f29-9d3b-e5c8a2f61b07",
"imageURL": "https://im.runware.ai/image/os/a14d18/ws/2/ii/b47d0e85-1a6c-4f29-9d3b-e5c8a2f61b07.jpg"
}
]
}Five rules govern the pair:
- A mask needs a reference.
inputs.maskImagewithoutinputs.referenceImagesis 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.
widthandheighthave 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
The same instruction on the same kitchen, sent without the mask:
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
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.
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
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.
- App screen

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.
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
})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 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
}
]'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{
"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
}Response
{
"data": [
{
"taskType": "imageInference",
"taskUUID": "d2f81b6a-4c37-4e90-8a15-3b9c7e0f5d42",
"imageUUID": "7a3e5c90-8b14-4d6f-a2e9-1c5f8b3d0e76",
"imageURL": "https://im.runware.ai/image/os/a14d18/ws/2/ii/7a3e5c90-8b14-4d6f-a2e9-1c5f8b3d0e76.jpg"
}
]
}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
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.
Drop an image here or browse
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:
magick -size 832x1248 xc:black -fill white -draw "roundrectangle 240,238 594,988 36,36" mask-phone.pngLeave 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
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.
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 describe the positions directly.
Tips for best results
-
Put the image you are editing first. The mask applies to the first reference, and there is no way to aim it at another.
-
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.
-
Send the source's own size. A masked edit keeps the first reference's shape, and
widthandheightmore than 3% off it are rejected. -
Keep naming the target. The mask chooses the area and the instruction still says what happens inside it.
-
Size the area for a new object. An added object fills the white area, so its shape is the object's shape.
-
Leave a margin. The edge, the shadow and the contact point need room just outside the object.
-
Let the reference carry the design. With a mask and a reference, say what to take from image 2 and leave its contents undescribed.
-
Count your references. Nine at most with a mask, ten without.






