POST
javascript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 const axios = require('axios'); const api_key = "YOUR API-KEY"; const url = "https://api.segmind.com/v1/bria-eraser"; const data = { "image": "https://segmind-resources.s3.amazonaws.com/input/eb8b89ca-9506-4e67-8356-6214f5f6162e-4d423914-87ba-4e92-8f28-21538c9c6154.jpeg", "mask": "https://segmind-resources.s3.amazonaws.com/input/1c67466e-1ad5-42c9-afe4-cecb064dfa9e-4b0596ee-3575-4a58-a64e-37e4c9edf4b5.jpeg", "mask_type": "manual", "visual_input_content_moderation": true, "visual_output_content_moderation": true }; (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 the main image URL. Choose high-resolution for better results.


maskstr *

Defines areas to modify with a mask URL. Use adaptive for complex changes.


mask_typeenum:str ( default: manual )

Select mask origin as manual or automatic. Manual offers precise control.

Allowed values:


visual_input_content_moderationboolean ( default: true )

Ensures input suits appropriateness needs. Enable for compliance projects.


visual_output_content_moderationboolean ( default: true )

Ensures output meets standards. Activation recommended for sensitive uses.

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

## What is Bria Eraser – Image Editing API v2?

**Bria Eraser** is Bria Image Editing API v2, a generative AI toolkit that performs precise image modification. It is an optimum model for developers (who want object removal) or product managers (designing creative tools). It features specialized models such as "**Eraser**" for removing unwanted objects and **"Generative Fill"** to effortlessly replace or add content. The AI enables users to upscale, expand, or enhance the image while maintaining its pixel accuracy. It is ideal for commercial use since its outputs strictly comply with the content moderation policy for compliant results that are reliable and safe.


## Key Features
- **Object Removal (Eraser):** It is designed to precisely remove unwanted elements using manual or automatic masks.  
- **Generative Fill:** It fills in the covered or masked (hidden) regions based on text prompts to maintain original style and lighting.  
- **Background Removal & Replacement:** It can isolate subjects or replace backgrounds with empty, transparent, or custom scenes.  
- **Canvas Expansion:** It makes it possible to extend edges through AI-driven resizing; perfect for social media formats or responsive layouts.  
- **Image Enhancement:** It enhances sharpness, color fidelity, and detail with neural enhancement models.  
- **Upscaling:** It is effective in boosting quality by increasing resolution up to 4×, while preserving fine textures for print and high-DPI displays.  
- **Content Moderation:** It can implement input/output filter guards to prevent inappropriate visual content.

## Best Use Cases
- **E-commerce Catalogs:** Easily remove backgrounds, upscale product shots, and fill gaps in images.  
- **Social Media Automation:** Process multiple profile pictures or banners with background swaps and canvas resizing.  
- **Creative Tools & Apps:** It has embedded generative fill for user-driven collage and photo-editing experiences.  
- **Marketing Assets:** Enhance and expand hero images (main promotional images) across various advertising formats and sizes, without any loss in detail or resolution.  
- **Compliance-Sensitive Projects:** The built-in moderation automatically checks and ensures the content is safe and compliant for regulated industries (e.g., healthcare, finance).


## Prompt Tips and Output Quality
1. Provide a high-resolution source image URL (`image` parameter) for best results.  
2. Define precise mask URLs (`mask`) or use `mask_type=automatic` to detect edges.  
3. Use clear text prompts in **Generative Fill** to guide style, e.g., “add a blue sky with fluffy clouds.”  
4. Toggle `visual_input_content_moderation` and `visual_output_content_moderation` to enforce compliance.  
5. Review margin artifacts and run a second fill iteration if edge blending is required.

## FAQs
**Q: How do I remove objects from an image with Bria Eraser?**  
A: Supply your `image` URL and a `mask` URL highlighting the object. Set `mask_type=manual` for pixel-perfect control or `automatic` for quick removal.

**Q: Can I replace a background automatically?**  
A: Yes, you can remove the background; use the **Eraser model** to isolate the subject, then apply a new background via **Generative Fill** or image overlay.

**Q: What input image formats are supported?**  
A: Bria Eraser accepts common web formats, including JPEG, PNG, via URI. High-resolution PNGs yield the best editing fidelity.

**Q: How does content moderation work?**  
A: Enable `visual_input_content_moderation` and `visual_output_content_moderation` to filter inappropriate content at each processing stage.

**Q: What’s the max upscaling factor?**  
A: The upscaling model supports up to 4× enlargement; it is ideal for print or high-density displays.