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
const axios = require('axios');
const api_key = "YOUR API-KEY";
const url = "https://api.segmind.com/v1/bria-expand-image";
const data = {
"image": "https://segmind-resources.s3.amazonaws.com/input/3f05def3-776b-4944-a0f6-c23cec41a09e-cbf61f2b859662c0.jpg",
"aspect_ratio": "4:3",
"prompt_content_moderation": true,
"seed": 12345,
"negative_prompt": "Do not include buildings or modern architecture",
"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);
}
})();
Input image for processing. Use an accessible URL or Base64 string.
Defines image aspect ratio. For landscapes use 16:9, for portraits use 2:3.
Allowed values:
Text guidance for image expansion. Use keywords like 'sunset' or 'ocean'.
Scans prompt for NSFW content. Keep enabled for safe usage.
Sets randomization seed for reproducibility. Use any integer for consistency.
Excludes elements in generating image. Use 'cityscapes' to avoid urban features.
Keeps transparency in images. Use with PNGs to maintain transparency.
Moderates input visuals for NSFW content. Enable for safer uploads.
Moderates output visuals for NSFW content. Use to ensure clean results.
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 Image Editing API v2 is a suite of generative AI–powered image manipulation models designed for developers, creators, and product managers. Whether you need selective object removal, background transformation, canvas expansion, or high-fidelity upscaling, Bria delivers pixel-accurate edits while preserving original fidelity and alpha transparency. It integrates seamlessly via REST endpoints, accepts common image URIs or Base64 inputs, and supports advanced parameters—from aspect_ratio to negative_prompt—to fine-tune results. The model is exclusively trained on licensed data, ensuring safe and risk-free commercial use.
Q: How do I remove an object from my photo?
A: Use the Eraser model with a binary mask. Supply your image URI and mask via the image
and mask
parameters. The API returns a clean composite without the object.
Q: Can I change my photo’s background to a custom scene?
A: Yes. Use Replace Background and include a text prompt describing your desired scene. For solid colors, set the prompt to the color name (e.g., “solid light gray”).
Q: What input formats are supported?
A: Bria accepts public image URLs or Base64-encoded strings. Transparent PNGs keep their alpha channel when preserve_alpha
is true.
Q: How do I expand my image canvas and fill it?
A: Call Expand Image with canvas_size
larger than the original, and include a descriptive prompt
(e.g., “sunset over rolling hills”) for context-aware generation.
Q: How do I ensure consistent outputs?
A: Provide a fixed integer seed
value. Identical seeds with the same parameters yield reproducible edits.