Guide

High-Volume Background Removal API for Product Catalogs

Integrate a background removal API into your product catalog pipeline: concurrent batches, white backgrounds, square catalog images. Tested Python code.

Six product photos on mixed backgrounds, a bottle, two watches, a mug, a pen and a sneaker, turned by a batch of API calls into centered white catalog images

This tutorial uses the Background Removal API. See the docs, live demo, and pricing.

To integrate a background removal API into a product catalog pipeline, read your SKUs and image URLs from a file or database, send them to the API in parallel, and write the clean image URL back to each product. A high-volume background removal API turns thousands of vendor photos, shot on warehouse floors, kitchen tables and brick walls, into one consistent white catalog.

This guide covers the patterns that matter at catalog scale: concurrent batches, white backgrounds for marketplaces, square images with the same framing for every SKU, and a pipeline for new products. We ran every script below against the live API on 12 real product photos.

Three products before and after: a camera on a pale backdrop, a steel watch on a wooden table and a leather watch on a gray gradient, each centered on a white square
Real results from the batch run: the raw upload, then the square catalog image built from the API cutout.

What a High-Volume Background Removal API Needs

  • Both input types: image URLs for catalogs that already live online, and file uploads for photos on disk. The API takes either.
  • Parallel requests: a catalog is a batch job, so the API must handle many calls at once. Our run used 10 workers.
  • Marketplace output in one call: a white background without a second compositing step, through the /color-background endpoint.
  • Metadata for your records: every response returns the output image_url with its width, height and size_bytes.

Prerequisites

Python 3.8 or newer, a RapidAPI key for the Background Removal API, and three packages: requests, tqdm for a progress bar, and Pillow for the square catalog images:

bash
pip install requests tqdm pillow

The Single Call

Start with one image to confirm the response. The API accepts a public image URL (or a file upload in the image field) and returns a URL to the processed PNG:

python
import requests

HEADERS = {
    "x-rapidapi-key": "YOUR_API_KEY",
    "x-rapidapi-host": "background-removal-ai.p.rapidapi.com",
}

resp = requests.post(
    "https://background-removal-ai.p.rapidapi.com/remove-background",
    headers={**HEADERS, "Content-Type": "application/json"},
    json={"image_url": "https://example.com/product.jpg"},
)

result = resp.json()
print(result["image_url"])     # URL to the transparent PNG
print(result["width"], result["height"], result["size_bytes"])

Store width, height and size_bytes with the product record if your storefront needs them.

White Background for Marketplace Listings

Amazon requires a pure white background (RGB 255, 255, 255) for main listing images, and a storefront looks more professional when every product sits on the same backdrop. The /color-background endpoint removes the background and places the product on white in one call:

python
def on_white(image_url):
    """Remove the background and place the product on solid white."""
    resp = requests.post(
        "https://background-removal-ai.p.rapidapi.com/color-background",
        headers={**HEADERS, "Content-Type": "application/json"},
        json={"image_url": image_url, "bg_color": "255,255,255,255"},
    )
    return resp.json()["image_url"]

print(on_white("https://example.com/product.jpg"))

The bg_color value is R,G,B,A (each 0 to 255), so 255,255,255,255 is opaque white. Change it when a sales channel needs a brand color behind the product.

Batch a Whole Catalog Concurrently

A catalog migration is where parallel requests pay off. This script reads a CSV of SKUs and image URLs, runs 10 requests at a time, retries transient errors, and writes the results to a new CSV:

python
import csv
import requests
from concurrent.futures import ThreadPoolExecutor, as_completed
from tqdm import tqdm

HEADERS = {
    "x-rapidapi-key": "YOUR_API_KEY",
    "x-rapidapi-host": "background-removal-ai.p.rapidapi.com",
}
URL = "https://background-removal-ai.p.rapidapi.com/color-background"

def process(sku, image_url, retries=3):
    """Process one product image, retrying on transient errors."""
    for attempt in range(retries):
        try:
            r = requests.post(
                URL,
                headers={**HEADERS, "Content-Type": "application/json"},
                json={"image_url": image_url, "bg_color": "255,255,255,255"},
                timeout=30,
            )
            r.raise_for_status()
            return sku, r.json()["image_url"], None
        except Exception as e:
            if attempt == retries - 1:
                return sku, None, str(e)


# products.csv has columns: sku, image_url
with open("products.csv") as f:
    products = list(csv.DictReader(f))

results, failures = [], []
with ThreadPoolExecutor(max_workers=10) as pool:
    futures = [pool.submit(process, p["sku"], p["image_url"]) for p in products]
    # tqdm shows a live progress bar as futures complete
    for fut in tqdm(as_completed(futures), total=len(futures), desc="Removing backgrounds"):
        sku, out_url, err = fut.result()
        if err:
            failures.append((sku, err))
        else:
            results.append((sku, out_url))

print(f"Processed {len(results)} images, {len(failures)} failed")

# Write the mapping back so you can update your catalog
with open("processed.csv", "w", newline="") as f:
    w = csv.writer(f)
    w.writerow(["sku", "processed_url"])
    w.writerows(results)

We ran it exactly as shown on a CSV of 12 product photos from Pexels:

