Developers
Background Remover API
Send an image, get back a transparent PNG. The API uses the same engine as the web app, returns JSON with request IDs on every response, and refunds credits automatically if processing fails.
Overview
Base URL: https://bgremovalai.co/api/v1. Requests and responses use JSON except for image uploads, which use multipart/form-data. Processing is asynchronous: you submit an image and receive a job. Pass wait to hold the connection open until the result is ready (most images finish within a few seconds).
- • Every response includes an
X-Request-IDheader (andrequest_idin error bodies). - • Result URLs are signed and expire after 15 minutes — download the file or request the job again for a fresh URL.
- • Results are kept for your account's retention period, then deleted automatically.
Authentication
Create keys in your dashboard. Send the key in the Authorization header (preferred) or in X-API-Key. Keys are shown once at creation and stored only as a hash.
Authorization: Bearer ctr_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# or
X-API-Key: ctr_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxPOST /background/remove
Uploads an image and starts background removal. Credits are reserved when the job is accepted and returned automatically if it fails.
| Parameter | In | Description |
|---|---|---|
| image | form | The image file (JPG, PNG, WebP or GIF). Required unless image_url is given. |
| image_url | form | A public http(s) URL to fetch instead of uploading. Private and internal addresses are refused. |
| wait | query | Seconds to wait for the result, 0–25 (default 0). If the job finishes in time the response is 200 with result_url; otherwise 202. |
Response (200 when finished within wait, 202 otherwise)
{
"data": {
"id": "6f1c2a0e-…", // job ID
"image_id": "b9d0…",
"status": "succeeded", // queued | processing | succeeded | failed
"progress": 100,
"width": 2400, "height": 1600,
"result_url": "https://…/result.png?…", // present when succeeded; expires in 15 minutes
"error_code": "", "error_message": "",
"credits_charged": 1,
"created_at": "2026-11-27T10:00:00Z", "finished_at": "2026-11-27T10:00:03Z"
}
}GET /background/jobs/{id}
Returns the job in the same shape as above. Poll every 1–2 seconds until the status is succeeded or failed. GET /background/jobs/{id}/result redirects (302) to the PNG, so curl -L downloads it directly.
GET /account
Returns your plan, credit balance, per-call cost and rate limit — useful for monitoring.
{ "data": { "plan": "business", "credits": 482, "credit_cost_per_call": 1, "rate_limit_per_minute": 120 } }Code examples
// Node.js 18+ (fetch, FormData and Blob are built in)
import { readFile, writeFile } from "node:fs/promises";
const API = "https://bgremovalai.co/api/v1";
const headers = { Authorization: `Bearer ${process.env.BG_REMOVAL_API_KEY}` };
async function removeBackground(path) {
const form = new FormData();
form.append("image", new Blob([await readFile(path)]), path);
let res = await fetch(`${API}/background/remove?wait=25`, { method: "POST", headers, body: form });
let { data, error } = await res.json();
if (!res.ok) throw new Error(`${error.code}: ${error.message} (request ${error.request_id})`);
// poll until the job finishes (only needed if it took longer than "wait")
while (data.status === "queued" || data.status === "processing") {
await new Promise((r) => setTimeout(r, 1500));
res = await fetch(`${API}/background/jobs/${data.id}`, { headers });
({ data } = await res.json());
}
if (data.status !== "succeeded") throw new Error(data.error_message);
const png = await fetch(data.result_url);
await writeFile("cutout.png", Buffer.from(await png.arrayBuffer()));
}
removeBackground("product.jpg");Errors
Errors use HTTP status codes and a consistent JSON body:
{ "error": { "code": "insufficient_credits", "message": "Not enough credits for this request.", "request_id": "req_9f2c…" } }| Status | Code | Meaning |
|---|---|---|
| 400 | url_not_allowed / url_fetch_failed | image_url points to a private address or could not be downloaded. |
| 401 | invalid_api_key | The key is missing, malformed, revoked or expired. |
| 402 | insufficient_credits | Your balance doesn't cover the request. Buy credits or upgrade. |
| 403 | api_access_not_included | Your plan doesn't include API access. |
| 404 | not_found | The job doesn't exist or belongs to another account. |
| 413 | payload_too_large | The image is larger than your plan's upload limit. |
| 415 | unsupported_media_type | The file isn't a JPG, PNG, WebP or GIF (checked by content, not extension). |
| 422 | invalid_image / validation_failed | The image is corrupt, too large in pixels, or a parameter is invalid. |
| 429 | rate_limited | Too many requests. Wait for the number of seconds in Retry-After. |
| 500 | internal_error | Something went wrong on our side. Retry with backoff; include the request_id if you contact us. |
| 503 | service_unavailable | Processing is temporarily unavailable. Retry with backoff. |
Rate limits
Each key is limited per minute according to your plan (shown in /account). Responses include X-RateLimit-Limit and X-RateLimit-Remaining; when you exceed the limit you receive 429 with Retry-After. Successful requests also return X-Credits-Remaining. Retry 429, 500 and 503 responses with exponential backoff.
Pricing
API access is included in plans with the API feature. Each accepted request uses the per-call credit cost shown in /account, from the same balance as the web app; failed jobs are refunded automatically. See pricing for plans and credit packs.