API Documentation

BgCut AI API

HTTP API for background removal · https://api.rembg.click/v1.0

Remove Background automatically with 1 API call

Explore our API documentation and examples to integrate BgCut AI into your application or workflow.

Not a developer? There are plenty of ready-to-use tools and bulk processing on this site.

Was this section helpful?

Easy to integrate

Our API is a simple HTTP interface with various options:

Source images:

Direct uploads or URL reference

Result images:

Image file or JSON-encoded data

Output resolution:

up to 50 megapixels

Requires images that have a foreground (e.g. people, products, animals, cars, etc.)

Was this section helpful?

Get started

  1. Get your API Key. Your first 50 API calls per month are on us (see Pricing).
  2. Use the following code samples to get started quickly
  3. Review the to adjust any parameters
Was this section helpful?

Sample Code

bash
$ curl -H 'X-Api-Key: INSERT_YOUR_API_KEY_HERE' \
       -F 'image_file=@/path/to/file.jpg' \
       -F 'size=auto' \
       -f https://api.rembg.click/v1.0/removebg -o no-bg.png
Was this section helpful?

Output formats

You can request one of four formats via the format parameter:

FormatResolutionPros and cons
PNGUp to 10 Megapixels e.g. 4000×2500+ Simple integration + Supports transparency − Large file size
JPGUp to 50 Megapixels e.g. 8000×6250+ Simple integration + Smallest file size − No transparency
WebPUp to 50 Megapixels e.g. 8000×6250+ Simple integration + Supports transparency − Not universally supported
ZIPUp to 50 Megapixels e.g. 8000×6250+ Fastest + Small file size + Supports transparency − Requires composition

PNG images above 10 megapixels are not supported. For transparency at that size, use WebP or ZIP. For fastest processing we recommend ZIP. If you do not need transparency, use JPG.

Was this section helpful?

How to use the ZIP format

The ZIP format has the best runtime performance for transparent images — up to 80% smaller and up to 40% faster than PNG.

The ZIP file contains:

  • color.jpgRGB color image (edge-corrected)
  • alpha.pnggrayscale alpha matte (white = foreground)

To compose the final image: extract files, apply alpha to color, save as PNG.

bash
$ unzip no-bg.zip                      && \
  convert color.jpg alpha.png             \
    -compose CopyOpacity                  \
    -composite no-bg.png
Was this section helpful?

Authentication

All API requests require your API key in the X-Api-Key request header.

Create and manage keys in your dashboard. Keep your key secret — anyone with it can use your credits.

bash
curl -H 'X-Api-Key: INSERT_YOUR_API_KEY_HERE' \
     -F 'image_file=@/path/to/file.jpg' \
     -F 'size=auto' \
     -f https://api.rembg.click/v1.0/removebg -o no-bg.png
Was this section helpful?

API Reference

Servers

https://api.rembg.click/v1.0

Background Removal

POST/removebg

Remove the background of a JPG/PNG/WebP image.

  • File size: up to 22 MB
  • Input resolution: up to 50 megapixels
  • Image source: File upload (binary or as base64 encoded string) or download from URL
  • Image content: Any photo with a foreground (e.g. people, products, animals, cars, etc.)
  • Output resolutions available: Preview (up to 0.25 megapixels), Full (up to 25 megapixels), 50MP (up to 50 megapixels)
  • Requires an API Key in the X-Api-Key request header

Request body — multipart/form-data

image_filestring($binary)

Source image file (binary). If this parameter is present, the other image source parameters must be empty.

image_file_b64string

Source image file (base64-encoded string). If this parameter is present, the other image source parameters must be empty.

image_urlstring

Source image URL. If this parameter is present, the other image source parameters must be empty.

sizestring

Maximum output image resolution: "preview" (default) = Resize image to 0.25 megapixels (e.g., 625×400 pixels) – 0.25 credits per image "full" = Use original image resolution, up to 25 megapixels (e.g., 6250×4000) with formats ZIP / JPG / WebP, or up to 10 megapixels (e.g., 4000×2500) with PNG – 1 credit per image "50MP" = Use original image resolution, up to 50 megapixels (e.g., 8000×6250) with formats ZIP / JPG / WebP, or up to 10 megapixels (e.g., 4000×2500) with PNG – 1 credit per image "auto" = Use highest available resolution, up to 25 megapixels (e.g. 6250×4000) based on image size and available credits For backwards-compatibility this parameter also accepts "medium" (up to 1.5 megapixels) and "hd" (up to 4 megapixels) for 1 credit per image. The value "full" is also available under the name "4k" and the value "preview" is aliased as "small" and "regular".

typestring

