OP Inference

Background removal

Cut the subject out of an image and get back a PNG with a transparent background.

Background removal is an image job on POST /v1/images/generations. Send the image as image and no prompt. The job answers 202; see How media jobs work for polling and output.

The model is zhengpeng7/birefnet-massive-tr-dis5k-tr-tes, a BiRefNet checkpoint. The output is always a PNG with an alpha channel: the subject keeps its pixels and the background becomes transparent.

Send a URL

curl https://api.opinference.com/v1/images/generations \
  -H "Authorization: Bearer $OP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "zhengpeng7/birefnet-massive-tr-dis5k-tr-tes",
    "image": "https://example.com/product.jpg"
  }'

The URL follows the rules on Inputs: absolute, https, and reachable without cookies or extra headers.

Send the image itself

If the image is not hosted anywhere, send it in the body as a base64 data: URI:

curl https://api.opinference.com/v1/images/generations \
  -H "Authorization: Bearer $OP_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{
    \"model\": \"zhengpeng7/birefnet-massive-tr-dis5k-tr-tes\",
    \"image\": \"data:image/png;base64,$(base64 < product.png | tr -d '\n')\"
  }"

The rules for an inline image:

RuleValueRefused with
Typeimage/png, image/jpeg or image/webp400 invalid_request, param: "image"
Encoding;base64, standard alphabet with padding, no line breaks400 invalid_request, param: "image"
ContentThe bytes must be the type the URI names400 invalid_request, param: "image"
SizeAt most 10 MiB after decoding413 payload_too_large
RetentionNot under zdr400 invalid_request, param: "image"

Inline data is accepted for image on image jobs only. Every other media input takes a URL.

If the gateway is holding as many inline images as it can at that moment, the request is refused with 503 server_busy before anything is charged. Retry it shortly.

We store an inline image once, for as long as your retention class keeps media inputs, and delete it when that period ends. The job shows it as a stored input with its type, size and SHA-256, never as the base64 text. See Data retention.

Billing

Each output image is billed once. The price is on the model's page under Models.

Zero data retention

This model is not available under zdr. The provider that runs it keeps inputs for up to 30 days and may use them to train models, so a zdr request for it gets 404 no_endpoint_available, whether the image is a URL or inline. Nothing is charged. The inline rule's 400 in the table above is for an image model that does offer a zdr endpoint.