PixMatteAPI

API reference

Remove background

Remove the background from one image and return the cutout.

Request

POSThttps://api.pixmatte.com/v1.0/removebg

Body: multipart/form-data. Auth: X-Api-Key header. Send exactly one image source — image_file, image_url, or image_file_b64.

Interactive OpenAPI console coming soon. Copy a sample below in the meantime.

Parameters

Image source (one required)

FieldTypeDescription
image_filefileThe image as a file upload. JPG, PNG, or WebP.
image_urlstringPublic HTTPS URL to fetch the image from. Must respond within 10 s.
image_file_b64stringThe image as a base64-encoded string, without a data: prefix.

Options

FieldTypeDefaultDescription
sizeenumautoOne of preview, full, auto. auto returns the highest resolution your plan allows.
formatenumpngOne of png, webp, jpg. jpg has no transparency and needs bg_color.
bg_colorstring—Hex color without #, e.g. ffffff. Fills the removed area.
typeenumautoSubject hint: auto, product, or person.
cropbooleanfalseCrop the output to the subject’s bounding box.
crop_marginstring0Margin around a cropped subject, in px or %, e.g. 24px or 5%.

Examples

Upload a file

curl -X POST https://api.pixmatte.com/v1.0/removebg \
  -H "X-Api-Key: $PIXMATTE_API_KEY" \
  -F "[email protected]" \
  -F "size=auto" \
  -o product-cutout.png

From a URL, WebP on white

curl
curl -X POST https://api.pixmatte.com/v1.0/removebg \
  -H "X-Api-Key: $PIXMATTE_API_KEY" \
  -F "image_url=https://example.com/product.jpg" \
  -F "format=webp" \
  -F "bg_color=ffffff" \
  -o product-cutout.webp

Response

By default a 200 returns the image as binary data with the matching Content-Type.

Response headers
HTTP/1.1 200 OK
Content-Type: image/png
X-Credits-Charged: 1
X-Width: 2048
X-Height: 2048
X-Request-Id: req_7Hc2kQ9mPz
HeaderDescription
X-Credits-ChargedCredits deducted for this request.
X-Width / X-HeightOutput dimensions in pixels.
X-Request-IdUnique request ID. Include it when contacting support.

JSON response

Send Accept: application/json to receive a base64 result with metadata instead of binary data.

curl · JSON
curl -X POST https://api.pixmatte.com/v1.0/removebg \
  -H "X-Api-Key: $PIXMATTE_API_KEY" \
  -H "Accept: application/json" \
  -F "[email protected]"

{
  "data": {
    "result_b64": "iVBORw0KGgoAAAANSUhEUgAA...",
    "width": 2048,
    "height": 2048,
    "credits_charged": 1
  }
}

Input limits

LimitValue
FormatsJPG, PNG, WebP
File sizeUp to 12 MB
ResolutionUp to 25 megapixels input. Output resolution depends on size and plan.
TimeoutRequests taking longer than 60 s return 504 and are not charged.