Image Editing API

AI Background Removal API

Remove image backgrounds programmatically and turn varied foreground objects into transparent PNG cutouts or reusable masks for ecommerce, marketplaces, creative tools, and automated media pipelines.

Strawberry product photo before and after automatic API background removal
Transparent PNG Return a ready RGBA cutout from Layer: 0.
Foreground Mask Return a ZIP with a mask layer from Layer: 1.
Single Plugin Job Remove Background must be the only task in the job.

Remove Background is a professional-mode plugin for teams that need to remove backgrounds from images automatically. The model performs foreground extraction across a broad range of subjects and objects rather than being tied to a single object category. The API returns either a production-ready transparent PNG or a layered ZIP archive containing the foreground mask.

Important: Remove Background must be the only plugin in the tasks array. Do not combine it with Heal, Crop, Color Correction, Clean Backdrop, or any other plugin in the same job. If you need additional processing, run background removal as a separate API request.

Background Removal Jobs This API Solves

Create Transparent Product PNGs

Remove the background from product images automatically and export clean RGBA cutouts for online stores, catalogs, and product detail pages.

Prepare Marketplace Images

Standardize seller and SKU photography before placing products on white, branded, seasonal, or marketplace-specific backgrounds.

Automate DAM, PIM, And CMS Workflows

Connect background removal to media ingestion, catalog publishing, asset management, and content production without a manual clipping path step.

Build A Photo Cutout Tool

Add an AI background eraser to an editor, upload form, design application, or internal content tool using the same asynchronous Cloud API flow.

Export Foreground Masks

Retrieve a black-and-white segmentation mask for compositing, quality control, background replacement, or downstream image processing.

Process Varied Foreground Objects

Cut out products, food, clothing, accessories, furniture, props, and other visible foreground subjects from studio or real-world scenes.

How To Remove An Image Background By API

  1. Upload one source image Send the JPG or PNG as multipart form data to /retoucher/start together with your token and JSON payload.
  2. Choose the required output Request Layer: 0 for a ready transparent PNG, or Layer: 1 for a ZIP containing the foreground mask.
  3. Poll and download Check /retoucher/status/{id} until the job completes, then download the result from /retoucher/getFile/{id}.

For bulk background removal, submit one job per image and manage the returned job IDs in your own queue. This pattern works for SKU imports, marketplace feeds, DAM/PIM synchronization, and other high-volume image-processing workflows.

Choose Transparent PNG Or Foreground Mask

Ready Image With No Background

Choose transparent PNG output when the next system needs a finished cutout immediately. It can be displayed as-is or composited onto white, solid-color, branded, or generated backgrounds.

See the transparent PNG request.

Reusable Object Segmentation Mask

Choose layered ZIP output when an editor or backend needs the foreground selection separately for masking, review, refinement, or custom compositing.

See the foreground mask request.

Example Output

The first example shows a clean product-style batch: multiple strawberries are preserved as a single foreground group and returned as a transparent PNG. The same request can also return the foreground mask in a ZIP archive.

Source strawberry product photo before automatic background removal
Source Image Download source PNG
Strawberry product cutout with a transparent background returned by the API
Ready Transparent PNG Download result PNG
White foreground segmentation mask for strawberries on a black background
Foreground Mask Download mask PNG

Second Example: Object Cutout From A Complex Scene

This example demonstrates a harder real-world scene with overlapping furniture, shadows, fine edges, and a blurred outdoor background. The photographed object happens to be a potted succulent, but the workflow is category-independent: the same API request is used for other foreground objects.

Real-world object photo before and after API background removal, shown on a transparent checkerboard
Left: source photo. Right: transparent PNG composited over a checkerboard preview.
Source object photo in a complex outdoor scene before background removal
Source Photo Download source JPG
Object isolated from a complex scene as a transparent PNG cutout
Transparent PNG Download result PNG
White object foreground mask on a black background returned by the API
Foreground Mask Download mask PNG

Ready Transparent PNG

Use flat output when your application needs the final image immediately. Set outputFormat to png and keep Layer at 0. The downloaded file is an RGBA PNG with transparency.

{
  "mode": "professional",
  "outputFormat": "png",
  "tasks": [
    {
      "Plugin": "Remove Background",
      "version": 1,
      "Layer": 0
    }
  ]
}

cURL Request

curl --location 'https://retoucher.hz.labs.retouch4.me/api/v1/retoucher/start' \
  --form 'file=@Remove_Background_Strawberries_Source.png' \
  --form 'token=YOUR_RETOUCH_TOKEN' \
  --form-string 'payload={"mode":"professional","outputFormat":"png","tasks":[{"Plugin":"Remove Background","version":1,"Layer":0}]}'

Poll /retoucher/status/{id} until state becomes completed, then download the transparent PNG:

curl --location 'https://retoucher.hz.labs.retouch4.me/api/v1/retoucher/getFile/remove-background-job-id' \
  --output remove-background-result.png

Layered ZIP With Foreground Mask

Use layered output when your editor, DAM, or backend pipeline needs the foreground mask separately. Set outputFormat to zip and Layer to 1. The ZIP contains a mask PNG named with type=mask and id=foreground.

{
  "mode": "professional",
  "outputFormat": "zip",
  "tasks": [
    {
      "Plugin": "Remove Background",
      "version": 1,
      "Layer": 1
    }
  ]
}

Layered ZIP Contents

The example archive contains this file:

index=0&blendmode=normal&name=Remove Background&type=mask&id=foreground.png

Download the example layered ZIP archive.

Parameters

Field Type Required Description
Plugin string yes Must be Remove Background.
version integer recommended Use 1 for the current Remove Background model.
Layer integer or boolean no 0 returns a flattened transparent PNG. 1 returns a ZIP archive with the foreground mask.
outputFormat string yes Use png for ready transparent PNG output, or zip for the mask archive.

Integration Notes

Background Removal API FAQ

What kinds of objects can the API cut out?

The model is designed for general foreground extraction rather than one narrow category. It can be used with products, food, clothing, accessories, furniture, props, and other clearly visible foreground subjects. Results depend on the source image, including edge visibility, occlusion, focus, and contrast with the background.

Can the API return an image with a transparent background?

Yes. Use outputFormat: "png" and Layer: 0. The result is an RGBA PNG with the detected foreground preserved and the original background made transparent.

Can I create a white-background product photo?

Yes. Request the transparent PNG or foreground mask, then composite it over white in your application. The same cutout can also be placed on a brand color, template, lifestyle image, or generated background without rerunning segmentation.

Should I request a transparent PNG or a foreground mask?

Use the transparent PNG when you need a ready image with no background. Use the layered ZIP when your editor, DAM, or backend needs the black-and-white object mask for custom compositing, review, or downstream processing.

Can I use this for bulk ecommerce background removal?

Yes. Submit one Cloud API job per source image, retain each returned job ID, poll the status endpoint, and download completed results. This makes the API suitable for catalog imports, SKU image cleanup, marketplace feeds, and scheduled DAM, PIM, or CMS processing.

Can Remove Background run with Crop or retouching plugins?

No. Remove Background must be the only item in the tasks array. Run Crop, Heal, Color Correction, or any other processing in a separate request.