Skip to navigation

Remove background

Remove the background from an image and return the foreground as a transparent PNG. Upload the source image using multipart/form-data. Returns the result directly by default; set async to get a generation_id and poll GET /v2/generations/{generation_id}.

Authentication

Api-Keystring

API key for access control. Use in the header with the name "Api-Key"

Query parameters

dry_runbooleanOptionalDefaults to false

When true, the request is validated and priced but not run: nothing is generated, stored, or billed, and no safety review is performed. The response is a PriceQuote object instead of the usual response for this endpoint. Send exactly the request you would send to generate, so the quote reflects the same options.

Request

This endpoint expects a multipart form containing a file.
imagefileRequired
The source image. JPEG, PNG, or WebP, up to 25MB. Multipart requests only.
privatebooleanOptional
Whether to keep the result out of the public gallery. When omitted, defaults to your plan's setting, or public if your plan has none. Enterprise generations are always private.
asyncbooleanOptionalDefaults to false

When false (the default), wait for and return the foreground image. When true, return as soon as the request is accepted; poll GET /v2/generations/{generation_id} for the result.

Response

The foreground image (synchronous requests), or an acknowledgement to poll (async requests). If a synchronous request fails after the response has started streaming, the HTTP status is already 200; the body contains error and status_code instead.

generation_idstringOptional

The generation ID to poll with GET /v2/generations/{generation_id}.

datalist of objectsOptional
The single foreground image. Present only for synchronous requests.
errorstringOptional
Error message for a failure after the response started streaming.
status_codeintegerOptional
The HTTP status the failure would have returned before streaming began.

Errors

400
Bad Request Error
401
Unauthorized Error
402
Payment Required Error
403
Forbidden Error
404
Not Found Error
429
Too Many Requests Error
500
Internal Server Error
503
Service Unavailable Error