API v2 (Beta)

Scalable and the fastest way to remove backgrounds automatically.

$ curl -H 'Authorization: YOUR_API_KEY'
       -F '[email protected]/your/image/file.jpg'
       -f https://api.backgroundcut.co/v2/cut/
       -o output.png

Sample Code

Remove background from image file

$ curl -H 'Authorization: YOUR_API_KEY' \
        -F '[email protected]/your/image/file.jpg' \
        -F 'quality=medium' \
        -f https://api.backgroundcut.co/v2/cut/ \
        -o output.png

import requests

response = requests.post(
    files={'image_file': open('/path/to/file.jpg', 'rb')},
    data={'quality': 'medium'},
    headers={'Authorization': 'YOUR_API_KEY'},

if response.status_code == requests.codes.ok:
    with open('output.png', 'wb') as out:
    print("Error:", response.status_code, response.text)

// Requires "guzzle" to be installed (see guzzlephp.org)
// If you have problems with our SSL certificate with error 'Uncaught GuzzleHttp\Exception\RequestException: cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)'
// follow these steps to use the latest cacert certificate for cURL: https://github.com/guzzle/guzzle/issues/1935#issuecomment-371756738

$client = new GuzzleHttp\Client();
$res = $client->post('https://api.backgroundcut.co/v2/cut/', [
    'multipart' => [
            'name'     => 'image_file',
            'contents' => fopen('/path/to/file.jpg', 'r')
            'name'     => 'quality',
            'contents' => 'medium'
    'headers' => [
        'Authorization' => 'YOUR_API_KEY'

$fp = fopen("output.png", "wb");
fwrite($fp, $res->getBody());


// Requires "axios" and "form-data" to be installed (see https://www.npmjs.com/package/axios and https://www.npmjs.com/package/form-data)
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
const path = require('path');

const inputPath = '/path/to/file.jpg';
const formData = new FormData();
formData.append('quality', 'medium');
formData.append('image_file', fs.createReadStream(inputPath), path.basename(inputPath));

    method: 'post',
    url: 'https://api.backgroundcut.co/v2/cut/',
    data: formData,
    responseType: 'arraybuffer',
    headers: {
    'Authorization': 'YOUR_API_KEY',
    encoding: null
.then((response) => {
    if(response.status != 200) return console.error('Error:', response.status, response.statusText);
    fs.writeFileSync("output.png", response.data);
.catch((error) => {
    return console.error('Request failed:', error);
$ curl -H 'Authorization: Token YOUR_API_KEY'  \
        -F 'file_url=https://www.example.com/example.jpg'  \
        -f https://backgroundcut.co/api/v1/cut/ 
import requests

URL = "https://backgroundcut.co/api/v1/cut/"

    'file_url': 'https://www.example.com/example.jpg',

headers = {'Authorization': 'Token YOUR_API_KEY'}
response = requests.post(URL, data=data, headers=headers)


// use Guzzle
// https://docs.guzzlephp.org/en/stable/

post("https://slazzer.com/api/v1/remove_image_background", [
'multipart' => [
    'name' => 'source_image_file',
    'contents' => fopen('SOURCE_IMAGE_FILE_PATH', 'r')
'headers' => [

$res_body = $res->getBody()->getContents();
echo $res_body;

const axios = require('axios');
const fs = require('fs');
const FormData = require('form-data');

const imagePath = 'YOUR_IMAGE_PATH'

const settings = {
"endpointPath": "https://slazzer.com/api/v1/remove_image_background",
"apiKey": "YOUR_API_KEY"

function endpointHeader(apiKey, formdata){
return {
headers: {
    'Content-Type':'multipart/form-data; boundary=' + formdata.getBoundary(),
    'API-KEY': apiKey

const formdata = new FormData;
formdata.append('source_image_file', fs.createReadStream(imagePath));

settings.endpointPath, formdata, endpointHeader(settings.apiKey, formdata)
.then(response => console.log(response.data))
.catch(errors => console.log(errors.response.data));

Output Formats

You can request one of three formats via the "return_type" parameter:

Output Type Resolution Pros and cons
PNG Up to 12 Megapixels
  • + Simple integration
  • + Supports transparency
  • - Large file size
ZIP Up to 12 Megapixels
  • + Small file size
  • + Supports transparency
  • - Integration requires compositing
WEBP Up to 12 Megapixels
  • + Simple integration
  • + Small file size
  • - Not as widely used format
JPG Up to 12 Megapixels

How to use quality parameter for WEBP format

WebP is a modern image format that provides superior lossless and lossy compression for images. Depending on the level of compression, it can range from 1 to 100. For example, to get lossless output, you can send a "return_type" parameter as WEBP_100, and to set some compression, you can send the "return_type" parameter as WEBP_50.

API Reference

  • API Endpointhttps://api.backgroundcut.co/v2/cut/
  • MethodPOST
  • Request Bodymultipart/form-data
  • Authorization (string)YOUR_API_KEY
  • image_fileSource image file (binary). Supports only PNG, JPG, WEBP
  • image_file_b64Source image file (base64-encoded string).
  • max_resolutionMaximum output resolution (specified in pixels). Upto 12000000, i.e 12MP. For eg, 4000000 outputs image of maximum resolution of 4MP.
  • quality'High', 'Medium'(default), 'Low'. 'High' quality takes the most time while 'Low' takes the least time to process.
  • return_type'PNG'(default), 'ZIP' or 'WEBP'.
  • channelsRequest either the finalized image ("rgba", default) or an alpha mask ("alpha"). Note: Since BackgroundCut also applies RGB color corrections on edges, using only the alpha mask often leads to a lower final image quality. Therefore "rgba" is recommended when quality parameter is set to 'High'.
  • Code : 200Successfully removed image background
  • Code: 400Error: Invalid parameters or unable to process input image file (No credit deducted)
  • Code: 401Error: API-KEY missing or invalid API-KEY or Denied API-KEY (no credits left)
  • Code: 405Error: Invalid request METHOD (Ensure the request is of type POST)
  • Code: 413Error: Request Entity Too Large. File size should not exceed 12MB when uploading.
  • Code: 429Error: API rate limit crossed (No credit deducted)
  • Code: 450Error: Invalid POST URL (Ensure the URL is https://api.backgroundcut.co/v2/cut/)
API Rate Limit
  • BackgroundCut implements rate limits dynamically. There is a default limit of 40 requests per minute for APIs. Depending on usage in the current minute, rate limits double the following minute up to a maximum of 500 requests per minute.
Data Storage Policy
  • Neither uploaded images nor generated output images are stored by BackgroundCut. The output is returned as soon as the response is generated and is never stored on our servers. It is the user's responsibility to save outputs in one go.