API Reference
Remove Background
Remove the background from an image
POST
The core endpoint for background removal. Send an image, get back a processed image with the background removed.
See Error Handling for detailed troubleshooting.
Request
The image file to process. Supports JPEG, PNG, and WebP formats. Maximum size: 20MB.
Output image format.
png— Lossless with transparency supportjpg— Smaller file size, no transparencywebp— Best compression with transparency
Output color channels.
rgba— Include alpha channel (transparency)rgb— Opaque output, usesbg_colorfor background (white by default)alpha— Grayscale alpha mask only: white foreground, black background
Background color when
channels is rgb or rgba. Accepts:- Hex:
#ffffff,#fff - RGB:
rgb(255, 255, 255) - Named:
white,black,red
Output image size preset.
full— Original resolutionpreview— up to 0.25 megapixelsmedium— up to 1.5 megapixelshd— up to 4 megapixels
Crop the output to the subject bounds, removing empty space around the subject.
Pass
true/false, or an aspect ratio like 1:1, 4:3, 16:9 to crop to that ratio around the subject.Padding around the subject when
crop is enabled, as a fraction (0.1) or percentage (10%).Response
The API returns the processed image directly in the response body. Check the response headers for metadata:| Header | Description |
|---|---|
Content-Type | MIME type of the image (image/png, image/jpeg, image/webp) |
X-Request-ID | Unique request ID for support inquiries |
X-Processing-Time-Ms | Processing time in milliseconds |
X-Image-Width | Output image width in pixels |
X-Image-Height | Output image height in pixels |
X-Matte-Confidence | Confidence in the alpha matte, 0–1. 1 means a fully decisive mask; lower values mean the model hedged. Heuristic, not a calibrated probability |
X-Matte-Ambiguous-Ratio | Fraction of pixels with alpha between 0.1 and 0.9, 0–1. High values indicate large uncertain regions — useful for flagging results for manual review |
Examples
Basic Usage
Remove background and save as PNG with transparency:White Background
Get a JPEG with a white background (great for e-commerce):Alpha Mask Only
Get just the grayscale alpha mask (white = foreground, black = background) — useful for custom compositing pipelines:Cropped Thumbnail
Get a small, cropped preview:WebP for Web
Optimal format for web delivery:Error Responses
| Status | Code | Description |
|---|---|---|
| 400 | validation_error | Invalid parameter value |
| 400 | missing_image | No image file provided |
| 400 | image_too_large | Image exceeds 20MB limit |
| 401 | authentication_error | Invalid or missing API key |
| 402 | payment_required | Insufficient credits |
| 429 | rate_limit_exceeded | Too many requests |
| 500 | internal_server_error | Server error, retry later |