Developers

Background Removal API

Send one JPEG, PNG, or WebP image and receive a transparent PNG. The API uses PurgeAI HD and charges 1 credit only when processing succeeds. New keys are shown once and stored as one-way fingerprints.

Quick start

curl -X POST https://purgebg.com/api/v1/remove-background \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "image=@product.jpg" \
  --output product-no-bg.png

Request

POST /api/v1/remove-background with an Authorization: Bearer … header and a multipart field named image. Maximum file size is 5 MB. Supported types are JPEG, PNG, and WebP.

Response and errors

A successful request returns the PNG bytes with HTTP 200 and x-purgebg-credits-used: 1. Errors use JSON in the form {"error":{"code":"…","message":"…"}}.

  • 401: missing or invalid API key
  • 402: insufficient credits
  • 413: image exceeds 5 MB
  • 415: unsupported or invalid image data
  • 429: requests are arriving too quickly
  • 502: processing failed; the reserved credit is returned

Usage rules

Keep API keys on your server, never expose them in browser code, and revoke a key immediately if it is leaked. Requests must comply with the Purgebg Terms of Service, including the prohibition on NSFW and sexually explicit content.