POST
javascript
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); } })();
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 *

Input image for processing. Use an accessible URL or Base64 string.


aspect_ratioenum:str ( default: 4:3 )

Defines image aspect ratio. For landscapes use 16:9, for portraits use 2:3.

Allowed values:


promptstr ( default: 1 )

Text guidance for image expansion. Use keywords like 'sunset' or 'ocean'.


prompt_content_moderationboolean ( default: true )

Scans prompt for NSFW content. Keep enabled for safe usage.


seedint ( default: 12345 )

Sets randomization seed for reproducibility. Use any integer for consistency.


negative_promptstr ( default: Do not include buildings or modern architecture )

Excludes elements in generating image. Use 'cityscapes' to avoid urban features.


preserve_alphaboolean ( default: true )

Keeps transparency in images. Use with PNGs to maintain transparency.


visual_input_content_moderationboolean ( default: 1 )

Moderates input visuals for NSFW content. Enable for safer uploads.


visual_output_content_moderationboolean ( default: 1 )

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 – Generative Image Editing Model

What is Bria Image Editing API v2?

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.

Key Features

  • Eraser: Remove unwanted objects or blemishes using precise mask inputs.
  • Generative Fill: Add new elements guided by text prompts within masked regions.
  • Remove Background (RMBG 2.0): Automatically isolate and eliminate backgrounds with refined edge detection.
  • Replace Background: Swap backgrounds for solid colors or AI-generated scenes by supplying a prompt.
  • Expand Image: Extend canvas size in any direction, using contextual prompts to fill new areas.
  • Enhance Image: Sharpen details, reduce artifacts, and boost clarity without altering composition.
  • Increase Resolution: Upscale images while preserving texture and avoiding regeneration artifacts.
  • Transparent Alpha Support: Maintain PNG transparency throughout editing pipelines.

Best Use Cases

  • E-commerce & Product Photos: Cleanly remove backgrounds, enhance detail, and upsample for high-resolution catalogs.
  • Marketing & Advertising: Quickly create fresh backgrounds or composite elements for banners and social posts.
  • Digital Art & Design: Sketch expansions and generative fills accelerate concept iterations.
  • Social Media Content: Auto-remove distracting elements and retouch portraits on the fly.
  • UI/UX Prototypes: Generate seamless assets with transparent alpha for mockups.

Prompt Tips and Output Quality

  • Use prompt and negative_prompt fields to steer generative fill and background replacement.
  • Specify aspect_ratio, canvas_size, original_image_size, and original_image_location for precise layout control.
  • Set a seed for reproducible results across runs.
  • Enable preserve_alpha to keep transparent regions intact (ideal for PNGs).
  • Tweak prompt_content_moderation to automatically filter NSFW terms.
  • For artifact-free upscaling, rely on the Increase Resolution model rather than re-rendering.

FAQs

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.