Detect or set a foreground type. We recommend using type = auto to automatically detect the type of foreground. To specify only one type of foreground, set type to one of these values: car, product, person, animal, graphic, transportation.

type_levelstring

Classification level of the detected foreground type: "none" = No classification (X-Type header won't be set on the response) "1" = Use coarse classification classes: [person, product, animal, car, other] "2" = Use more specific classification classes: [person, product, animal, car, car_interior, car_part, transportation, graphics, other] "latest" = Always use the latest classification classes available

formatstring

Result image format: "auto" = Use PNG format if transparent regions exist, otherwise use JPG format (default) "png" = PNG format with alpha transparency "webp" = WebP format with alpha transparency "jpg" = JPG format, no transparency "zip" = ZIP format, contains color image and alpha matte image, supports transparency (recommended for fastest processing)

roistring

Region of interest: Only contents of this rectangular region can be detected as foreground. Everything outside is considered background and will be removed. The rectangle is defined as two x/y coordinates in the format "x1 y1 x2 y2". The coordinates can be in absolute pixels (suffix 'px') or relative to the width/height of the image (suffix '%'). By default, the whole image is the region of interest ("0% 0% 100% 100%").

cropboolean

Whether to crop off all empty regions (default: false). Note: Cropping has no effect on the amount of charged credits.

crop_marginstring

Adds a margin around the cropped subject (default: 0). Can be an absolute value (e.g. "30px") or relative to the subject size (e.g. "10%"). Can be a single value (all sides), two values (top/bottom and left/right) or four values (top, right, bottom, left). This parameter only has an effect when "crop=true". The maximum margin that can be added on each side is 50% of the subject dimensions or 500 pixels.

scalestring

Scales the subject relative to the total image size. Can be any value from "10%" to "100%", or "original" (default). Scaling the subject implies "position=center" (unless specified otherwise).

positionstring

Positions the subject within the image canvas. Can be "original" (default unless "scale" is given), "center" (default when "scale" is given) or a value from "0%" to "100%" (both horizontal and vertical) or two values (horizontal, vertical).

channelsstring

Request either the finalized image ("rgba", default) or an alpha mask ("alpha"). Note: Since BgCut AI also applies RGB color corrections on edges, using only the alpha mask often leads to a lower final image quality. Therefore "rgba" is recommended.

add_shadowboolean

Warning: add_shadow is deprecated and will be removed in the next major release, version 2.0. Please use shadow_type instead. Setting add_shadow = true will set shadow_type [car] = car. A car shadow will only be generated if the foreground type is detected or specified as car.

shadow_typestring

Generate shadows based on your foreground type. BgCut AI supports four different shadow types: car, 3D, drop, none. Use shadow_type = auto to automatically assign the most suitable shadow_type for each foreground type. Default assignments: shadow_type [car] = car shadow_type [product] = drop shadow_type [person] = 3D shadow_type [animal] = drop shadow_type [transportation] = 3D shadow_type [graphic] = drop shadow_type [other] = drop

shadow_opacitystring

Set a shadow's opacity, i.e. darkness. Can be set to any value from 0 (lightest) to 100 (darkest) or auto for default values. Default values: shadow_opacity [car] = 90 shadow_opacity [product] = 50 shadow_opacity [person] = 50 shadow_opacity [animal] = 50 shadow_opacity [transportation] = 50 shadow_opacity [graphic] = 50 shadow_opacity [other] = 50

semitransparencyboolean

Whether to have semi-transparent regions in the result (default: true). Note: Semitransparency is currently only supported for car windows. Other objects are returned without semitransparency, even if set to true.

bg_colorstring

Adds a solid color background. Can be a hex color code (e.g. 81d4fa, fff) or a color name (e.g. green). For semi-transparency, 4-/8-digit hex codes are also supported (e.g. 81d4fa77). If this parameter is present, the other bg_ parameters must be empty.

bg_image_urlstring

Adds a background image from a URL. The image is centered and resized to fill the canvas while preserving the aspect ratio, unless it already has the exact same dimensions as the foreground image. If this parameter is present, the other bg_ parameters must be empty.

bg_image_filestring($binary)

Adds a background image from a file (binary). The image is centered and resized to fill the canvas while preserving the aspect ratio, unless it already has the exact same dimensions as the foreground image. If this parameter is present, the other bg_ parameters must be empty.

Response headers (200)

NameDescription
X-TypeDetected foreground type (how specific this classification is depends on the type_level parameter sent in the request)
X-WidthWidth of the result image
X-HeightHeight of the result image
X-Credits-ChargedAmount of credits charged for this call
X-Foreground-TopTop position of the foreground image along the vertical axis
X-Foreground-LeftLeft position of the foreground image along the horizontal axis
X-Foreground-WidthWidth of the foreground image
X-Foreground-HeightHeight of the foreground image

Error responses

400Invalid parameters or input file unprocessable (no credits charged)

json
{
  "errors": [
    {
      "code": "multiple_sources",
      "title": "Multiple image sources given: Please provide either the image_url, image_file or image_file_b64 parameter."
    }
  ]
}

402Insufficient credits (no credits charged)

json
{
  "errors": [
    { "title": "Insufficient credits" }
  ]
}

403Authentication failed (no credits charged)

json
{
  "errors": [
    { "title": "Missing API Key" }
  ]
}

429Rate limit exceeded (no credits charged)

json
{
  "errors": [
    { "title": "Rate limit exceeded" }
  ]
}

Improvement Program

POST/improve

Submit an image to the BgCut AI Improvement program

  • Contribute an image that BgCut AI could not remove the background from properly
  • Help us make BgCut AI better
  • Get better results for similar images in the future

Notes:

  • By submitting images through the API you agree to the Improvement Program Conditions
  • File size: up to 22 MB
  • Input resolution: up to 50 megapixels
  • Up to 100 files per day
  • Requires an API Key in the X-Api-Key request header

Please note that submissions are used on a best-effort basis and improvements usually take several weeks to become effective.

Request body — multipart/form-data

image_filestring($binary)

Source image file (binary). If this parameter is present, the other image source parameters must be empty.

image_file_b64string

Source image file (base64-encoded string). If this parameter is present, the other image source parameters must be empty.

image_urlstring

Source image URL. If this parameter is present, the other image source parameters must be empty.

image_filenamestring

Filename of the image, if not provided it will be autodetected from the submitted data.

tagstring

Images with the same tag are grouped together.

Response (200)

json
{
  "id": "fe09820b-be79-4511-8836-679583529882"
}
GET/account

Fetch account info

Get the current credit balance and number of free API calls. Balance changes may be delayed by several seconds — use the X-Credits-Charged header from each image response to track usage locally.

bash
curl -H 'X-Api-Key: INSERT_YOUR_API_KEY_HERE' https://api.rembg.click/v1.0/account
json
{
  "data": {
    "attributes": {
      "credits": {
        "total": 200,
        "subscription": 150,
        "payg": 50,
        "enterprise": 0
      },
      "api": {
        "free_calls": 50,
        "sizes": "all"
      }
    }
  }
}
Was this section helpful?

Rate Limit

You can process up to 500 images per minute through the API, depending on input resolution in megapixels.

Input imageMegapixelsEffective rate limit
625 × 4001 MP500 images per minute
1200 × 8001 MP500 images per minute
1600 × 12002 MP250 images per minute
2500 × 16004 MP125 images per minute
4000 × 250010 MP50 images per minute
6250 × 400025 MP20 images per minute
8000 × 625050 MP10 images per minute

Exceeding limits returns HTTP 429 (no credits charged). Use these response headers:

HeaderSampleDescription
X-RateLimit-Limit500Total rate limit in megapixel images
X-RateLimit-Remaining499Remaining rate limit for this minute
X-RateLimit-Reset1781552509Unix timestamp when rate limit resets
Retry-After59Seconds until reset (only when limit exceeded)

Sample: handling Retry-After

bash
#!/bin/bash

make_request_with_retry() {
    while true; do
        response=$(get_result)
        status_code=$(echo "$response" | grep HTTP | awk '{print $2}')

        if [ "$status_code" -eq 200 ]; then
            echo "$response" | grep -v HTTP
            return
        elif [ "$status_code" -eq 429 ]; then
            retry_after=$(echo "$response" | grep -i "Retry-After" | awk '{print $2}')
            if [ -n "$retry_after" ]; then
                echo "Rate limit reached. Retrying after $retry_after seconds..."
                sleep "$retry_after"
            else
                sleep 10
            fi
        else
            echo "Request failed with status code $status_code"
            exit 1
        fi
    done
}
Was this section helpful?

Exponential backoff

Exponential backoff gradually increases wait time between retries. Use it for 5XX responses (e.g. 503). For 429 responses, prefer the Retry-After header instead.

bash
#!/bin/bash

MAX_RETRIES=5

call_api_with_exponential_backoff() {
  local retry=true
  local retries=0

  while $retry && [ $retries -lt $MAX_RETRIES ]; do
    local wait_time=$(echo "2^$retries + $RANDOM/32768" | bc -l)
    sleep $wait_time

    local result=$(get_result)

    if [ "$result" == "SUCCESS" ]; then
      retry=false
    elif [ "$result" == "ERROR" ] || [ "$result" == "THROTTLED" ]; then
      retry=true
    fi

    retries=$((retries + 1))
  done
}
Was this section helpful?