Remove background
POST
https://api.imagemcpserver.com/playground/remove-background💳 8 credits🛠️ MCP tool: remove_background⌘ imagemcp.js remove_bg
Runs a dedicated cut-out model over your image and returns the subject on a transparent background. This is the endpoint to use for catalogue photography, avatars and any asset that has to composite onto another layout.
Overview
Strip the background from an image and return a transparent PNG.
Flat 8 credits per call, regardless of image size.
Request
Headers
| Field | Type | Description |
|---|---|---|
Authorizationrequired | string | Bearer <IMAGEMCP_API_KEY>. The header x-api-key: <key> is accepted as an alternative. |
Content-Typerequired | string | application/json |
Body parameters
| Field | Type | Description |
|---|---|---|
imagerequired | string | Input image as an https URL or a base64 data URI. imageBase64 is accepted as an alias for the same value. |
prompt | string | Optional note recorded with the request. It does not steer the cutout. |
responseFormat | "url" | "b64_json" | Defaults to "url". Pass "b64_json" to also receive result.b64_json and result.imageBase64 alongside the hosted URL. |
Examples
The same call in five forms. The MCP tab is what an MCP client sends under the hood; the CLI tab is what an agent with the agent skill runs.
remove_background
curl -X POST "https://api.imagemcpserver.com/playground/remove-background" \
-H "Authorization: Bearer $IMAGEMCP_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"image": "https://example.com/product.jpg"
}'imagemcp.js remove_bg --image ./product.jpg --out ./clean.pngconst res = await fetch("https://api.imagemcpserver.com/playground/remove-background", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.IMAGEMCP_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"image": "https://example.com/product.jpg"
}),
});
const data = await res.json();
console.log(data.result.imageUrl);import os
import requests
res = requests.post(
"https://api.imagemcpserver.com/playground/remove-background",
headers={"Authorization": f"Bearer {os.environ['IMAGEMCP_API_KEY']}"},
json={
"image": "https://example.com/product.jpg"
},
timeout=120,
)
print(res.json()){
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "remove_background",
"arguments": {
"image": "https://example.com/product.jpg"
}
}
}Response
Response fields
| Field | Type | Description |
|---|---|---|
result.imageUrl | string | Transparent PNG cut-out. |
result.action | string | "remove_bg". |
deductedCredits | number | Always 8. |
userCredits | number | Balance remaining after the call. |
{
"success": true,
"message": "Background removed successfully",
"deductedCredits": 8,
"userCredits": 2439,
"result": {
"imageUrl": "https://cdn.imagemcpserver.com/bgrem/bgrem_6251423.png",
"prompt": "Remove background",
"action": "remove_bg",
"hasInputImage": true,
"model": "fal-ai/feynobg",
"seed": 610233,
"latency": "2.74s",
"cost": "$0.0250",
"deductedCredits": 8,
"userCredits": 2439
}
}When it fails
Errors return
success: false with a message. See errors & troubleshooting for the status codes and whether a retry is worth it.FAQ
What does background removal cost?
A flat 8 credits per call — it does not vary with image size or the model you have selected elsewhere.
Can I send a local file?
Send it as a base64 data URI in the image field. Both https URLs and data URIs are accepted.