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
Background color when
channels is rgb. Accepts:- Hex:
#ffffff,#fff - RGB:
rgb(255, 255, 255) - Named:
white,black,red
Output image size preset.
full— Original resolutionpreview— 256px max dimensionsmall— 512px max dimensionmedium— 1024px max dimensionlarge— 2048px max dimension
Crop the output to the subject bounds, removing empty space around the subject.
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 |
Examples
Basic Usage
Remove background and save as PNG with transparency:White Background
Get a JPEG with a white background (great for e-commerce):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 |