API reference/POST /remove

Remove background

Upload an image and get back a transparent PNG or WebP. Edges are cleaned via closed-form foreground matting — no halos, no fringing.

POSThttps://useknockout--api.modal.run/remove

Parameters

Send as multipart/form-data unless noted otherwise.

filerequiredfileImage to process. JPG, PNG, WebP, HEIC. Up to 10 MB and 4096×4096.
formatstringpngOutput format — png (with alpha) or webp.
qualityint 1-10092JPEG/WebP quality. Ignored for PNG.
mattingstringclosed-formEdge cleanup algorithm. Options: closed-form, none.

Request

curl -X POST "https://useknockout--api.modal.run/remove" \
  -H "Authorization: Bearer $TOKEN" \
  -F "file=@cat.jpg" \
  -F "format=png" \
  -o out.png

Response

HTTP/1.1 200 OK
content-type: image/png
content-length: 254312
x-knockout-latency: 184
x-knockout-model: BiRefNet
x-ratelimit-limit: 60
x-ratelimit-remaining: 59

Errors

401unauthorizedMissing or invalid token.
402payment_requiredFree tier exhausted. Add a card to continue.
413payload_too_largeImage exceeds 10 MB or 4096×4096.
422no_subject_detectedForeground could not be isolated from background.
429rate_limit_exceededSlow down. Retry-After header tells you when.
500internal_errorSomething broke on our side. Include request_id when reporting.
Every error response also includes a request_id in the JSON body. Quote it when reporting issues.

Notes

  • The model runs on a Modal L4 GPU. Cold starts add ~3 seconds.
  • Images are processed in-memory and discarded after the response is returned.
  • For batch workflows, fan out with Promise.all in Node or asyncio.gather in Python — or use /remove-batch.