Inpaint and outpaint
Redraw part of an image with a mask, or extend it past its edges.
qwen-image/inpaint changes one part of an image and keeps the rest as it was. Send the image, an instruction in prompt, and one of:
mask: an image the same size as yours, white where the model redraws and black where your image stays as it is. Use it to remove or replace something: "Remove the man", "Add a lamp on the sideboard".outpaint: pixels to add on any side,{"left": 600}or{"top": 200, "bottom": 200}. The model draws the new area to match: "Extend the beach to the left".
Away from the mask, or inside the old edges, the result keeps your image's own pixels. Poll the result like any generation.
# Remove the man: the photo and its mask, both inline as data URLs
curl https://tensorfactory.ai/v1/generations \
-H "Authorization: Bearer $TENSORFACTORY_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"model": "qwen-image/inpaint", "prompt": "Remove the man",
"image": "data:image/jpeg;base64,'"$(base64 < street.jpg | tr -d '\n')"'",
"mask": "data:image/png;base64,'"$(base64 < street-mask.png | tr -d '\n')"'"}'
# Extend a photo 600 pixels to the left
curl https://tensorfactory.ai/v1/generations \
-H "Authorization: Bearer $TENSORFACTORY_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"model": "qwen-image/inpaint", "prompt": "Extend the beach to the left", "image": "https://example.com/beach.jpg", "outpaint": {"left": 600}}'Make a mask
- The same width and height as the image, in pixels. Another size answers
400namingmask. - White (any grey of 128 or more) is redrawn, black is kept. Transparent pixels count as white, so a PNG with the area to redraw cut out works too.
- Paint a little past the edges of what you remove, its shadow included: the model only redraws what the mask covers.
masktakes the same forms asimage: an https link, a data URL or an upload'sasset_id. The image and the mask together are at most 7 MiB.
Outpaint limits
Outpaint is in beta: on some seeds the new margins can cut a subject at the old edge or show a visible line where the
photo meets the new area. Run it again with another seed if that happens. A mask fill is not affected.
- Send any of
left,top,rightandbottom, whole numbers of pixels. The rest are 0, and at least one is more than 0. - The result is at most twice your image on each side: a 1000 x 800 image takes up to 1000 pixels more across (left and right together) and 800 more down.
- The image, and the result with its margins, are each at most 8192 pixels a side and 16,777,216 pixels.
The generation shows what you sent: mask (its upload's asset_id) or outpaint (the four margins), the other null. result.width and result.height are the image's size, plus the margins.
What else it takes
- Send
maskoroutpaint, not both, and one of them: either mistake answers400. - No
aspect_ratio,resolution,image_2,image_3ortransparent_background: the result is your image's size. seedandoutput_formatas for an edit. A prompt that names a real person is refused, as for any edit.- It takes no
stepsormode: a fill with amaskruns 8 steps, an outpaint 4. The generation'sstepsshows which. Prices are on Pricing.