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.
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.)
Get started
- Get your API Key. Your first 50 API calls per month are on us (see Pricing).
- Use the following code samples to get started quickly
- Review the to adjust any parameters
Sample Code
$ 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.pngOutput formats
You can request one of four formats via the format parameter:
| Format | Resolution | Pros and cons |
|---|---|---|
| PNG | Up to 10 Megapixels e.g. 4000×2500 | + Simple integration + Supports transparency − Large file size |
| JPG | Up to 50 Megapixels e.g. 8000×6250 | + Simple integration + Smallest file size − No transparency |
| WebP | Up to 50 Megapixels e.g. 8000×6250 | + Simple integration + Supports transparency − Not universally supported |
| ZIP | Up 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.
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.jpg — RGB color image (edge-corrected)
- alpha.png — grayscale alpha matte (white = foreground)
To compose the final image: extract files, apply alpha to color, save as PNG.
$ unzip no-bg.zip && \
convert color.jpg alpha.png \
-compose CopyOpacity \
-composite no-bg.pngAuthentication
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.
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.pngAPI Reference
Servers
https://api.rembg.click/v1.0Background Removal
/removebgRemove 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-Keyrequest 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_b64stringSource image file (base64-encoded string). If this parameter is present, the other image source parameters must be empty.
image_urlstringSource image URL. If this parameter is present, the other image source parameters must be empty.
sizestringMaximum 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".
typestringDetect 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_levelstringClassification 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
formatstringResult 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)
roistringRegion 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%").
cropbooleanWhether to crop off all empty regions (default: false). Note: Cropping has no effect on the amount of charged credits.
crop_marginstringAdds 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.
scalestringScales 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).
positionstringPositions 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).
channelsstringRequest 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_shadowbooleanWarning: 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_typestringGenerate 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_opacitystringSet 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
semitransparencybooleanWhether 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_colorstringAdds 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_urlstringAdds 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)
| Name | Description |
|---|---|
| X-Type | Detected foreground type (how specific this classification is depends on the type_level parameter sent in the request) |
| X-Width | Width of the result image |
| X-Height | Height of the result image |
| X-Credits-Charged | Amount of credits charged for this call |
| X-Foreground-Top | Top position of the foreground image along the vertical axis |
| X-Foreground-Left | Left position of the foreground image along the horizontal axis |
| X-Foreground-Width | Width of the foreground image |
| X-Foreground-Height | Height of the foreground image |
Error responses
400 — Invalid parameters or input file unprocessable (no credits charged)
{
"errors": [
{
"code": "multiple_sources",
"title": "Multiple image sources given: Please provide either the image_url, image_file or image_file_b64 parameter."
}
]
}402 — Insufficient credits (no credits charged)
{
"errors": [
{ "title": "Insufficient credits" }
]
}403 — Authentication failed (no credits charged)
{
"errors": [
{ "title": "Missing API Key" }
]
}429 — Rate limit exceeded (no credits charged)
{
"errors": [
{ "title": "Rate limit exceeded" }
]
}Improvement Program
/improveSubmit 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-Keyrequest 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_b64stringSource image file (base64-encoded string). If this parameter is present, the other image source parameters must be empty.
image_urlstringSource image URL. If this parameter is present, the other image source parameters must be empty.
image_filenamestringFilename of the image, if not provided it will be autodetected from the submitted data.
tagstringImages with the same tag are grouped together.
Response (200)
{
"id": "fe09820b-be79-4511-8836-679583529882"
}/accountFetch 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.
curl -H 'X-Api-Key: INSERT_YOUR_API_KEY_HERE' https://api.rembg.click/v1.0/account{
"data": {
"attributes": {
"credits": {
"total": 200,
"subscription": 150,
"payg": 50,
"enterprise": 0
},
"api": {
"free_calls": 50,
"sizes": "all"
}
}
}
}Rate Limit
You can process up to 500 images per minute through the API, depending on input resolution in megapixels.
| Input image | Megapixels | Effective rate limit |
|---|---|---|
| 625 × 400 | 1 MP | 500 images per minute |
| 1200 × 800 | 1 MP | 500 images per minute |
| 1600 × 1200 | 2 MP | 250 images per minute |
| 2500 × 1600 | 4 MP | 125 images per minute |
| 4000 × 2500 | 10 MP | 50 images per minute |
| 6250 × 4000 | 25 MP | 20 images per minute |
| 8000 × 6250 | 50 MP | 10 images per minute |
Exceeding limits returns HTTP 429 (no credits charged). Use these response headers:
| Header | Sample | Description |
|---|---|---|
| X-RateLimit-Limit | 500 | Total rate limit in megapixel images |
| X-RateLimit-Remaining | 499 | Remaining rate limit for this minute |
| X-RateLimit-Reset | 1781552509 | Unix timestamp when rate limit resets |
| Retry-After | 59 | Seconds until reset (only when limit exceeded) |
Sample: handling Retry-After
#!/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
}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.
#!/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
}