text
Removing backgrounds: 100%|██████████| 12/12 [00:25<00:00,  2.15s/it]
Processed 12 images, 0 failed

The whole run took 26 seconds. max_workers sets how many requests run at once: raise it to go faster, within your plan's rate limit. The retry loop handles transient network errors, and any SKU that still fails lands in failures so you can run it again.

Center and Square Every Product

Vendor photos frame products very differently: a small bottle in the middle of a boardwalk, a watch filling the whole frame. To give the catalog the same look on every card, take the transparent cutout, crop it to the product, and center it on a white square with the same fill ratio:

python
import io
from PIL import Image

def catalog_tile(image_url, size=1600, fill=0.85):
    """Cut out the product, then center it on a white square."""
    r = requests.post(
        "https://background-removal-ai.p.rapidapi.com/remove-background",
        headers={**HEADERS, "Content-Type": "application/json"},
        json={"image_url": image_url},
        timeout=60,
    )
    r.raise_for_status()
    png = requests.get(r.json()["image_url"], timeout=60).content
    product = Image.open(io.BytesIO(png)).convert("RGBA")
    product = product.crop(product.getchannel("A").getbbox())

    scale = size * fill / max(product.size)
    product = product.resize(
        (round(product.width * scale), round(product.height * scale)), Image.LANCZOS
    )
    tile = Image.new("RGB", (size, size), "white")
    tile.paste(product, ((size - product.width) // 2, (size - product.height) // 2), product)
    return tile

catalog_tile("https://example.com/product.jpg").save("SKU-001.jpg", quality=92)

The alpha channel of the cutout gives the exact bounding box of the product, so the crop needs no tuning. With fill=0.85, the longest side of every product covers 85% of the square. All 12 products of our run came out centered on 1600 x 1600 white squares, ready for a product grid. For apparel photographed by users at home, the clothing background removal tutorial applies the same idea to closet tiles and adds automatic color tags.

Keep a Pipeline Running for New Products

A catalog grows every week. Call the same function when a new product image arrives, so background removal becomes an automatic step of the product lifecycle:

python
def ingest_new_product(sku, raw_image_url):
    """Called when a new product image lands (webhook, queue, cron)."""
    _, clean_url, err = process(sku, raw_image_url)
    if err:
        enqueue_for_retry(sku, raw_image_url)   # your retry queue
        return False
    save_to_catalog(sku, clean_url)             # your DB write
    return True

Wire ingest_new_product to a webhook from your PIM, a message queue, or a nightly cron over a staging folder.

Production Tips

  • Test on a sample first: run 20 products from your own catalog, check the results, then process the full list.
  • Make runs resumable: skip SKUs already present in processed.csv, so a restarted job only sends what is left.
  • Keep the files with your catalog: download each result into your own media storage or CDN, next to the SKU, so the storefront serves every image from one place.
  • Use other backgrounds for marketing: the same API has /blur-background and /gradient-background for ads and social posts. See how to remove image backgrounds with an API for every mode, and the transparent background PNG guide.

When a Cloud API Beats Self-Hosting at Scale

Open-source models like rembg are free and fine for low volume. At catalog scale the calculus changes:

  • Consistent quality on messy input. Vendor photos vary wildly. A managed API holds quality across hair, fur, reflective metal and busy backgrounds where lighter models struggle.
  • No GPU fleet to operate. High throughput from a self-hosted model means GPUs, autoscaling, and on-call. The API absorbs that.
  • One pipeline to monitor. Retries, rate limits, and a single output format, instead of a model deployment you maintain.

For a measured comparison of the open-source route, read rembg vs Cloud API. To compare commercial providers, see the best background removal APIs comparison and our Photoroom API alternative guide.

Getting Started

Grab a key from the Background Removal API page, put it in the batch script, point it at a CSV of your SKUs and image URLs, and run it on a sample of 20 products. Then raise the worker count and process the full catalog. A free tier is available to test on your own product photos.

Sources

Frequently Asked Questions

What background removal API handles high-volume image processing?
The AI Engine Background Removal API is built for batch work: it accepts an image URL or a file upload, returns the result as a URL with its width, height and size, and has dedicated endpoints for white, colored, blurred and gradient backgrounds. In our test, 10 parallel workers processed 12 product photos in 26 seconds with no failed request.
How many product images can I process per day?
Throughput depends on how many requests you run in parallel and on your plan's volume. At the rate we measured (12 images in 26 seconds with 10 workers), one machine processes tens of thousands of images a day. Add workers to go faster, within your plan's rate limit.
Can I get a white background instead of a transparent one for marketplace listings?
Yes. The /color-background endpoint removes the original background and places the product on a solid color in one call. Pass bg_color as R,G,B,A values: 255,255,255,255 is opaque white, which is what marketplaces like Amazon require for main images.
How do I make every product the same size in the catalog?
Use the transparent cutout from /remove-background, crop it to the product with Pillow (the alpha channel gives the exact bounding box), then paste it centered on a white square with the same fill ratio for every SKU. The catalog_tile function in this guide does it in about 20 lines.

Ready to Try Background Removal?

Check out the full API documentation, live demos, and code samples on the Background Removal spotlight page.

Related Articles

Continue learning with these related guides and tutorials.