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
const axios = require('axios');
const api_key = "YOUR API-KEY";
const url = "https://api.segmind.com/v1/bria-replace-background";
const data = {
"image": "https://segmind-resources.s3.amazonaws.com/input/1df4100f-65bc-4d83-8ecf-54c8a8e6e3bf-e0bc66b8-77a1-49ab-a5b2-12c19aae6918.jpeg",
"enhance_ref_images": true,
"prompt": "In a parking lot",
"refine_prompt": true,
"prompt_content_moderation": true,
"negative_prompt": "no cars",
"original_quality": false,
"force_background_detection": false,
"fast": false,
"visual_input_content_moderation": false,
"visual_output_content_moderation": false,
"seed": 1234
};
(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);
}
})();
The primary image for processing; Keep quality high for best output. For example, use URLs like 'https://yourimage.com/main.jpg'.
Reference images for guidance; Use similar style images such as 'https://examples.com/ref1.jpg', 'https://examples.com/ref2.jpg'.
Improves reference image quality; Set true for enhanced images, false for original.
Defines desired scene; use clear, simple language like 'sunny beach with palm trees'.
Refines complex descriptions; true for detailed prompts, false for straightforward.
Ensures prompt safety; always true for moderated content.
Excludes unwanted elements; specify like 'no cars'.
Retains original resolution; true for high-res, false for faster results.
Detects background with transparency; true improves control.
Speeds up processing; use true for quick outputs.
Checks input for safety; enable during public demos.
Ensures output safety; turn on when unsure of results.
Sets result reproducibility; use specific numbers like '1234'.
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 Image Editing API v2 is an advanced generative image editing solution designed for developers, creators, and product managers. It offers a full suite of background operations—removal, replacement, and blurring—and precise content editing tools like erasing and generative fill within masked regions. By preserving original image quality and supporting asynchronous processing with request tracking, Bria AI streamlines complex workflows and accelerates your integration of AI-driven visual enhancements.
force_background_detection
).prompt
) or reference images (ref_images
) for custom backgrounds.original_quality
toggle.prompt_content_moderation
, visual_input_content_moderation
, and visual_output_content_moderation
for safety.fast
, then switch off for full-quality renders.seed
parameter.ref_images
for style consistency.negative_prompt
(e.g., “no cars”) to exclude elements.refine_prompt
for intricate or multi-object scenes.original_quality
when resolution matters most.fast
mode for quick iterations, then disable for final renders.seed
to reproduce outputs across calls.Q: How do I integrate Bria AI Image Editing API v2?
A: Call our RESTful endpoints with your API key, provide the image URL, set parameters, and poll the job endpoint to fetch results.
Q: What is asynchronous processing?
A: After submitting your request, you receive a job ID. Poll the status endpoint until it’s complete, then download the edited image.
Q: How do I preserve original resolution?
A: Include "original_quality": true
in your JSON payload to maintain the input image’s native resolution.
Q: How does content moderation work?
A: Turn on prompt_content_moderation
and visual moderation flags to automatically filter unsafe or inappropriate content.
Q: Can I generate entirely new backgrounds?
A: Yes—use the Generate Background model with text prompts or reference images to create bespoke scenes tailored to your needs.