StableSAM Docs

StableSAM is an API-first service for SAM 3.1 video and image segmentation, plus SAM 3 single-image human body reconstruction. Video and image segmentation use Meta SAM 3.1 with Object Multiplex for faster multi-object tracking; the 3D body route uses SAM 3 because no SAM 3.1 3D-body endpoint exists yet.

Workflow

  1. Upload the source asset to StableUpload.
  2. For video segmentation, inspect the local file and compute frame count.
  3. POST the StableUpload URL to the matching StableSAM route.
  4. Poll /api/jobs/{jobId} with SIWX until complete.

Prompting

Limits

Video compositing guidance

Create a transparent subject video

ffmpeg -i input.mp4 -i mask.mp4 \
  -filter_complex "[1:v]format=gray[mask];[0:v][mask]alphamerge,format=yuva420p" \
  -an -c:v libvpx-vp9 -pix_fmt yuva420p subject-alpha.webm

Composite onto a background video

ffmpeg -i background.mp4 -i subject-alpha.webm \
  -filter_complex "[0:v][1:v]overlay=shortest=1:format=auto" \
  -c:v libx264 -pix_fmt yuv420p composited.mp4

Pricing

Endpoints

Example requests

Video segmentation

{
  "type": "sam-3-video-segment",
  "videoUrl": "https://f.stableupload.dev/abc123/clip.mp4",
  "declaredFrameCount": 320,
  "prompt": "person",
  "applyMask": true,
  "videoOutputType": "mp4",
  "detectionThreshold": 0.5
}

Image segmentation

{
  "type": "sam-3-image-segment",
  "imageUrl": "https://f.stableupload.dev/abc123/photo.jpg",
  "prompt": "person",
  "applyMask": true
}

3D body reconstruction

{
  "type": "sam-3-body-3d",
  "imageUrl": "https://f.stableupload.dev/abc123/person.jpg"
}