Background removal API
Same requests as the remove.bg API, same responses. Change the base URL and the key; leave the rest of your code alone.
Switching from remove.bg
remove.bg has announced that its standalone service closes on 1 December 2026 and that self-serve API requests stop the same day, with its API moving to Leonardo.Ai. If your code calls api.remove.bg, point it here instead:
| Before | https://api.remove.bg/v1.0/removebg |
|---|---|
| After | https://imagic-ai.com/api/v1.0/removebg |
The header stays X-Api-Key, the fields keep their names, and errors keep remove.bg's shape, so client libraries that let you set the base URL work as they are.
What the 1 December shutdown changes, and what to do firstGet a key
- Sign in with Google.
- Open My Account and create a key under Background removal API keys.
- Copy the key when it is shown. It is displayed only once.
Quick start
Send the image as a file upload, as base64, or as a public URL. The response body is the finished image.
curl -H "X-Api-Key: $IMAGIC_API_KEY" \
-F "image_file=@photo.jpg" \
-F "size=auto" \
-o no-bg.png \
https://imagic-ai.com/api/v1.0/removebgimport os, requests
response = requests.post(
"https://imagic-ai.com/api/v1.0/removebg",
files={"image_file": open("photo.jpg", "rb")},
data={"size": "auto"},
headers={"X-Api-Key": os.environ["IMAGIC_API_KEY"]},
)
response.raise_for_status()
with open("no-bg.png", "wb") as out:
out.write(response.content)import { readFile, writeFile } from "node:fs/promises";
const form = new FormData();
form.append("image_file", new Blob([await readFile("photo.jpg")]), "photo.jpg");
form.append("size", "auto");
const res = await fetch("https://imagic-ai.com/api/v1.0/removebg", {
method: "POST",
headers: { "X-Api-Key": process.env.IMAGIC_API_KEY },
body: form,
});
if (!res.ok) throw new Error(JSON.stringify(await res.json()));
await writeFile("no-bg.png", Buffer.from(await res.arrayBuffer()));Request fields
POST /api/v1.0/removebg accepts multipart/form-data, application/x-www-form-urlencoded or JSON. Send exactly one of the three image fields.
| Field | Values | Notes |
|---|---|---|
| image_file | file | JPG, PNG or WebP upload, up to 22 MB. |
| image_file_b64 | base64 string | The same file, base64-encoded. A data: URL prefix is accepted. |
| image_url | http(s) URL | We download it. Public addresses only, standard web ports, up to 3 redirects. |
| size | preview · small · regular · medium · hd · full · 4k · auto · 50MP | preview/small/regular: up to 0.25 MP. medium: 1.5 MP. hd: 4 MP. full/4k/auto/50MP: up to 25 MP (PNG up to 10 MP). Every size counts as one image. |
| format | auto · png · jpg · webp · zip | auto returns PNG when the result is transparent and JPG when it is not. zip holds color.jpg plus alpha.png, as on remove.bg. |
| channels | rgba · alpha | alpha returns only the mask, in grayscale. |
| bg_color | hex (81d4fa, #81d4fa77) or a color name | Fills the removed background. A JPG with no bg_color is flattened onto white. |
| crop | true · false | Trims the result to the subject. |
| crop_margin | e.g. 30px or 10% | Space around a cropped subject. Up to 500px or 50%. |
| type | auto · person · product · car · animal · graphic · transportation | Accepted for compatibility. It is echoed in X-Type; it does not change the cutout. |
| model | fast · precise | Our addition (remove.bg has no such option). fast, the default: our standard model. precise: finer edges on hair, thin parts and glass, a little slower. Both count as one image; the X-Imagic-Model header says which one ran. |
scale, position, roi, bg_image_url, bg_image_file and shadow options are not supported. Requests that use them get a 400 rather than a silently different image.
Response
By default the body is the image itself, with these headers: X-Width, X-Height, X-Type, X-Foreground-Top, X-Foreground-Left, X-Foreground-Width, X-Foreground-Height, X-Credits-Charged (always 1) and X-RateLimit-Limit / -Remaining / -Reset for the daily allowance. An image paid with a credit also carries X-Imagic-Paid: 1 and X-Imagic-Credit-Balance. Send Accept: application/json to get JSON instead:
{
"data": {
"result_b64": "iVBORw0KGgo…",
"foreground_top": 115,
"foreground_left": 477,
"foreground_width": 637,
"foreground_height": 824
}
}Remaining allowance
GET /api/v1.0/account returns remove.bg's account shape. api.free_calls is the number of free images left today, credits.payg is the account's credit balance, and credits.total is the two added together.
Errors
Errors use remove.bg's envelope, shown below. A failed request does not use up an image.
{"errors": [{"title": "Daily limit of 50 free images reached. …", "code": "rate_limit_exceeded"}]}| Status | Meaning |
|---|---|
| 400 | Bad input: no image, two images, an unreadable file, an unsupported option, or an image_url we may not or could not fetch. |
| 403 | The X-Api-Key header is missing, wrong or revoked. |
| 422 | The model you asked for is not available right now (code model_unavailable). Retry with model=fast; the image is not counted. |
| 429 | The 50 free images for today are used up and the account has no credits left, or it has reached 1,000 paid images today. Retry-After gives the seconds until the free images reset. |
| 503 | Processing is temporarily unavailable. Retry after a short wait. |
Limits
- 50 images a day per account, shared by all of its keys. Up to 3 active keys per account, so you can rotate them.
- Uploads up to 22 MB. Output up to 25 MP, or 10 MP for PNG.
- Requests are queued and processed a few at a time. Expect a few seconds per image, more for large photos.
- After the 50 free images, each image uses one credit from the account's balance, up to 1,000 paid images a day. Credits are bought on the account page (100 for US$5 or 500 for US$19) and do not expire.
What to expect from the cutouts
Cutouts come from the isnet-general-use model, the same one behind the Background Remover tool. It is reliable on products, people and animals against ordinary backgrounds. Fine hair, glass and subjects that match their background are where it is weakest, and remove.bg's own model may do better there. Test with a few of your own images before you move a production pipeline.
Questions
- Is this an official remove.bg replacement?
- No. Imagic AI is not affiliated with remove.bg, Canva or Leonardo.Ai. The API accepts remove.bg's request format so existing code keeps working.
- Is the API free?
- Yes. Every account gets 50 images a day at no cost. Every size counts as one image, including preview. Past that, each image uses one credit (100 credits cost US$5).
- Do the official remove.bg client libraries work?
- Libraries that let you set the base URL work by changing it to https://imagic-ai.com/api. Libraries with api.remove.bg hard-coded need that one line changed in their source or a small wrapper.
- Do you keep my images?
- Images sent to the API are processed and returned in the response. They are not added to any gallery or used for training.
Only need a few images, without code?
Use the Background Remover