Object removal fails in a recognisable way: the object goes, but a faint halo of it stays — a rim of hair, a shadow edge, a sliver of the original silhouette. It looks worse than not removing it at all.
That artefact almost always comes from the mask, not the model. FLUX Erase has a specific parameter for it, and Black Forest Labs publishes the starting value.
Sourcing note: the mask rules, dilate_pixels guidance, training resolution, and error codes below are taken from Black Forest Labs' FLUX Erase documentation. Nothing here is inferred from experimentation on my side; where BFL gives a numeric recommendation, it is quoted as theirs. Last verified July 30, 2026.
What this guide solves
The pain point: people blame the model for leftover edges and try to fix it with better prompts — except Erase does not take a prompt at all. The fix lives in the mask, and it is a single parameter.
The differentiator: the concrete numbers BFL publishes — start dilation at 10 for SAM masks, 15–20 for soft edges, keep inputs near 1MP — plus what each error code actually means, which no summary of "FLUX Tools" bothers to include.
The basics
Endpoint:
POST https://api.bfl.ai/v1/flux-tools/erase-v1
x-key: $BFL_API_KEYThen poll the returned polling_url until the result is ready, same async pattern as the rest of the FLUX API.
No prompt is accepted. The model uses a built-in instruction and reconstructs what was behind the object on its own. BFL documents it as powered by FLUX.2 Klein 9B, which is why it is quick enough for interactive cleanup.
The mask rules
This is the part to get right.
- Format: black-and-white PNG, same resolution as the input image
- White (255) = pixels to remove
- Black (0) = pixels to keep
- You send only the binary mask; BFL notes the server converts it to a green fill internally
Inverting white and black is the classic first-integration bug: you get an image with everything erased except the object you wanted gone.
dilate_pixels — the setting that removes halos
dilate_pixels expands your mask outward by a few pixels. BFL's guidance:
| Situation | Starting value |
|---|---|
| Typical SAM (Segment Anything) mask | 10 |
| Soft edges — hair, fur, smoke | 15–20 |
| Mask leaving a visible edge | increase it |
The reasoning is mechanical: segmentation masks tend to hug the object slightly inside its true boundary, leaving a one-or-two-pixel ring of the original object outside the mask. The model faithfully keeps that ring, because you told it to. Dilation pushes the boundary out past the object so there is nothing left to preserve.
If you are auto-generating masks with SAM and seeing consistent halos, this is your fix — not a different model.
Resolution matters more than you would expect
BFL states the model was trained on images at ~1 megapixel across 9 aspect ratios from 1:2 to 2:1, and that inputs close to those resolutions produce the best results, with significant deviations potentially reducing quality.
Practical reading: downscale a 24MP camera original to around 1MP before erasing, then composite the cleaned region back at full resolution if you need the pixels. Sending the full-size original is not "higher quality input" here — it is off-distribution.
Extreme aspect ratios beyond 1:2 or 2:1 are the other edge to avoid.
Need the source images before you clean them? Flux 3 AI generates product frames, campaign visuals and reference shots in the browser, plus upscaling for delivery. Open the image generator.
Error codes, decoded
- 403 Forbidden — your API key is missing, or your project does not have access to this endpoint. That second half matters: a key that works for text-to-image is not automatically entitled to Tools.
- 422 / validation error — check your base64 encoding and the required fields.
Treat 403 as a provisioning question rather than an auth typo, and you will find it much faster.
What to use it for
BFL's documented use cases, and what each really means in production:
- Product photography clean-up — removing stands, clamps, reflections and stray props from packshots
- Removing unwanted elements — the passer-by in the background of a location shot
- Scene simplification — stripping clutter so a subject reads clearly at thumbnail size
- Privacy-aware editing — removing identifiable details before publishing
The last one is worth a note: removing a face or a licence plate is a legitimate use, but "the pixels are gone from this render" is not the same as a privacy compliance process. Treat it as a visual tool, not a legal one.
A working checklist
- Mask is a PNG at exactly the input resolution
- White marks what goes, black marks what stays
-
dilate_pixelsstarts at 10, raised to 15–20 for hair, fur or smoke - Input downscaled to roughly 1MP, aspect ratio within 1:2 to 2:1
- 403 checked as an endpoint-entitlement issue, not just a bad key
- Result downloaded promptly — the signed URL expires like every other FLUX result
FAQ
Does FLUX Erase take a prompt? No. It uses a built-in instruction; you supply only an image and a mask.
Which colour removes pixels in the mask? White. Black keeps them.
Why is there still an edge of the object left?
Your mask stops just inside the object boundary. Increase dilate_pixels.
What resolution should the input be? Around 1MP, within 1:2 to 2:1 aspect ratios — that is the documented training distribution.
Which model powers it? FLUX.2 Klein 9B, per BFL's documentation.
What does 403 mean here? Missing key, or a project without access to this specific endpoint.
Can it remove people? Technically yes. For privacy work, treat it as a visual step inside a real process, not the process itself.
Bottom line
Erase is a two-input tool with one tuning knob, and that knob explains nearly every disappointing result. Set the mask convention right, start dilation at 10, raise it for soft edges, and work near 1MP.
If the images you are cleaning need to be created first, generate them in the Flux 3 AI workspace and keep the cleanup step where it belongs.
Sources
- FLUX Erase (BFL documentation) — endpoint, mask guidelines,
dilate_pixelsvalues, 1MP training distribution, error codes, use cases - FLUX Erase announcement (BFL, May 21, 2026) — release and positioning
- Object Removal use case (BFL docs) — editing-model alternative for the same job
- FLUX Tools model page — where Erase sits in the family
- FLUX Outpainting (BFL docs) — the sibling tool that needs no mask
- Image generation quick start (BFL docs) — shared async pattern and signed-URL expiry
- Errors reference (BFL docs) — full error semantics
- FLUX.2 klein model page — the model class behind Erase
- BFL API pricing — how Tools calls are billed
- FLUX API integration guide (BFL docs) — production integration guidance
Scope note: parameters and behaviour as of July 30, 2026. Flux 3 AI is an independent creator workspace, not affiliated with Black Forest Labs.


