1const axios = require('axios');
3const fs = require('fs');
4const path = require('path');
6async function toB64(imgPath) {
7    const data = fs.readFileSync(path.resolve(imgPath));
8    return Buffer.from(data).toString('base64');
11const api_key = "YOUR API-KEY";
12const url = "";
14const data = {
15  "image": "toB64('/bg-removal.jpg')",
16  "method": "object"
19(async function() {
20    try {
21        const response = await, data, { headers: { 'x-api-key': api_key } });
22        console.log(;
23    } catch (error) {
24        console.error('Error:',;
25    }
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


imageimage *

Input Image

methodenum:string ( default: object )


Allowed values:

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.

Background Removal

Background removal is a cutting edge model that is designed to instantly remove the background of an image or an object in an image using generative AI. Using Segmind’s free background removal model, you can automatically detect the subject from any image and remove background instantly without any hassle. Harnessing the power of our artificial intelligence tool, it's easy to handle hair, animal fur, or complex edges in just a few seconds.

AI-based background removal, often used in image and video editing software, relies on deep learning models, particularly convolutional neural networks (CNNs), to separate the foreground (the subject) from the background in an image or video.

To use Segmind's background removal model, simply upload an image and click generate, the model will automatically remove the background in seconds. You can then download the image with a transparent background or replace the background with another image or colour.

AI-based background removal is a powerful and versatile technology that is rapidly becoming an essential tool for image and video editors. With Segmind's background removal model, you can easily create high-quality images and videos with professional-looking results.

Background Removal Use Cases

  1. Product photography: Segmind’s background removal tool can be used to create product photos with a white background. This makes the products look more professional and visually appealing.

  2. Portrait editing: The background removal tool can be used to edit portraits by blurring the background or removing it altogether. This can help to make the subject of the portrait stand out more.

  3. Social media graphics: Background removal tool can be used to create social media graphics with interesting and unique backgrounds. This can help to grab attention and make your posts more engaging.

Background Removal License

The Background Removal model is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License. This license allows for the free use, modification, and distribution of the software for non-commercial purposes only, provided that the original copyright notice and disclaimer are included in all copies or substantial portions of the software. However, it does not permit the sharing of adapted material.

The license also does not permit the use of the name of the license holder or the names of its contributors to endorse or promote products derived from this software without specific prior written permission. Furthermore, the license is irrevocable, meaning once granted, it cannot be taken back.