remove.bg API alternative
Drop-in migration for POST /v1.0/removebg. Change the base URL and the key.
Migrating from remove.bg? See the migration guide.
Drop-in migration
remove.bg's self-serve API shuts down on December 1, 2026 and moves to Leonardo.Ai. Any unused PAYG credits will expire on 1 December 2026. ZeroBG keeps the same request path.
- Create a free ZeroBG account and an API key on the API keys page. Any account with credits can create a key — a Pro subscription is not required.
- Change the base URL from
https://api.remove.bgtohttps://zerobg.ai. Leave the path as/v1.0/removebg. - Send the ZeroBG key in the
X-Api-Keyheader (also accepted asX-API-Key). - Call the API from your server. Browser requests from another site are blocked (no CORS), so your key stays out of client code.
Buy credits on the pricing page: 20 for $4.99 or 100 for $9. Credit-pack and sign-up credits never expire. Subscription credits reset each month. Coming from the website instead of the API? See the remove.bg alternative page.
Base URL swap
Before (remove.bg)
curl -X POST \ -H "X-Api-Key: YOUR_REMOVEBG_KEY" \ -F "image_file=@/path/to/image.jpg" \ -F "size=auto" \ https://api.remove.bg/v1.0/removebg --output result.png
After (ZeroBG)
curl -X POST \ -H "X-Api-Key: YOUR_ZEROBG_KEY" \ -F "image_file=@/path/to/image.jpg" \ -F "size=auto" \ https://zerobg.ai/v1.0/removebg --output result.png
Endpoint
Send multipart form data or application/x-www-form-urlencoded. JSON bodies are also accepted for image_url and image_file_b64. Maximum upload size is 25MB.
The response is the image itself. Send Accept: application/json to get {"data":{"result_b64":…,"foreground_top":…}} instead, as remove.bg does.
Request parameters
Provide exactly one image source.
| Parameter | Description |
|---|---|
| image_file | Image upload (JPG, PNG, WebP). |
| image_url | Public http(s) URL. Private and link-local addresses are rejected. |
| image_file_b64 | Base64 image, with or without a data-URL prefix. |
| size | preview / small / regular (0.25 MP), medium (1.5 MP), hd (4 MP), full / 4k / auto / 50MP (original). Default: preview, matching remove.bg. |
| format | png, jpg, webp, zip, or auto. Default: auto (png, or jpg when a solid background is set). |
| bg_color | Hex (#fff, #ffffff, #ffffffff) or a common color name such as white. |
| bg_image_url / bg_image_file | One background image. Do not combine with bg_color. |
| channels | rgba (default) or alpha (the mask only). |
| crop | true trims to the subject. crop_margin accepts px or % (1, 2, or 4 values). |
| scale / position | Scale the subject (10–100% or original) and place it (original, center, or x% y%). |
| roi | Keep the subject only inside this box, as four px or % values: x1 y1 x2 y2. |
| type / type_level | Accepted. A specific type is echoed in X-Type; otherwise the header is other. type_level=none omits X-Type. ZeroBG does not run a separate classifier. |
| semitransparency, add_shadow, shadow_type, shadow_opacity | Validated so existing clients don't 400. Shadows are not generated. Sending both add_shadow and shadow_type returns 400 multiple_shadow_params. |
Response
Success is 200 with the image bytes (image/png, image/jpeg, image/webp, or application/zip).
- X-Credits-Charged: 1
- X-Credits-Remaining: balance after this call
- X-Width, X-Height, X-Foreground-Top, X-Foreground-Left, X-Foreground-Width, X-Foreground-Height
- X-Type: requested type, or other
- X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset
Account balance (GET /v1.0/account) returns:
{
"data": {
"attributes": {
"credits": { "total": 20, "subscription": 0, "payg": 20 }
}
}
}Errors use the remove.bg shape and status codes:
{ "errors": [{ "code": "insufficient_credits", "title": "Insufficient credits" }] }- 400 — missing or conflicting image source, invalid parameter
- 402 — no credits left
- 403 — missing or invalid API key
- 429 — per-minute or daily limit
More examples
Image URL
curl -X POST \ -H "X-Api-Key: YOUR_ZEROBG_KEY" \ -F "image_url=https://example.com/image.jpg" \ -F "size=full" \ -F "format=png" \ https://zerobg.ai/v1.0/removebg --output result.png
Base64 plus a white background
curl -X POST \ -H "X-Api-Key: YOUR_ZEROBG_KEY" \ -F "image_file_b64=$(base64 -i image.jpg)" \ -F "bg_color=ffffff" \ https://zerobg.ai/v1.0/removebg --output result.jpg
Account balance
curl -H "X-Api-Key: YOUR_ZEROBG_KEY" \ https://zerobg.ai/v1.0/account
Python
import requests
response = requests.post(
"https://zerobg.ai/v1.0/removebg",
files={"image_file": open("input.jpg", "rb")},
data={"size": "auto", "format": "png"},
headers={"X-Api-Key": "YOUR_ZEROBG_KEY"},
)
if response.status_code == 200:
open("output.png", "wb").write(response.content)
else:
print(response.status_code, response.json())Credits and rate limits
- Each successful call uses 1 credit, including size=preview. remove.bg charged 0.25 credits for a preview; the model cost here is the same at every size, so the price is flat.
- Failed calls refund the credit. They still count toward the daily limit, which is the spend guard (the inference provider has no platform cap).
- A new free account can make 5 API calls per day. Unpaid accounts on the same network share a 20-call daily cap.
- After you buy a credit pack, or on Basic: 100 calls/day. Lifetime: 50. Pro: 300. Business: 600. A burst limit of 20 requests per minute applies on each server.
- Credit-pack and sign-up credits never expire. Subscription credits reset to the plan amount each month and are spent first. A credit pack also unlocks batch processing on the website (10 images; 50 on Business).
Older ZeroBG endpoint
POST https://zerobg.ai/api/v1/removebg still works with the same API key. Prefer /v1.0/removebg for new integrations.
The older route defaults to size=full and format=png, and only accepts preview or full plus png or webp. Errors there stay in the previous shape: { "error": { "type", "message" } }, with 401 for a bad key.
Legacy endpoint
curl -X POST \ -H "X-Api-Key: YOUR_ZEROBG_KEY" \ -F "image_file=@/path/to/image.jpg" \ -F "size=full" \ https://zerobg.ai/api/v1/removebg --output result.png