DEV Community

szp2005
szp2005

Posted on Fully Autonomous

Migrating Broken /v1.0/removebg Scripts on Shutdown Day (Dec 1, 2026): cURL, Python, Node.js, n8n & MCP

Standalone remove.bg and its self-serve POST /v1.0/removebg API close today, December 1, 2026 at 09:00 CET. Under their September 9 terms, unused PAYG and monthly rollover credits expire on shutdown with no refund.

If you are checking repositories ahead of the 09:00 CET cutoff today (or triaging failing jobs right after it), you have two distinct paths:

  1. Rewrite to Leonardo.Ai (the official API destination): swap X-Api-Key for Authorization: Bearer, replace multipart/form-data binary uploads with presigned init uploads plus JSON requests, and pass "ephemeral": true if you do not want processed outputs retained in your library.
  2. Swap to a /v1.0/removebg-compatible endpoint: keep X-Api-Key, multipart/form-data or JSON request bodies, and X-Foreground-* bounding-box headers intact.

Below is a practical cutover checklist using remove.ac, covering cURL, Python, Node.js, self-hosted n8n, and MCP, along with payload limits and billing gotchas to verify before pushing to production.

1. Find Every Caller First

Search your codebase, CI workflows, and serverless configs for the hostname, path, and legacy environment variable together:

rg -n "api\.remove\.bg|/v1\.0/removebg|REMOVE_BG_API_KEY|removebg" .
Enter fullscreen mode Exit fullscreen mode

Do not skip self-hosted n8n or Make HTTP nodes, GitHub Actions asset jobs, and cron containers where api.remove.bg was hardcoded inside an image helper years ago.

2. Watch the Default size Parameter Across Clients

Before swapping keys, make size explicit in every call. On remove.ac (API reference), omitted size defaults match each surface's convention:

Surface Default size if omitted Max output Cost on 200 OK
Raw POST /v1.0/removebg (cURL / custom HTTP) preview ~0.25 MP 0.25 credit
Python from removebg import RemoveBg shim regular ~0.25 MP 0.25 credit
Node.js & Python RemoveAcClient, CLI remove-ac auto up to 50 MP 1 credit
MCP (remove-ac-mcp), GitHub Action, Desktop v1.1.1 full up to 50 MP 1 credit

Any 4xx, 5xx, validation rejection (413), or timeout returns X-Credits-Charged: 0. Always log the X-Credits-Charged response header in your wrapper so staging tests verify exact spend.

3. cURL: Multipart, JSON Input, and X-Foreground-* Headers

Standard binary upload (<= 4.4 MB)

REMOVE_AC_HOST="remove.ac"
curl -sS -D headers.txt \
  -H "X-Api-Key: $REMOVE_AC_API_KEY" \
  -H "Idempotency-Key: job-20261201-001" \
  -F "image_file=@product.jpg" \
  -F "size=full" \
  -F "format=png" \
  "https://${REMOVE_AC_HOST}/v1.0/removebg" \
  -o product-cutout.png
Enter fullscreen mode Exit fullscreen mode

Response headers include X-Credits-Charged, X-Width, X-Height, and the subject bounding box (X-Foreground-Top, X-Foreground-Left, X-Foreground-Width, X-Foreground-Height) so downstream compositors that read remove.bg subject coordinates keep working.

JSON body + JSON Base64 response

If your service sends JSON instead of multipart/form-data (or sets Accept: application/json to receive data.result_b64 alongside foreground coordinates):

REMOVE_AC_HOST="remove.ac"
curl -sS -X POST "https://${REMOVE_AC_HOST}/v1.0/removebg" \
  -H "X-Api-Key: $REMOVE_AC_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{"image_url":"https://example.com/shoe.jpg","size":"full","bg_color":"FFFFFF"}'
Enter fullscreen mode Exit fullscreen mode

Files > 4.4 MB up to 25 MB / 50 MP: 180s Single-Use HMAC Ticket

Direct serverless gateway requests cap at 4.4 MB. For larger studio images up to 25 MB (26,214,400 bytes) and 50 MP, POST /v1.0/removebg/ticket issues a 180-second single-use HMAC ticket (foregroundSha256 + foregroundByteLength -> directEndpoint, ticket, holdId, releaseToken). The binary then streams directly into GPU memory with zero disk or database persistence. If the upload drops or times out, calling /v1.0/removebg/ticket/release (or letting the hold lease expire) releases the credit hold at 0 charge.

4. Python (remove-ac@1.3.2, Zero External Dependencies)

pip uninstall -y removebg
pip install "remove-ac==1.3.2"
Enter fullscreen mode Exit fullscreen mode

Drop-in shim for legacy from removebg import RemoveBg call sites:

from removebg import RemoveBg

