BgCut AI API
HTTP API for background removal, background replacement and upscaling · 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.
Change Background with 1 API call
Remove the background and replace it with a solid color, linear gradient, or your own background image — same credit pricing as /removebg.
Try the interactive Change Background tool on this site, or call POST /changebg from your app.
Upscale images with 1 API call
Increase resolution up to 4× with the same size tiers and credit costs as background removal (preview = 0.25 credits, full / 50MP = 1 credit).
Try the Image Upscaler on this site, or call POST /upscale from your app.
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.pngData retention
Standard endpoints (/removebg, /changebg, /upscale) process images in memory only. Uploaded files are not written to disk and are not retained after the HTTP response is sent.
Improvement Program submissions (POST /improve) temporarily store the original image on our servers for manual review. Files are automatically deleted within 1 hour.
Usage metadata (credits charged, endpoint, megapixels) is stored for billing and account history. See our Privacy Policy for details.
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.
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.
modelstringOptional rembg model name (e.g. birefnet-general-lite, u2net, bria-rmbg). When omitted, the server picks a model from type (auto uses REMBG_AUTO_MODEL from server config).
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.
bg_gradient_fromstringStart color of a linear gradient background (hex or color name). Requires bg_gradient_to. Mutually exclusive with bg_color and bg_image_*.
bg_gradient_tostringEnd color of a linear gradient background (hex or color name). Requires bg_gradient_from.
bg_gradient_anglestringGradient direction in degrees (0–360). Default is 135. Used with bg_gradient_from and bg_gradient_to.
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-Effective-Size | Resolved output size tier after billing (e.g. auto → preview or full) |
| X-Process-Time-Ms | Server-side processing time in milliseconds (removebg and changebg) |
| 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 |
| X-RateLimit-Limit | Total rate limit in megapixel images per minute |
| X-RateLimit-Remaining | Remaining rate limit for the current minute |
| X-RateLimit-Reset | Unix timestamp when the rate limit resets |
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" }
]
}Change Background
/changebgRemove the background and replace it with a solid color (bg_color), linear gradient (bg_gradient_from / bg_gradient_to / bg_gradient_angle), or background image (bg_image_url / bg_image_file). Exactly one background option is required.
- Same credit pricing as /removebg (preview = 0.25 credits, full / 50MP = 1 credit)
- File size: up to 22 MB
- Input resolution: up to 50 megapixels
- Background: one of bg_color, bg_image_url/bg_image_file, or bg_gradient_from + bg_gradient_to
- Default output is JPG when a background is applied
- 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.
sizestringOutput resolution — same pricing as /removebg: "preview" (default) = up to 0.25 megapixels — 0.25 credits "full" = up to 25 megapixels — 1 credit "50MP" = up to 50 megapixels — 1 credit "auto" = highest available resolution based on credits
typestringForeground type hint: auto (default), person, product, animal, car, etc.
modelstringOptional rembg model name. When omitted, the server picks a model from type.
formatstringResult format: auto (default, usually JPG when a background is applied), png, jpg, or webp.
bg_colorstringSolid background color (hex or name, e.g. ffffff or white). Exactly one background option is required.
bg_image_urlstringBackground image URL. Centered and cover-cropped to match the foreground size.
bg_image_filestring($binary)Background image file (binary). Centered and cover-cropped to match the foreground size.
bg_gradient_fromstringGradient start color (hex or name). Must be used together with bg_gradient_to.
bg_gradient_tostringGradient end color (hex or name). Must be used together with bg_gradient_from.
bg_gradient_anglestringGradient direction in degrees (0–360). Default is 135.
Examples
$ curl -H 'X-Api-Key: INSERT_YOUR_API_KEY_HERE' \
-F 'image_file=@/path/to/file.jpg' \
-F 'size=preview' \
-F 'bg_color=ffffff' \
-f https://api.rembg.click/v1.0/changebg -o new-bg.jpg$ curl -H 'X-Api-Key: INSERT_YOUR_API_KEY_HERE' \
-F 'image_file=@/path/to/file.jpg' \
-F 'size=preview' \
-F 'bg_gradient_from=0066FF' \
-F 'bg_gradient_to=00E5FF' \
-F 'bg_gradient_angle=135' \
-f https://api.rembg.click/v1.0/changebg -o new-bg.jpg$ curl -H 'X-Api-Key: INSERT_YOUR_API_KEY_HERE' \
-F 'image_file=@/path/to/file.jpg' \
-F 'size=preview' \
-F 'bg_image_url=https://example.com/background.jpg' \
-f https://api.rembg.click/v1.0/changebg -o new-bg.jpgResponse 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-Effective-Size | Resolved output size tier after billing (e.g. auto → preview or full) |
| X-Process-Time-Ms | Server-side processing time in milliseconds (removebg and changebg) |
| 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 |
| X-RateLimit-Limit | Total rate limit in megapixel images per minute |
| X-RateLimit-Remaining | Remaining rate limit for the current minute |
| X-RateLimit-Reset | Unix timestamp when the rate limit resets |
Image Upscaling
/upscaleUpscale and sharpen a JPG/PNG/WebP image up to 2× with the same credit pricing as background removal.
- File size: up to 22 MB
- Input resolution: up to 50 megapixels
- Scale: 1× to 4× (default 2×)
- Output resolution follows the same size tiers as /removebg (preview, full, 50MP)
- 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 resolution — same pricing as /removebg: "preview" (default) = up to HD output — 0.25 credits per image "full" = up to 25 megapixels — 1 credit per image "50MP" = up to 50 megapixels — 1 credit per image "auto" = highest available resolution based on credits
scalestringUpscale factor from 1 to 4. Default is 2 (doubles width and height). Output is capped by the size parameter.
formatstringResult format: auto (default), png, jpg, or webp.
curl -H 'X-Api-Key: INSERT_YOUR_API_KEY_HERE' \
-F 'image_file=@/path/to/file.jpg' \
-F 'size=preview' \
-F 'scale=2' \
-f https://api.rembg.click/v1.0/upscale -o upscaled.jpgResponse headers (200)
| Name | Description |
|---|---|
| X-Width | Width of the upscaled result image |
| X-Height | Height of the upscaled result image |
| X-Credits-Charged | Amount of credits charged for this call |
| X-Input-Megapixels | Megapixels of the input image |
| X-RateLimit-Limit | Total rate limit in megapixel images per minute |
| X-RateLimit-Remaining | Remaining rate limit for the current minute |
| X-RateLimit-Reset | Unix timestamp when the rate limit resets |
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
- Stored images are automatically deleted within 1 hour
- 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
}