Sam3 Video API Documentation

Sam3 Video API Documentation

Playground

Try it on WaveSpeedAI!

SAM3 Video is a unified foundation model for prompt-based video segmentation. Provide text, point, box, or mask prompts and the model segments and tracks targets across frames with strong temporal consistency. Supports concept-level (“segment anything with concepts”) and multi-object masks for editing, analytics, and VFX. Ready-to-use REST inference API with fast response, no cold starts, and affordable pricing.

Features

WaveSpeedAI SAM3 Video Video-to-Video is a prompt-based video segmentation and mask-guided editing model. Provide a video and a short text prompt to target specific subjects across frames, then choose whether to apply the mask to the video output or return a mask-style result for downstream workflows.


Why Choose This?

  • Prompt-based target selection
    Use natural language to identify the subject or object to segment, such as person, woman, red car, or backpack.

  • Multi-object targeting
    Target multiple objects in one request by listing them in the prompt.

  • Mask-guided video output
    Use apply_mask to control whether the detected mask is applied to the video or returned as a mask-style output.

  • Temporal video consistency
    Track selected subjects across frames for more stable video segmentation workflows.

  • Editing and compositing workflows
    Prepare masks or localized video outputs for object removal, background cleanup, subject isolation, and downstream compositing.


Parameters

ParameterRequiredDescription
videoYesInput video file or public video URL.
promptYesText prompt describing the subject or object to target. Use short, concrete labels such as person, car, or dog.
apply_maskNoWhether to apply the mask to the video output. Default: true. When disabled, the output is a mask-style video: the background is black and the selected region is white.

How to Use

  1. Upload a video — Provide the source video you want to process.
  2. Write a target prompt — Describe the subject or object to segment, such as the woman, red car, or person, backpack.
  3. Choose mask behavior — Keep apply_mask enabled to apply the mask to the video output. Disable it when you need a black-and-white mask-style output.
  4. Submit — Generate the processed video result.

Pricing

Pricing is based on input video duration.

Billed duration is rounded up to the next whole second, with a minimum billed duration of 3 seconds and a maximum billed duration of 600 seconds. Pricing is charged in 5-second units at $0.05 per 5 seconds.

Billed DurationCost
3s$0.03
5s$0.05
10s$0.10
60s$0.60
600s$6.00

prompt and apply_mask do not add separate charges.


Best Use Cases

  • Video segmentation — Segment people, objects, animals, clothing, vehicles, or other visible subjects across frames.
  • Subject isolation — Isolate a target subject for compositing or downstream editing.
  • Mask generation — Create black-and-white mask-style video outputs for external editing pipelines.
  • Object-focused editing — Prepare localized regions for removal, cleanup, or replacement workflows.
  • Background cleanup — Target foreground subjects or unwanted background objects with prompt guidance.
  • Multi-target workflows — Segment multiple objects in one run when the prompt clearly identifies each target.

Pro Tips

  • Use short, concrete target descriptions for better segmentation.
  • For multiple objects, use comma-separated labels such as person, backpack, bicycle.
  • Keep the prompt focused on what should be targeted.
  • Use apply_mask=true when you want the mask applied to the video output.
  • Use apply_mask=false when you need a black-background mask output with the selected region shown in white.
  • Use stable footage with clear subject separation for better results.
  • Reduce the number of targets if the model selects the wrong object or drifts across frames.

Notes

  • video and prompt are required.
  • apply_mask defaults to true.
  • When apply_mask is disabled, the output is a mask-style video with a black background and the selected region in white.
  • Billed duration is rounded up and clamped to 3–600 seconds.
  • Very short videos are billed as 3 seconds.
  • Videos longer than 600 seconds are billed at the 600-second cap.

Authentication

For authentication details, please refer to the Authentication Guide.

API Endpoints

Submit Task & Query Result

set -euo pipefail

export WAVESPEED_API_KEY="your-api-key"

REQUEST_BODY=$(cat <<'JSON'
{
  "prompt": "A cinematic ocean wave at sunrise, highly detailed",
  "video": "https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4",
  "apply_mask": true
}
JSON
)

# 1. Submit the prediction.
SUBMIT_RESPONSE=$(curl --silent --show-error --fail-with-body \
  -X POST "https://api.wavespeed.ai/api/v3/wavespeed-ai/sam3-video" \
  -H "Authorization: Bearer ${WAVESPEED_API_KEY}" \
  -H "Content-Type: application/json" \
  -d "${REQUEST_BODY}")

TASK=$(printf '%s' "${SUBMIT_RESPONSE}" | jq 'if type == "object" and has("data") then .data else . end')
PREDICTION_ID=$(printf '%s' "${TASK}" | jq -r '.id // empty')
if [ -z "${PREDICTION_ID}" ]; then
  printf 'Submission response did not contain a prediction id
' >&2
  exit 1
fi
RESULT_URL="https://api.wavespeed.ai/api/v3/predictions/${PREDICTION_ID}/result"

# 2. Poll until the prediction finishes.
while true; do
  RESPONSE=$(curl --silent --show-error --fail-with-body \
    "${RESULT_URL}" \
    -H "Authorization: Bearer ${WAVESPEED_API_KEY}")
  RESULT=$(printf '%s' "${RESPONSE}" | jq 'if type == "object" and has("data") then .data else . end')
  STATUS=$(printf '%s' "${RESULT}" | jq -r '.status // empty')

  case "${STATUS}" in
    completed) printf '%s\n' "${RESULT}" | jq '.outputs'; break ;;
    failed|cancelled|timeout|deleted) printf '%s\n' "${RESULT}" | jq . >&2; exit 1 ;;
    *) sleep 2 ;;
  esac
done

Parameters

Task Submission Parameters

Request Parameters

ParameterTypeRequiredDefaultRangeDescription
promptstringYes-Text prompt for segmentation. Use commas to track multiple objects (e.g., 'person, cloth').
videostringYes-Video URL for segmented
apply_maskbooleanNotrue-Whether to apply mask to video

Response Parameters

ParameterTypeDescription
codeintegerHTTP status code (e.g., 200 for success)
messagestringStatus message (e.g., “success”)
data.idstringUnique identifier for the prediction, Task Id
data.modelstringModel ID used for the prediction
data.outputsarrayOutput values, usually URL strings; some models return text strings or structured result objects (empty when status is not completed)
data.urlsobjectObject containing related API endpoints
data.statusstringTask status. completed is successful; failed, cancelled, timeout, and deleted are failure terminal statuses.
data.created_atstringISO timestamp of when the request was created (e.g., “2023-04-01T12:34:56.789Z”)
data.errorstringError message (empty if no error occurred)
data.timingsobjectObject containing timing details
data.timings.inferenceintegerInference time in milliseconds

Result Request Parameters

ParameterTypeRequiredDefaultDescription
idstringYes-Task ID

Result Response Parameters

ParameterTypeDescription
codeintegerHTTP status code (e.g., 200 for success)
messagestringStatus message (e.g., “success”)
dataobjectThe prediction data object containing all details
data.idstringUnique identifier for the prediction
data.modelstringModel ID used for the prediction
data.outputsarray<string | object>Array of generated outputs (empty when status is not completed). Items are usually URL strings, but may be text strings or structured result objects, depending on the model.
data.urlsobjectObject containing related API endpoints
data.statusstringStatus: completed is successful; failed, cancelled, timeout, and deleted are failure terminal statuses
data.created_atstringISO timestamp of when the request was created
data.errorstringError message (empty if no error occurred)
data.timingsobjectObject containing timing details
data.timings.inferenceintegerInference time in milliseconds
© 2026 WaveSpeedAI. All rights reserved.