Try Basic free for 7 days — 15 credits, no charge today.Start free trial
v1.0

Background Removal API reference.

Remove image backgrounds programmatically. Authenticate with an API key and POST an image — you get the cut-out back in the response.

Quick start

  1. Create an API key in your dashboard.
  2. Send your image to the endpoint below with the key as a Bearer token.
  3. Receive the background-removed image in the response.

Base URL

https://api.remover.bg

Authentication

Pass your API key as a Bearer token. Create and manage keys in your dashboard. Keep keys secret — anyone with a key can spend your credits.

Authorization: Bearer rmbg_YOUR_API_KEY

Remove background

POST/remove-bg

Send the image as multipart/form-data under the file field. Accepts PNG, JPEG or WebP up to 25 MB and 50 megapixels. The response body is the processed image; the remaining balance is returned in the X-Credits-Remaining header. An optional bg_image_file field can carry a background image (see below).

Parameters

All parameters are sent in the query string, except bg_image_file, which is a multipart field.

formatpng | jpeg | jpg | webpdefault pngOutput image format.
qualitynumber 0–1default 1Compression quality (jpeg/webp only).
trimbooleandefault trueTrim transparent edges around the subject. Trimming does not affect credit usage.
trim_marginstringdefault 0Space to leave around the subject when trimming, e.g. "30px" or "10%" (relative to subject size). One value (all sides), two (top/bottom, left/right) or four (top, right, bottom, left). Capped at 50% of the subject size or 500 px per side; never extends past the original image borders. Only applies when trim is enabled.
transparent_windowsbooleandefault trueCar photos only: cleans up the old background visible through the windows and keeps a natural, slightly transparent glass look. Set to false to get fully opaque windows. Images without car windows are unaffected.
shadowauto | force | nonedefault autoAI shadow. A dedicated shadow model generates a soft shadow that matches the subject's shape and where it meets the ground — there is nothing to tune by hand. With auto (the default) the shadow is added when a vehicle is detected; other subjects come back without one. Use force to apply the shadow to any subject, whatever is detected. Use none for a cutout with no shadow at all. The shadow is baked into the transparency, so it works on transparent results and with bg_ options alike.
bg_colorstringdefault —Adds a solid color background. Hex code (e.g. 81d4fa, fff) or color name (e.g. green). 4-/8-digit hex codes add semi-transparency (e.g. 81d4fa77). If present, the other bg_ options must be empty.
bg_image_urlstringdefault —Adds a background image from a URL. The image is centered and resized to fill the canvas while preserving its aspect ratio, unless it already has the exact same dimensions as the foreground. If present, the other bg_ options must be empty.
bg_image_filefiledefault —Adds a background image from a file, sent as a second multipart/form-data field (not a query parameter). PNG, JPEG or WebP up to 25 MB; scaled like bg_image_url. If present, the other bg_ options must be empty.
responseimage | urldefault imageBinary image (default) or JSON with a temporary download URL (kept for 24 hours).
session1default —Opens a one-hour photo session so you can choose which objects stay (see Select objects). PNG only, untrimmed (trim defaults to false), no bg_ options, binary response. The session id comes back in the X-Photo-Session header.

Examples

curl -X POST "https://api.remover.bg/remove-bg?format=png" \
  -H "Authorization: Bearer rmbg_YOUR_API_KEY" \
  -F "file=@photo.jpg" \
  --output result.png

Transparent car windows

On car photos, the old background showing through the windows is cleaned up automatically and the glass keeps a natural, slightly transparent look (transparent_windows=true, the default). Prefer solid windows? Pass transparent_windows=false and they come back fully opaque. This only applies to vehicle photos — images without car windows are unaffected either way.

curl -X POST "https://api.remover.bg/remove-bg?transparent_windows=false" \
  -H "Authorization: Bearer rmbg_YOUR_API_KEY" \
  -F "file=@car.jpg" \
  --output result.png

Shadows

Results come with an AI shadow by default. A dedicated shadow model generates a soft shadow that matches the subject's shape and where it meets the ground, so there is nothing to tune by hand — the single shadow parameter only decides when it is there: auto (the default) adds it when a vehicle is detected, force adds it to any subject (a product, a person, a pet…), and none returns a cutout with no shadow at all. Vehicle detection is part of the window cleanup, so with transparent_windows=false use forceto keep the shadow. The shadow is part of the image's transparency, so it also works together with the bg_ options below and costs no extra credits.

