- Erase Foreground
Description
The Erase Foreground endpoint removes the primary subject (foreground) from the input image and intelligently generates the background to fill the erased area.
Output Characteristics
- Returns the edited image at its original resolution, ensuring full visual fidelity without any automatic resizing or downscaling.
- Only the foreground is removed; all other areas remain unaltered, preserving pixel-perfect accuracy in untouched regions.
- When
preserve_alpha=trueand the input image includes an alpha channel, the output maintains original transparency values (both full and partial).
Content Moderation
This endpoint includes granular content moderation controls to ensure safe usage across all stages of processing:
- Input Image Moderation – Scans the uploaded image and stops processing if inappropriate or restricted content is detected.
- Output Image Moderation – Evaluates the generated image and blocks the response if it violates safety guidelines.
The image that you would like to remove the background from. Supported input types:
- Base64-encoded string
- URL pointing to an image file that is publicly accessible and available at the time of processing.
Accepted formats: JPEG, JPG, PNG, WEBP.
Controls whether the alpha channel values from the input image are retained in the output, if the input includes an alpha channel.
- When true: The output image maintains the original transparency of fully and partially transparent pixels.
- When false: The output image is fully opaque.
- Has no effect if the input image does not include an alpha channel.
Specifies the response mode.
- When
false(default), the request is processed asynchronously: the API immediately returns a status URL to track progress. - When
true, the request is processed synchronously: the API hold the connection open until the proccess is complete and then returns the final image URL in the response.
Optional URL for receiving the result via webhook when the async job completes. See Webhooks.
When enabled, applies content moderation to input visual.
Expected behavior:
- Processing stops if the image fails moderation.
- Returns a 422 error with details about which parameter failed.
curl -i -X POST \
https://engine.prod.bria-api.com/v2/image/edit/erase_foreground \
-H 'Content-Type: application/json' \
-H 'api_token: string' \
-d '{
"image": "example"
}'{ "result": { "image_url": "string" }, "request_id": "string" }