Skip to main content
POST
/
v1
/
flux-tools
/
erase-v1
Erase an object from an image
curl --request POST \
  --url https://api.bfl.ai/v1/flux-tools/erase-v1 \
  --header 'Content-Type: application/json' \
  --header 'x-key: <api-key>' \
  --data '
{
  "image": "<string>",
  "mask": "<string>",
  "dilate_pixels": 10,
  "seed": 42,
  "safety_tolerance": 2,
  "output_format": "png",
  "webhook_url": "<string>",
  "webhook_secret": "<string>"
}
'
import requests

url = "https://api.bfl.ai/v1/flux-tools/erase-v1"

payload = {
"image": "<string>",
"mask": "<string>",
"dilate_pixels": 10,
"seed": 42,
"safety_tolerance": 2,
"output_format": "png",
"webhook_url": "<string>",
"webhook_secret": "<string>"
}
headers = {
"x-key": "<api-key>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'x-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
image: '<string>',
mask: '<string>',
dilate_pixels: 10,
seed: 42,
safety_tolerance: 2,
output_format: 'png',
webhook_url: '<string>',
webhook_secret: '<string>'
})
};

fetch('https://api.bfl.ai/v1/flux-tools/erase-v1', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.bfl.ai/v1/flux-tools/erase-v1",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'image' => '<string>',
'mask' => '<string>',
'dilate_pixels' => 10,
'seed' => 42,
'safety_tolerance' => 2,
'output_format' => 'png',
'webhook_url' => '<string>',
'webhook_secret' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-key: <api-key>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.bfl.ai/v1/flux-tools/erase-v1"

payload := strings.NewReader("{\n \"image\": \"<string>\",\n \"mask\": \"<string>\",\n \"dilate_pixels\": 10,\n \"seed\": 42,\n \"safety_tolerance\": 2,\n \"output_format\": \"png\",\n \"webhook_url\": \"<string>\",\n \"webhook_secret\": \"<string>\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("x-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.bfl.ai/v1/flux-tools/erase-v1")
.header("x-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"image\": \"<string>\",\n \"mask\": \"<string>\",\n \"dilate_pixels\": 10,\n \"seed\": 42,\n \"safety_tolerance\": 2,\n \"output_format\": \"png\",\n \"webhook_url\": \"<string>\",\n \"webhook_secret\": \"<string>\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.bfl.ai/v1/flux-tools/erase-v1")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"image\": \"<string>\",\n \"mask\": \"<string>\",\n \"dilate_pixels\": 10,\n \"seed\": 42,\n \"safety_tolerance\": 2,\n \"output_format\": \"png\",\n \"webhook_url\": \"<string>\",\n \"webhook_secret\": \"<string>\"\n}"

response = http.request(request)
puts response.read_body
{
  "id": "<string>",
  "polling_url": "<string>",
  "cost": 123,
  "input_mp": 123,
  "output_mp": 123
}
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}

Authorizations

x-key
string
header
required

Body

application/json

Input model for public FLUX.2 erase.

image
string
required

Base64-encoded input image or HTTP(S) image URL.

mask
string
required

Base64-encoded black/white mask or HTTP(S) image URL. White pixels indicate the object to remove; black pixels are preserved. Must have the same dimensions as the input image.

dilate_pixels
integer
default:10

Number of pixels to dilate the mask by before removal. Dilation helps cover object edges. Maximum is 25 pixels.

Required range: 0 <= x <= 25
seed
integer | null

Optional seed for reproducibility.

Example:

42

safety_tolerance
integer
default:2

Tolerance level for input and output moderation. Between 0 and 5, 0 being most strict, 5 being least strict.

Required range: 0 <= x <= 5
Example:

2

output_format
enum<string> | null
default:png
Available options:
jpeg,
png,
webp
webhook_url
string<uri> | null

URL to receive webhook notifications

Required string length: 1 - 2083
webhook_secret
string | null

Optional secret for webhook signature verification

Response

Successful Response

id
string
required
polling_url
string
required
cost
number | null

Cost in credits for this request

input_mp
number | null

Input megapixels (2 decimal places)

output_mp
number | null

Output megapixels (2 decimal places)