Background removal API for AI agents: MCP tool or REST call, transparent PNG out.
A background removal API separates the subject of a photo from everything behind it and returns a cutout with a real alpha channel — no editor, no manual selection, one HTTP request per image.
Image MCP Server exposes background removal as POST /v1/remove-background and as the remove_background MCP tool, so an agent in Claude Code, Cursor or any other MCP client can cut out an image mid-task without you writing the request. Send a URL or a base64 image and get the PNG back. It is a background remover API with no editor to log into and no separate subscription for the one step of your pipeline that needed a cutout.
What you actually get back
A PNG with a genuine alpha channel, not a white rectangle and not a hard-edged mask. That distinction is the whole point: alpha is what lets the subject sit on a gradient, overlap a heading, or bleed past the edge of a card. A JPEG can only ever be a rectangle.
The file is uploaded to Cloudflare R2 and handed back as an https URL, so the next step in your pipeline can consume it directly without you storing anything. If you would rather hold the bytes yourself, ask for responseFormat: "b64_json" and they arrive in the same response. The hosted copy is made either way — that flag adds the bytes, it does not skip the upload.
This page is the endpoint: fields, response, price per cutout. If you are cleaning up a whole product catalogue, the ecommerce product image pipeline covers the workflow around it: enlarge first, cut out, flatten onto pure white in your own code, then compress, at a cost per SKU.
Timely
If you are moving off remove.bg
remove.bg’s own API documentation states that from 1 December 2026 its background removal “moves to Leonardo.Ai, also part of Canva”, and the same page carries a Leonardo API migration section. Checked November 2026.
We are not going to tell you what that means for your account — check it yourself, because the public documentation does not cover what happens to credits you have already bought. What we can say is that if you have to re-point an integration before the deadline anyway, the cost of evaluating an alternative has dropped to roughly zero.
Worth noticing what the incumbent is actually arguing, though: the pitch for moving is that a cutout should chain into upscaling and scene generation rather than ending the job. That is a fair description of how this server has always worked — remove_background is one of eight image tools behind one endpoint and one key, and multicall chains them in a single request.
01
Swap the URL
POST to /v1/remove-background instead. One JSON field: image.
02
Swap the auth
Authorization: Bearer, or the x-api-key header if that is closer to what you had.
03
Read one field
The cutout is result.imageUrl. Credits spent and left come back on the same response.
Background removal API request example
The whole surface is image. Everything else is optional. That matters more than it sounds: a tool an agent can call correctly on the first try is a tool that actually gets used mid-task.
curl -X POST "https://api.imagemcpserver.com/v1/remove-background" \
-H "Authorization: Bearer $IMAGEMCP_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "image": "https://cdn.example.com/shoe.jpg" }'Background removal API response
Note that the response names the model that did the work, and reports both the credits taken and the balance left — so a batch job can decide whether to keep going without a second call.
{
"success": true,
"deductedCredits": 8,
"userCredits": 2439,
"result": {
"imageUrl": "https://cdn.imagemcpserver.com/bgrem/bgrem_6251423.png",
"action": "remove_bg",
"model": "fal-ai/feynobg",
"hasInputImage": true,
"seed": 610233,
"latency": "2.74s"
}
}If the provider fails, the call answers 500 with refundedCredits in the body — the 8 credits go back automatically, so a retry loop against a flaky image cannot quietly drain a balance.
Remove a background in Python and Node
One POST with a bearer token — no SDK to install. The x-api-key header works as an alternative to Authorization if that is closer to the client you are replacing.
import os, requests
r = requests.post(
"https://api.imagemcpserver.com/v1/remove-background",
headers={"Authorization": f"Bearer {os.environ['IMAGEMCP_API_KEY']}"},
json={"image": "https://cdn.example.com/shoe.jpg"},
timeout=90,
)
data = r.json()
print(data["result"]["imageUrl"], data["deductedCredits"])const res = await fetch(
"https://api.imagemcpserver.com/v1/remove-background",
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.IMAGEMCP_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ image: sourceUrl }),
},
);
const { result, deductedCredits } = await res.json();
console.log(result.imageUrl, deductedCredits);Background removal API parameters
The same body works for the REST endpoint and the remove_background MCP tool.
| Field | Accepts | What it does |
|---|---|---|
image | string · required | The photo to cut out, as an https URL or a base64 data URI. imageBase64 is accepted as an alias for the same value. |
responseFormat | url · b64_json | Defaults to url. b64_json adds result.b64_json and result.imageBase64 to the same response. |
prompt | string | Echoed back as result.prompt and otherwise ignored: it does not steer the cutout and is not written to your request log. |
model | string | Accepted for forward compatibility but currently ignored: every cutout runs on the same matting model, which the response reports back to you. |
Edge quality, honestly
The cutout comes from a matting model, which produces a soft alpha channel rather than a hard binary mask. That is the difference between hair that looks like hair and hair that looks like it was cut out with scissors, and it is the reason the output is worth more than a threshold-based cut.
It is not magic, and no vendor in this category has solved the hard cases. Fine strands against a busy background, a subject whose colour matches what is behind it, motion blur at the edge of a limb, glass and reflections — these degrade everywhere, here included. The honest advice is to run your own worst photo through the $5 Testing plan before you wire a pipeline to any provider, ours or anyone else’s.
Background removal API pricing
A flat 8 credits per cutout, whatever the image size. What that is in money depends on how you bought the credits, so here is every option, worked out per cutout:
| How you buy credits | Price | Credits | Cutouts | Per cutout |
|---|---|---|---|---|
| Testing planOne-time | $5 | 100 | 12 | 40¢ |
| Starter planPer month | $20 | 250 | 31 | 64¢ |
| Pro planPer month | $50 | 750 | 93 | ≈ 53.3¢ |
| Enterprise planPer month | $100 | 2,000 | 250 | 40¢ |
| 300-credit packOne-time | $10 | 300 | 37 | ≈ 26.7¢ |
| 800-credit packOne-time | $25 | 800 | 100 | 25¢ |
| 1,700-credit packOne-time | $50 | 1,700 | 212 | ≈ 23.5¢ |
| 3,600-credit packOne-time | $100 | 3,600 | 450 | ≈ 22.2¢ |
Cutouts are whole calls at 8 credits; on the Starter plan that is 31 a month, on the Enterprise plan 250. No watermark on any of them.
Why credit packs come out cheaper per cutout
Every credit pack is cheaper per credit than every plan: ≈ 22.2¢ to ≈ 26.7¢ per cutout from a pack, against 40¢ to 64¢ from a plan.
A pack is a one-time purchase you can make with or without a subscription, and its credits land in the same balance. What a monthly plan adds is not cheaper credits. It adds bring-your-own-key: connect an OpenRouter key and generation and editing drop to a flat 2 credits a call, and the Enterprise plan adds priority email support. BYOK does not change the price of a cutout, because background removal runs on our own provider either way. So if cutouts are most of what you buy, a pack is the cheaper way to buy them. A plan is the one to pick when you also generate or edit images and want to run those on your own OpenRouter key.
When a specialist is the better buy
Be clear-eyed about this. If background removal is the only thing you need and you are doing it at real volume, a dedicated cutout service priced per image will beat these numbers, often by an order of magnitude — that is what a single-purpose product is for, and a few of them are very good.
This is worth paying for when the cutout is one step among several. Generating the source image, editing it, cutting it out, upscaling it and compressing it behind one key, one bill and one integration is cheaper in total than assembling four vendors to do it — and it is the only version an agent can drive end to end. See plans and credit packs.
Three tools touch transparency. Pick the right one.
| You have… | Use | Cost |
|---|---|---|
| A photo that needs its background gone | remove_backgroundThis page | 8 credits |
| Nothing yet — the subject has to be made and cut out | generate_transparent_imageTransparent PNG generator API | model rate + 8 |
| A photo that needs a different background, not none | edit_imageAI image editing API | model rate, 15 by default |
Where a cutout is the difference between shipping and not
Catalogue imports
Suppliers send photos on beige carpet, grey studio walls and kitchen tables. One pass over the import queue and every product sits on the same clean ground.
Composites
A cutout can be dropped onto a gradient, a lifestyle photo or a colour block. A JPEG with a baked-in background can only ever be a rectangle.
Marketing layouts
Subjects that break out of their container — overlapping a heading, bleeding past a card edge — need alpha. This is the call that gets you there.
User-generated content
Profile pictures and submitted photos arrive with whatever was behind the person. Normalising them makes a directory look designed rather than assembled.
Sprite and icon work
Game and app assets need transparency by definition. Generate, upscale, then cut out last. The upscaler returns transparency as white, so the cutout has to be the final step.
Print and packaging
Upscale first, then cut out. The upscaler returns transparency as white, so a cutout has to be the last step or you lose the alpha channel.
Workflows that call remove_background
Each of these use cases runs this tool as one step of a larger job, with the tool order and the credit cost worked out.
Use it from your agent
Connect the server once in Claude Code or Cursor, or in any other MCP client, and remove_background shows up in your agent’s tool list next to the other 7 image tools and 3 utility tools. Setup takes about five minutes. New to the protocol? What MCP is, and how an agent calls a tool.
More image APIs on the same key
One API key and one credit balance cover all eight, over REST or as MCP tools. Six of them return a hosted URL that the next tool accepts as input, so they chain without a download step.
- AI image generation APIText-to-image and image-to-image, any live model8–30 credits
- AI image editing APIEdit or restyle an image from a text instruction8–30 credits
- AI image upscaler APICrisp super-resolution in one call15 credits
- Transparent PNG generator APIGenerate and cut out in one call16–38 credits
- AI SVG generator APIGenerate editable vector SVG from a prompt5 credits
- Image compression APIRe-encode smaller with a quality dial1 credit
- Image format converter APIPNG, JPG, WebP, GIF, TIFF, AVIF1 credit
- Compare all eight image APIsCost, response shape and the catch for each, side by side.
Background removal API questions
No source photo yet? The transparent PNG generator API makes the subject and cuts it out in one call.
What is a background removal API?
A service that takes an image over HTTP, separates the main subject from everything behind it, and returns the subject on a transparent background. It replaces the manual selection work someone would otherwise do in an image editor, which is what makes it usable inside an import pipeline or by an agent working unattended.
What format does the cutout come back in?
A PNG with a real alpha channel, uploaded to Cloudflare R2 and returned as an https URL in result.imageUrl. Pass responseFormat: "b64_json" and the same response also carries the bytes as result.b64_json and result.imageBase64, which avoids a second round trip when the caller wants to hand the image straight to another tool.
How does it handle hair, glass and detailed edges?
The cutout runs on a matting model, so the alpha channel is soft rather than a hard binary mask — that is what keeps hair and semi-transparent edges usable instead of jagged. It is still the hardest case in the category: a subject whose colour matches the background, or fine strands against a busy scene, is where any matting model degrades. Test it on your own worst photo before you commit a pipeline to it.
How much does each removal cost?
A flat 8 credits per call whatever the image size. Bought through a plan that works out between 64¢ and 40¢ per cutout; bought as a credit pack it is between 27¢ and 22¢. Background removal runs on our own provider account, so connecting your own OpenRouter key does not change the price the way it does for generation and editing.
Is there a free tier?
No. New accounts start with 0 credits. The cheapest way in is the Testing plan: a one-time $5 for 100 credits, which is 12 cutouts — enough to check the edge quality on your own images before you commit to a plan or a pack. There is no watermark on the output.
Can I remove backgrounds in bulk?
Yes. Wrap the calls in multicall and they are dispatched concurrently rather than one after another, with the whole batch billed as a single deduction. That is the pattern for a catalogue import where a hundred supplier photos land at once.
Are there rate limits?
Sixty requests per minute per API key. A 429 response carries a Retry-After header, so a well-behaved batch job should honour it and back off rather than retrying immediately.
Do you store the images the API processes?
Every cutout is uploaded to Cloudflare R2 and served from a public https URL, including when you request responseFormat: "b64_json". That flag adds the bytes to the response; it does not skip the upload. Our privacy policy covers what is retained and for how long.
What happens to my remove.bg integration after 1 December 2026?
remove.bg's own API documentation says that from 1 December 2026 its background removal moves to Leonardo.Ai, and the same page carries a Leonardo API migration section. Checked November 2026. If you are re-pointing an integration anyway, the switch here is a different URL, a bearer token and one JSON field — but check your own remove.bg account for what happens to any credits you have already bought, because that detail is not stated on their public docs.
Should I remove the background before or after upscaling?
After. The upscaling model does not support transparent images — hand it a cut-out PNG and the transparent area comes back white, which destroys the alpha channel. Enlarge the flat photo first, then cut out the enlarged result. It costs the same either way; only one order gives you a usable transparent asset.
What is the difference between this and generate_transparent_image?
This one cuts out a picture you already have. generate_transparent_image creates the picture and cuts it out in a single call, billed at the model rate plus the same 8 credits for the cutout pass. Use it when there is no source photo to begin with.
Background removal API reference
8 credits. One call. Alpha channel intact.
$5 Testing plan: 100 credits — 12 cutouts, enough to judge the edges on your own photos.
Get an API key