curl -X POST "https://api.remover.bg/remove-bg?shadow=force" \
  -H "Authorization: Bearer rmbg_YOUR_API_KEY" \
  -F "file=@product.jpg" \
  --output result.png
curl -X POST "https://api.remover.bg/remove-bg?shadow=none" \
  -H "Authorization: Bearer rmbg_YOUR_API_KEY" \
  -F "file=@car.jpg" \
  --output result.png

Backgrounds

Replace the removed background in the same call. Pass bg_color for a solid color (hex or color name; use a 4-/8-digit hex code for semi-transparency), bg_image_url to load a background image from a URL, or upload one directly as a bg_image_file multipart field. Background images are centered and scaled to fill the canvas while keeping their aspect ratio. Only one bg_ option can be used per request, and backgrounds do not affect credit usage.

# Solid color
curl -X POST "https://api.remover.bg/remove-bg?bg_color=81d4fa" \
  -H "Authorization: Bearer rmbg_YOUR_API_KEY" \
  -F "file=@photo.jpg" \
  --output result.png

# Background image from a URL
curl -X POST "https://api.remover.bg/remove-bg?bg_image_url=https%3A%2F%2Fexample.com%2Fbeach.jpg" \
  -H "Authorization: Bearer rmbg_YOUR_API_KEY" \
  -F "file=@photo.jpg" \
  --output result.png

# Background image from a file
curl -X POST "https://api.remover.bg/remove-bg" \
  -H "Authorization: Bearer rmbg_YOUR_API_KEY" \
  -F "file=@photo.jpg" \
  -F "bg_image_file=@beach.jpg" \
  --output result.png

Response formats

By default the response body is the processed image (binary). Pass ?response=url to instead receive JSON with a temporary download URL:

curl -X POST "https://api.remover.bg/remove-bg?response=url" \
  -H "Authorization: Bearer rmbg_YOUR_API_KEY" \
  -F "file=@photo.jpg"
200 · application/json
{
  "url": "https://.../outputs/.../abc.png?X-Amz-...",
  "format": "png",
  "model": "quality",
  "expiresAt": "2026-06-20T10:00:00.000Z"
}

Stored results — including the URL above — are automatically deleted after 24 hours. Download promptly or use the default binary response.

Select objects

Decide which objects stay in the cutout: keep only the car and drop the person next to it, remove leftovers such as a hanging cable, or bring back something the automatic cutout left out. You pay for the background removal once; finding objects and applying a selection are free.

1. Remove the background with a session

Add session=1 to /remove-bg. The response is the usual image, plus an X-Photo-Session header with the session id and X-Photo-Session-Expires. The session lasts 1 hour and only your account can use it. Sessions need a PNG, untrimmed result (trim defaults to false here), without bg_ options or response=url.

curl -X POST "https://api.remover.bg/remove-bg?session=1" \
  -H "Authorization: Bearer rmbg_YOUR_API_KEY" \
  -F "file=@car.jpg" \
  -D headers.txt \
  --output result.png

2. Find the objects

POST/photos/{session_id}/objects

