CommonCompute
Get startedExplore workloads
Available workloads

Background removal

Background removal (mlx_bgremove) cuts the subject out of one photo with BiRefNet and returns a PNG with an alpha channel at the input's size. It has its own endpoint instead of /v1/jobs: upload the image with POST /v1/uploads, then send the upload_id to POST /v1/images/background-removal with an API key. Inputs up to 50 MiB and 36 megapixels; $0.018 per image.

bash
UPLOAD=$(curl -s -X POST "https://api.commoncompute.ai/v1/uploads?filename=photo.jpg" \
  -H "Authorization: Bearer $CC_API_KEY" -H "X-CC-Upload: 1" \
  -H "Content-Type: image/jpeg" --data-binary @photo.jpg | jq -r .upload_id)

curl -s -X POST https://api.commoncompute.ai/v1/images/background-removal \
  -H "Authorization: Bearer $CC_API_KEY" -H "Content-Type: application/json" \
  -d "{\"upload_id\": \"$UPLOAD\", \"data_class\": \"public\", \"marketplace_execution_risk_acknowledged\": true}" \
  -o cutout.png