The API endpoint accepts a single image or a batch. For automated processing, use the batch endpoint with 20 files per request and loop over your catalog.
A minimal Python loop that processes a directory and writes results to an output directory:
import os, requests, glob
INPUT = "input/"
OUTPUT = "output/"
API = "https://removatool.com/api/process/bulk?transparent=true&max_size=1200"
files = sorted(glob.glob(INPUT + "*.jpg"))
batch_size = 20
for i in range(0, len(files), batch_size):
batch = files[i:i+batch_size]
files_payload = [("files", (os.path.basename(f), open(f, "rb"), "image/jpeg")) for f in batch]
r = requests.post(API, files=files_payload, timeout=300)
if r.status_code == 200:
zip_path = f"{OUTPUT}batch_{i//batch_size}.zip"
with open(zip_path, "wb") as fh:
fh.write(r.content)
print(f"Wrote {zip_path}")
else:
print(f"Batch {i//batch_size} failed: {r.status_code}")
for _, (_, fh, _) in files_payload:
fh.close()
The rate limit is 30 requests per minute. Twenty files per request means 600 files per minute at full throughput. That is enough for most pipelines.
Add error handling for the 503 case. That status means the inference backend is waking up from a cold start. Retry after a short delay and the request will succeed.