Send an empty JSON body to list the objects in the photo. Boxes are in pixels of the original image; each mask is a grayscale PNG (white = object) at maskWidth × maskHeight. inCutout tells whether the current cutout already contains the object, and parentIdmarks parts of another object (a car's wheels or plate). initialIds is what the automatic cutout kept. To look for something specific, send up to three English words — they are added to the list and returned in foundIds.

curl -X POST "https://api.remover.bg/photos/SESSION_ID/objects" \
  -H "Authorization: Bearer rmbg_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'

# Look for specific things
curl -X POST "https://api.remover.bg/photos/SESSION_ID/objects" \
  -H "Authorization: Bearer rmbg_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"words": ["dog", "suitcase"]}'
200 · application/json
{
  "sessionId": "4274a568663844be82f215d9270856a1",
  "width": 1500,
  "height": 2000,
  "maskWidth": 1440,
  "maskHeight": 1920,
  "objects": [
    {
      "id": "o1",
      "name": "car",
      "score": 0.93,
      "box": [96, 610, 1410, 1720],
      "maskUrl": "data:image/png;base64,iVBORw0KGgo...",
      "inCutout": true,
      "parentId": null
    },
    {
      "id": "o2",
      "name": "wheel",
      "score": 0.88,
      "box": [180, 1390, 470, 1712],
      "maskUrl": "data:image/png;base64,iVBORw0KGgo...",
      "inCutout": true,
      "parentId": "o1"
    }
  ],
  "initialIds": ["o1"],
  "foundIds": [],
  "expiresAt": "2026-11-19T10:00:00.000Z"
}

3. Apply the selection

POST/photos/{session_id}/apply

Send the ids to keep. The response is a PNG the size of the original. Only the listed objects stay: anything else the cutout had is removed, including leftovers that were not detected as objects, and listed objects the cutout had left out are added back. Fine edges such as hair are kept. The AI shadow stays only while every id in initialIds is kept. You can apply as many selections as you like within the session.

curl -X POST "https://api.remover.bg/photos/SESSION_ID/apply" \
  -H "Authorization: Bearer rmbg_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"keep": ["o1"]}' \
  --output selection.png

Limits per session: 12 object searches and 40 selections. An expired session returns 404; if object detection is busy you get 409 with a Retry-After header.

Get account

GET/account

Returns your remaining credits, active subscription and recent usage. Does not consume credits. Also available at /me.

Examples

curl "https://api.remover.bg/account" \
  -H "Authorization: Bearer rmbg_YOUR_API_KEY"

Response

200 · application/json
{
  "credits": 142,
  "subscription": {
    "plan": "pro_yearly",
    "status": "active",
    "currentPeriodEnd": "2027-01-15T00:00:00.000Z"
  },
  "usage": { "last30Days": 37 }
}

Responses & errors

/remove-bg returns the processed image (binary) on 200, with headers X-Credits-Remaining (balance after the call) and X-Output-File (suggested filename). Errors return JSON: { "error": "message" }.

StatusMeaning
400Missing file or invalid parameter.
401Missing or invalid API key.
402Insufficient credits.
404Photo session not found or expired (Select objects).
409Object detection is busy — retry after the Retry-After header (Select objects).
413File too large (max 25 MB) or image above 50 megapixels.
415Unsupported file type (use PNG, JPEG or WebP).
422Invalid request body, e.g. an unknown object id (Select objects).
429Per-session limit reached (Select objects).
503Server busy — retry shortly.
504Processing timed out.

Credits & pricing

Each successful /remove-bg call consumes 1 credit. Failed requests are not charged. Top up or subscribe on the pricing page.

API changelog

  1. Improved

    Small leftovers that are detached from the subject and sit well away from it — such as a stray piece of cable — are now removed automatically, before shadows and trimming, so trimmed results are tighter. Thin parts close to the subject, such as chair wires or bicycle frames, are kept.

  2. New

    Added object selection: session=1 on /remove-bg opens a one-hour photo session; POST /photos/{id}/objects lists the objects in the photo and POST /photos/{id}/apply keeps only the ones you choose — leftovers such as hanging cables are removed. Both are free.

  3. New

    Added shadow=force — applies the AI shadow to any subject, not only to detected vehicles. auto (default) and none are unchanged.

  4. Changed

    Shadows are now produced by a dedicated AI model and are on by default. A single shadow parameter takes auto (default) or none; the old shadow_type, shadow_opacity and shadow_direction parameters have been removed. Shadows still do not affect credit usage.

  5. New

    Added shadow_direction (−60 to 60 degrees) — 0 drops the shadow straight down, positive tilts it right, negative left. Applies to both car and drop shadows.

  6. New

    Added shadows: shadow_type (auto, car, drop, none) with shadow_opacity (0–100 or auto) — a soft drop shadow under the subject (a larger, softer one for vehicles), falling straight down by default. Shadows do not affect credit usage.

  7. New

    Added background replacement: bg_color (solid color, semi-transparent hex supported), bg_image_url and bg_image_file (custom image, centered and scaled to fill the canvas). Backgrounds do not affect credit usage.

  8. New

    Added the trim_margin parameter — leave a pixel (30px) or percentage (10%) margin around the subject when trimming.

  9. New

    Added the transparent_windows parameter — choose between naturally transparent or fully opaque car windows.

  10. Improved

    Car photos now get clean windows automatically: the old background visible through the glass is removed and a subtle transparency is kept.

  11. Changed

    Simplified to a single high-quality model. Every call now costs exactly 1 credit; the type parameter is no longer needed and is ignored.

  12. New

    The X-Trim response header now reports how much was trimmed from each edge, so results can be repositioned precisely over the original.

  13. Improved

    response=url download links are now signed, private URLs that expire together with the stored result (24 hours).

  14. New

    Added response=url — receive JSON with a temporary download URL instead of the binary image.

  15. Launch

    Public API launch: POST /remove-bg and GET /account with API-key authentication. PNG, JPEG and WebP supported as input and output formats.

Video endpoint

Upload a clip, poll the job, download the result. Not part of the public API yet.

Coming soon