1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const axios = require('axios');
const api_key = "YOUR API-KEY";
const url = "https://api.segmind.com/v1/bria-remove-background";
const 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
};
(async function() {
try {
const response = await axios.post(url, data, { headers: { 'x-api-key': api_key } });
console.log(response.data);
} catch (error) {
console.error('Error:', error.response.data);
}
})();
Specify the image URI for background removal. Use URL for web images, Base64 for local files.
Decide if output retains transparency. Set true for semi-transparent, false for fully opaque results.
Control input content moderation. Enable for processing in sensitive areas.
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.
Bria AI's latest flagship model, RMBG 2.0, is designed for professionally removing image background. It is trained on licensed data, making it safe for commercial use as it generates compliant outputs. The model is ideal for developers, creators, and product managers to get speedy background removal with precision and accuracy. It functions on deep learning to create smooth alpha channels with natural and clean transparency, with a soft transition. RMBG 2.0 utilizes non-binary masks with 256 transparency levels, ensuring harmonious and invisible image merging and preserving the fine details for realistic image output, unlike the commonly available models, which produce harsh edges with obvious binary masks. Furthermore, being a part of Bria AI’s image-editing suite, it operates with asynchronous processing for scalable image handling to manage and efficiently execute large volumes of background-removing tasks.
{ "preserve_alpha": false, "custom_threshold": 0.5 }
Q: Which image formats are supported?
A: RMBG 2.0 supports JPEG, PNG, WebP via URI or Base64. Output supports PNG (with alpha) or JPEG (opaque).
Q: How do I retain transparency?
A: Set preserve_alpha: true
; RMBG 2.0 will export a PNG with smooth, anti-aliased alpha channels.
Q: Can I process images in bulk?
A: Yes, you can use asynchronous endpoints to execute multiple jobs and poll for results programmatically.
Q: What is content moderation?
A: Two toggles ensure the output is "safe" for commercial use -
• visual_input_content_moderation
: blocks sensitive inputs
• visual_output_content_moderation
: filters outputs before public release.
Q: How accurate is the mask?
A: RMBG 2.0 achieves >95% pixel-level accuracy on high-contrast, well-lit inputs. The non-binary mask with 256 transparency levels further gives sharp edges.