Foldbun Stack
中Get an API keyComing soon
Background removal

Background removal API (BiRefNet)

Model licence: MIT

BiRefNet separates the foreground from the background with hair-level alpha and returns a cutout PNG or the alpha mask.

Read the docsGet an API keyComing soonAPI reference

Price

Billed itemUnitCredits
Background removal
One image per request.
per image1
≈ US$0.001 top-up

Available to accounts with a balance (paid pool). Prices are in credits. Failed calls cost nothing.

Sample results

Recorded responses of the API on sample images.

Product photo: subject cut out from the background, shown on a checkerboard.
Product photo1 image, output cutoutcutout 560×315
Potted plant: subject cut out from the background, shown on a checkerboard.
Potted plant1 image, output cutoutcutout 560×420
Dog with fur: subject cut out from the background, shown on a checkerboard.
Dog with fur1 image, output cutoutcutout 560×517

Request and response

POST https://api.stack.foldbun.com/v1/remove-background with a Bearer API key.

API reference
# macOS: replace "base64 -w0 sneaker.webp" with "base64 -i sneaker.webp"
curl https://api.stack.foldbun.com/v1/remove-background \
  -H "Authorization: Bearer $FOLDBUN_API_KEY" \
  -H "Content-Type: application/json" \
  -d @- <<EOF
{"model": "birefnet", "image": {"base64": "$(base64 -w0 sneaker.webp)"},
 "options": {"output": "cutout"}}
EOF
import base64, os, requests

with open("sneaker.webp", "rb") as f:
    image = base64.b64encode(f.read()).decode()

r = requests.post(
    "https://api.stack.foldbun.com/v1/remove-background",
    headers={"Authorization": f"Bearer {os.environ['FOLDBUN_API_KEY']}"},
    json={"model": "birefnet",
          "image": {"base64": image},
          "options": {"output": "cutout"}},
    timeout=60,
)
r.raise_for_status()
print(r.json())
open("sneaker-cutout.png", "wb").write(base64.b64decode(r.json()["data"]))
Response (shortened)
{
  "id": "call_01a1913f-131f-7b89-9f1e-7423a3895c99",
  "model": "birefnet",
  "image": {"height": 1008, "id": "img_d239eb4c…6504", "width": 1791},
  "data": {"$file": "sneaker-cutout.webp"},
  "format": "png",
  "height": 1008,
  "width": 1791,
  "cost": 1,
  "balance": 1233.56
}

Request fields

FieldDescription
image{"base64": "…"} or {"id": "img_…"} from an earlier response.
options.outputcutout (default): RGBA image of the subject. matte: 8-bit grayscale alpha matte.
options.formatpng (default) or webp.

Pricing examples

CallCredits
1 image
1
1
≈ US$0.001 top-up
1,000 images
1,000 × 1
1000
≈ US$1.00 top-up

Limits

Images
JPEG, PNG, static WebP; up to 20 MiB and 40 megapixels
Coordinates
Pixels of the original image with EXIF orientation applied; masks can be smaller and carry their own size
Images per call
1
Output
PNG or WebP, returned as base64 in data with width and height
Rate limit
Depends on the account tier; see GET /v1/models

Frequently asked questions

How is BiRefNet billed?

Each image costs 1.0 credits. The model is in the paid pool, available to accounts with a balance. Failed calls cost nothing.

What is the difference between cutout and matte?

cutout returns an RGBA image of the subject. matte returns an 8-bit grayscale alpha matte that can be applied to the original image.

Which output formats are available?

png (default) and webp. The image is returned base64-encoded in data, together with its width and height.

Related models

Models and pricing

Foldbun Stack — pay-per-use vision model API

Call BiRefNet through the REST API; the docs list request and response formats.

Read the docsGet an API keyComing soon