bgless
REST API · v1.0

Background Removal API

Add background removal to your app, shop or workflow with a few lines of code. Compatible with the remove.bg API.

Get an API key

Quick start

Create an API key in your account and send your first request:


        

Authentication

Send your API key in the X-Api-Key header with every request. Create and revoke keys in your account.

X-Api-Key: bg_xxxxxxxxxxxxxxxxxxxxxxxx

POST/v1.0/removebg

Removes the background of an image. The body can be multipart/form-data, application/x-www-form-urlencoded or application/json. Provide exactly one source: image_file, image_file_b64 or image_url.

ParameterDescription
image_fileImage file to upload (JPG, PNG, WebP…; max 20 MB).
image_file_b64Base64-encoded image.
image_urlURL of the image to download.
sizepreview · small · regular · medium · hd · 4k · full · 50mp · auto (default). auto: full resolution if you have credits, otherwise preview.
formatauto (default: PNG if transparent, else JPG) · png · jpg · webp.
bg_colorBackground color: hex (81d4fa, #fff) or a color name (white). Transparent if omitted.
bg_image_url / bg_image_fileImage to use as background (URL or file), placed behind the subject with “cover” fit.
cropIf true, empty space around the subject is cropped away.
crop_marginCrop margin: 30px or 10% (max 500px / 50%).
add_shadowIf true, a soft drop shadow is added under the subject.
channelsrgba (default) or alpha (grayscale mask only).
modelfast (default, ~3 s) or hd (sharper edges, ~40 s). bgless extension.

Response

A successful response is the image itself (image/png, image/jpeg or image/webp) with these headers:

X-Credits-ChargedCredits charged for this request (e.g. 1, 0.25, 0).
X-Width, X-HeightSize of the result image.
X-Foreground-Top/Left/Width/HeightPosition and size of the subject within the result (pixels).

Send Accept: application/json to receive the image base64-encoded in JSON:

{"data": {"result_b64": "iVBORw0KGgo…", "foreground_top": 120, "foreground_left": 45,
          "foreground_width": 519, "foreground_height": 288}}

GET/v1.0/account

Returns your credit balance and the free API previews left this month. Free of charge.

{"data": {"attributes": {
  "credits": {"total": 42.5, "subscription": 0, "payg": 42.5, "enterprise": 0},
  "api": {"free_calls": 47, "sizes": "all"}
}}}

Credits & limits

sizeResolutionCredits
preview, small, regular≤ 0.25 MP50 free per month, then 0.25
medium≤ 1.5 MP1
hd≤ 4 MP1
4k≤ 10 MP1
full, 50mp≤ 36 MP1
autofull or preview depending on balance0–1

Rate limit: 60 requests per minute per API key. Exceeding it returns 429.

Errors

Failed requests return a JSON body with an errors array:

{"errors": [{"title": "Insufficient credits", "code": "insufficient_credits"}]}
400Invalid parameter, or missing / unreadable image.
402Insufficient credits.
403Missing or invalid API key.
413Image larger than 20 MB.
429Rate limit exceeded.