Skip to content

Remove Background

Image-to-Image • bria

View as MarkdownAgent setup
  • Third-party

Bria's RMBG 2.0 model removes the background from an image and returns a PNG cutout with a transparent background. Partial transparency from the input's alpha channel is kept by default.

Model Info
Terms and Licenselink ↗
More informationlink ↗
Pricing
  • Per image$0.018

Usage

const response = await env.AI.run(
  'bria/remove-background',
  { image: 'https://labs-assets.bria.ai/sandbox-example-inputs/remove_background_example.jpg' },
)
console.log(response)
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \
  --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
  "model": "bria/remove-background",
  "input": {
    "image": "https://labs-assets.bria.ai/sandbox-example-inputs/remove_background_example.jpg"
  }
}'
Portrait Cutout
{
  "state": "Completed",
  "result": {
    "image": "https://examples.aig.cloudflare.com/bria/remove-background/portrait-cutout.png"
  }
}

Parameters

image
stringrequiredminLength: 1JPEG or PNG image (RGB, RGBA, or CMYK), a public URL or base64-encoded image data (a `data:` URI prefix is accepted).
preserve_alpha
booleanKeep partial transparency from the input alpha channel. When false, every foreground pixel is fully opaque. Default true.
visual_input_content_moderation
booleanReject the request if the input image fails content moderation. Default false.
visual_output_content_moderation
booleanFail the request if the result fails content moderation. Default false.
image
stringformat: uriURL of the PNG cutout with a transparent background. Bria hosts it for a limited time (3 days by default); download it to keep it.

API Schemas (Raw)

Input
Output

Was this helpful?