rmbg = RemoveBg("rac_live_your_key_here")
rmbg.remove_background_from_img_file(
    "bottle.jpg",
    size="full",
    new_file_name="bottle-cutout.png",
)
Enter fullscreen mode Exit fullscreen mode

Or use RemoveAcClient (automatically negotiates /v1.0/removebg/ticket when local files exceed 4 MB, up to 25 MB / 50 MP):

from remove_ac import RemoveAcClient

client = RemoveAcClient()  # reads REMOVE_AC_API_KEY
cutout_bytes = client.remove_background(
    "catalog-19mb.png",
    size="full",
    crop=True,
    shadow_type="contact",
)
with open("catalog-19mb-cutout.png", "wb") as f:
    f.write(cutout_bytes)
Enter fullscreen mode Exit fullscreen mode

5. Node.js 18+ & Hot-Folder CLI (remove-ac@1.3.2)

npm install remove-ac@1.3.2
Enter fullscreen mode Exit fullscreen mode
import fs from "node:fs";
import { RemoveAcClient } from "remove-ac";

const client = new RemoveAcClient({ apiKey: process.env.REMOVE_AC_API_KEY });
const result = await client.removeBackground("./chair-15mb.png", {
  size: "full",
  format: "png",
  bgImageFile: "./studio-backdrop.jpg",
});

fs.writeFileSync("./chair-composited.png", result.buffer);
console.log(`${result.width}x${result.height}, credits=${result.creditsCharged}`);
Enter fullscreen mode Exit fullscreen mode

Note on combined uploads: each file supports up to 25 MiB, and combined foreground + local bgImageFile raw bytes cap at 29.5 MiB client-side inside the 32 MiB edge request limit.

For shell scripts or watched folders without writing JS:

npx -y -p remove-ac@1.3.2 remove-ac ./incoming --output-dir ./cutouts --concurrency=4 --size=full
Enter fullscreen mode Exit fullscreen mode

For GitHub Actions asset pipelines, use szp2005/remove-ac-sdk@v1. Standalone Electron installers (v1.1.1 for Windows, macOS Universal, and Linux) are also available for non-CLI teammates.

6. Self-Hosted n8n (n8n-nodes-remove-ac@1.0.3) & MCP (io.github.szp2005/remove-ac@1.3.2)

  • Self-hosted / desktop n8n: go to Settings -> Community Nodes -> Install and install n8n-nodes-remove-ac (v1.0.3). It accepts upstream binary items (data) or public URLs (with private-IP/NAT64 SSRF checks), auto-streams > 4 MB files via /v1.0/removebg/ticket, outputs cutout binaries plus json.removeAc metadata (creditsCharged, width, height, foregroundTop/Left/Width/Height), and works as an n8n AI Agent tool (usableAsTool: true).
  • MCP clients (Claude Desktop, Cursor, VS Code, Windsurf, Cline): run npx -y -p remove-ac@1.3.2 remove-ac-mcp (io.github.szp2005/remove-ac), which exposes remove_background_file, remove_background_url, and get_account_balance.

7. Testing Quality & Commercial Terms Before Committing

If a workflow only processes batches manually, you may not need an API key at all: remove.ac/batch runs $0 no-login browser cutouts locally via ONNX Runtime Web (after a 41-82 MB first-visit model cache, 0 source image bytes uploaded, up to 50 images / 250 MB batch ZIP with Amazon/Shopify/Etsy/eBay presets and 300 DPI metadata; single-image refinement and layered .PSD export live in remove.ac/upload, and fresh-device offline use is not guaranteed).

For Cloud GPU and API testing (pricing & terms):

  • Free web preview: signed-in accounts on remove.ac/upload get ~612px (~0.25 MP) Cloud GPU previews for 0 credits (5/day free, 30/day paid) before spending 1 credit on full 50 MP / 25 MB output.
  • Welcome grant: verified email signup grants 10 free full-resolution credits (valid 30 days).
  • Dec 1 Migration Grant (through Dec 31, 2026, 23:59:59 PST): auto-applied at checkout via single-use voucher (30% off Starter 10-75 PAYG & 40 mo/yr, 40% off Growth 200-500, 50% off High-Volume 1,200-5,000 PAYG/mo + 1,200 yr; max 3 orders/account, max 1 on 2,800/5,000; Enterprise 2,800 & 5,000 annual verified via support@remove.ac). PAYG packs ($9/10 to $1,299/5,000) never expire.
  • 14-day self-serve refund: initial (non-renewal) orders get 100% back if 0 credits are used, or a 1-click proportional refund for all remaining unused credits with $0 processing fee ($0.50 minimum net payout, max 2 self-serve refunds per account; further requests via support@remove.ac).

Disclosure: I build remove.ac.

Top comments (0)