Bria RMBG 2.0

Effortlessly extract backgrounds with unmatched precision, powered by models trained exclusively on licensed data for safe and risk-free commercial use. Unlike traditional binary masking, Bria RMBG 2.0 delivers non-binary masks with 256 levels of transparency, ensuring seamless edges and natural blending for diverse creative workflows.


API

If you're looking for an API, you can choose from your desired programming language.

POST
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 import requests import base64 # Use this function to convert an image file from the filesystem to base64 def image_file_to_base64(image_path): with open(image_path, 'rb') as f: image_data = f.read() return base64.b64encode(image_data).decode('utf-8') # Use this function to fetch an image from a URL and convert it to base64 def image_url_to_base64(image_url): response = requests.get(image_url) image_data = response.content return base64.b64encode(image_data).decode('utf-8') # Use this function to convert a list of image URLs to base64 def image_urls_to_base64(image_urls): return [image_url_to_base64(url) for url in image_urls] api_key = "YOUR_API_KEY" url = "https://api.segmind.com/v1/bria-remove-background" # Request payload data = { "image": "https://segmind-resources.s3.amazonaws.com/input/34bdeb2a-792a-4ef3-88b8-ffc0aa8391f7-53d09e98-fbe3-4b0a-ae58-a4c966d40ea0_1.jpeg", "preserve_alpha": True, "visual_input_content_moderation": False, "visual_output_content_moderation": False } headers = {'x-api-key': api_key} response = requests.post(url, json=data, headers=headers) print(response.content) # The response is the generated image
RESPONSE
image/jpeg
HTTP Response Codes
200 - OKImage Generated
401 - UnauthorizedUser authentication failed
404 - Not FoundThe requested URL does not exist
405 - Method Not AllowedThe requested HTTP method is not allowed
406 - Not AcceptableNot enough credits
500 - Server ErrorServer had some issue with processing

Attributes


imagestr *

Specify the image URI for background removal. Use URL for web images, Base64 for local files.


preserve_alphaboolean ( default: true )

Decide if output retains transparency. Set true for semi-transparent, false for fully opaque results.


visual_input_content_moderationboolean ( default: 1 )

Control input content moderation. Enable for processing in sensitive areas.


visual_output_content_moderationboolean ( default: 1 )

Manage output content moderation. Activate for safe public use outputs.

To keep track of your credit usage, you can inspect the response headers of each API call. The x-remaining-credits property will indicate the number of remaining credits in your account. Ensure you monitor this value to avoid any disruptions in your API usage.

Resources to get you started

Everything you need to know to get the most out of Bria RMBG 2.0

# Guide to Using RMBG 2.0 Effectively

RMBG 2.0 is Bria AI’s high-precision background removal model. This guide will help you configure the right parameters for different workflows, optimize output quality, and seamlessly integrate into your pipeline.

## 1. Basic Usage
1. Provide a valid image URI or Base64:
   ```json
   { "image": "https://example.com/product.jpg" }
  1. Choose preserve_alpha:
    • true (default): PNG with smooth, semi-transparent edges
    • false: opaque JPEG-style cutout
  2. (Optional) Toggle content moderation:
    {
      "visual_input_content_moderation": true,
      "visual_output_content_moderation": true
    }
    

2. Recommended Parameters by Use Case

E-commerce & Retail

Isolate products for catalogs, A/B testing, and storefronts.

{
  "preserve_alpha": false,
  "custom_threshold": 0.4
}

• Opaque cutouts simplify batch compositing on white or colored backgrounds.
• Lower custom_threshold sharpens edges around glossy or reflective items.

Graphic & UX Design

Generate assets for icons, mockups, thumbnails.

{
  "preserve_alpha": true,
  "custom_threshold": 0.6
}

• Retain anti-aliased borders for smooth UI elements.
• Mid-level threshold keeps fine details in text or logos.

Social Media Content

Create eye-catching banners or story visuals.

{
  "preserve_alpha": false,
  "visual_output_content_moderation": true
}

• Opaque cutouts stack easily over dynamic backgrounds.
• Enable output moderation to ensure brand-safe imagery.

Digital Art & Compositing

Prep elements for collage, layering, or generative fill.

{
  "preserve_alpha": true,
  "custom_threshold": 0.5
}

• Smooth transparency lets you blend edges naturally.
• Pair with Bria AI’s generative fill or background replacement.

Automated Pipelines

Scale background removal in CI/CD workflows.

{
  "preserve_alpha": false,
  "visual_input_content_moderation": true
}

• Use asynchronous endpoints to queue jobs and poll statuses.
• Automate moderation and error-handling in your pipeline code.

3. Asynchronous Processing

  • Submit multiple jobs: POST /v2/rmbg/jobs
  • Poll for completion: GET /v2/rmbg/jobs/{job_id}
  • Fetch results: PNG or JPEG URL when done

4. Pro Tips for Best Results

  • Use high-resolution inputs (≥1024 px) for cleaner masks.
  • Experiment with custom_threshold (0.3–0.7) on text and logos.
  • For public-facing apps, always enable both input/output moderation.
  • Chain with Bria AI’s enhancement or generative fill for advanced edits.

By tuning preserve_alpha, custom_threshold, and moderation flags, you can unlock RMBG 2.0’s full potential—whether you’re removing backgrounds for e-commerce, design, or large-scale automation.

Other Popular Models

Discover other models you might be interested in.

Cookie settings

We use cookies to enhance your browsing experience, analyze site traffic, and personalize content. By clicking "Accept all", you consent to our use of cookies.