Skip to main content
FLUX Erase removes the masked object and reconstructs the scene behind it with contextually coherent content in a single call. Useful for product photography clean-up, removing unwanted elements, scene simplification, or privacy-aware image editing.

Example output

Drag the slider to compare the input image with the masked region outlined in green (left) against the cleaned result (right).

More examples

Endpoint

Submit an erase job:
Poll for the result:

Quick start

The API uses an asynchronous workflow:
1

Prepare a mask

Create a black/white PNG at the same resolution as your input image. White (255) marks the pixels to remove, black (0) marks pixels to keep.
2

Submit an erase request

POST the input image and mask (both base64-encoded) to the endpoint. No prompt is needed — the model uses a built-in erase instruction.
3

Poll for the result

Use the returned polling_url to check status until the image is ready.

Request parameters

No prompt is sent by the caller — the server applies a fixed erase instruction internally.

Response format

Initial response

Polling response (success)

When status is "Ready", use result.sample.
Signed delivery URLs are only valid for 10 minutes. Retrieve your result within this timeframe.

Mask guidelines

  • Format: black-and-white PNG at the same resolution as the input image.
  • White (255) = pixels to remove. Black (0) = pixels to keep.
  • The server converts the binary mask to a green fill internally — callers only send the binary mask.
  • Dilation (dilate_pixels): expanding the mask by a few pixels typically improves removal quality by ensuring the model fully covers object edges. For typical SAM (Segment Anything) masks, start with 10.

Tips for best results

  • Use a mask that fully covers the object you want to remove. If the mask is leaving an edge, increase dilate_pixels.
  • For objects with soft edges (hair, fur, smoke) that masks rarely capture cleanly, use a higher dilate_pixels value (15–20).
  • The model was trained on images at ~1 megapixel across 9 aspect ratios from 1:2 to 2:1. Inputs close to these resolutions produce the best results — significant deviations may reduce quality.

Troubleshooting

  • 403 Forbidden — your API key is missing or your project doesn’t have access to this endpoint.
  • 422 / validation errors — check base64 encoding and that the mask matches the input image dimensions exactly.
  • Visible halo around removed object — increase dilate_pixels.
  • Reconstruction looks off — verify the mask covers the entire object including shadows or reflections you want gone.
For the full list of HTTP status codes and polling response types returned by the API, see the Errors reference.