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
const axios = require('axios');
const api_key = "YOUR API-KEY";
const url = "https://api.segmind.com/v1/bria-gen-fill";
const data = {
"image": "https://segmind-resources.s3.amazonaws.com/input/84380902-5a75-4ae6-b499-4e8c08777792-6e2fc83c-b77b-4f89-869e-76fdbf746c81.jpeg",
"mask_type": "manual",
"prompt": "Place a wooden bench on the grass",
"prompt_content_moderation": true,
"negative_prompt": "No skyscrapers or ground vehicles",
"preserve_alpha": true,
"seed": 42,
"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);
}
})();
Provide the source image via URL or Base64. Use different formats to test input handling.
Define the generation area with a mask. Test different regions by altering mask shape.
Specify if the mask is manual or automatic. Use 'manual' for custom, 'automatic' for algorithm-generated.
Allowed values:
Enter a prompt to guide object generation. Try creative or detailed prompts for varied outputs.
Moderate the prompt for safety. Enable for sensitive environments.
Exclude elements from generation using this field. Use for undesired features or details.
Decide if the alpha channel is retained. Keep true for transparency needs.
Select a seed for reproducibility. Use fixed seed for consistent results.
Enable to check input images for inappropriate content. Useful for platform compliance.
Check output images for content issues. Activate for moderated environments.
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 is a next-generation generative image editing model in the Image Editing API v2 designed for developers, creators, and product managers. At its core, Bria AI offers Generative Fill capabilities—allowing you to inject new content into masked areas with pixel-precise accuracy. Beyond fill operations, the suite supports background removal, advanced segmentation, foreground erasure with automatic background reconstruction, AI-driven canvas expansion, background blurs, detail sharpening, and high-quality upscaling. Built for asynchronous API workflows, Bria AI preserves original resolution and transparency while integrating robust visual and prompt content moderation.
Properly structured inputs lead to pixel-perfect edits, consistent style, and high-resolution final images.
Q: Which image formats are supported?
A: Supply the source image via URL or Base64. PNG with alpha, JPEG, and WebP are all compatible.
Q: How do I define and switch mask types?
A: Pass mask_type
as "manual"
for your custom mask or "automatic"
to leverage Bria AI’s built-in segmentation.
Q: Can I preserve transparency in the output?
A: Yes. Set preserve_alpha: true
to retain the alpha channel for overlays and icons.
Q: How do I ensure consistent generative fill results?
A: Provide the same integer seed
value. Changing or omitting it yields varied outputs.
Q: Is moderation available for inputs and outputs?
A: Enable visual_input_content_moderation
or visual_output_content_moderation
to filter inappropriate content automatically.