Sam3 Image Rle

Sam3 Image Rle

Playground

Try it on WaveSpeedAI!

SAM 3 RLE is a unified foundation model for promptable image segmentation using text, points, or boxes to detect and segment objects. Returns RLE (Run-Length Encoding) encoded masks for efficient storage and processing. Ready-to-use REST inference API, best performance, no coldstarts, affordable pricing.

Features

SAM3 Image Segmentation RLE is an advanced image segmentation model based on Meta’s Segment Anything Model 3. It returns segmentation masks in RLE (Run-Length Encoding) format — a compact, program-friendly output ideal for API integration, automated pipelines, and machine learning workflows.


Why Choose This?

  • RLE output format Returns compact Run-Length Encoded mask data instead of image files — smaller payload, faster transfer.

  • Multiple prompt types Segment objects using text prompts, point prompts, box prompts, or any combination.

  • API-optimized Designed for programmatic use, batch processing, and automated workflows.

  • COCO-compatible RLE format is directly compatible with COCO dataset tools and annotation pipelines.

  • Prompt Enhancer Built-in tool to automatically improve your text prompts for better results.

  • Ultra-affordable Just $0.005 per image for professional-quality segmentation.


Parameters

ParameterRequiredDescription
imageYesSource image to segment (upload or URL)
promptNo*Text description of the object to segment
point_promptsNo*Point coordinates to identify the target object
box_promptsNo*Bounding box coordinates to identify the target object
apply_maskNoOverlay the segmentation mask on the original image

*At least one prompt type (text, boxes, or points) must be provided.


How to Use

  1. Upload your image — drag and drop or paste a URL.
  2. Add prompts — provide at least one of the following:
  • Text prompt — describe the object to segment (e.g., “the man”, “the dog”).
  • Point prompts — click ”+ Add Item” to add point coordinates.
  • Box prompts — click ”+ Add Item” to add bounding box coordinates.
  1. Enable apply_mask (optional) — check to include mask overlay data.
  2. Run — submit and receive RLE-encoded segmentation data.

Output Format

The model returns RLE (Run-Length Encoding) data in JSON format:

{
 "rle": "146301 3 147834 11 149368 14 150903 16..."
}

Decoding RLE in Python

from pycocotools import mask as mask_utils
 
rle_data = {"counts": "146301 3 147834 11...", "size": [height, width]}
binary_mask = mask_utils.decode(rle_data) # Returns numpy array

Pricing

ItemCost
Per image$0.005

Simple flat-rate pricing regardless of image size or prompt complexity.


Best Use Cases

  • ML Data Annotation — Generate segmentation masks for training datasets in COCO format.
  • Automated Pipelines — Integrate segmentation into batch processing workflows.
  • API Integration — Compact output for efficient API responses.
  • Computer Vision — Programmatic mask processing for CV applications.
  • Background Removal at Scale — Extract masks for automated image processing.

Pro Tips

  • Use this model when you need programmatic access to mask data.
  • Use SAM3 Image if you need direct image output.
  • RLE format is compatible with pycocotools for easy decoding.
  • Combine multiple prompt types for more accurate segmentation.
  • Text prompts work best for common objects with clear descriptions.

Notes

  • At least one prompt type must be provided (text, points, or boxes).
  • Output is RLE-encoded JSON, not an image file.
  • Use pycocotools or similar libraries to decode RLE data.
  • Ideal for automated and batch processing workflows.

  • SAM3 Image — Same segmentation with direct image output.
  • Bria RMBG — Background removal model.

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'
{
  "image": "https://interactive-examples.mdn.mozilla.net/media/cc0-images/painted-hand-298-332.jpg",
  "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-image-rle" \
  -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=$(printf '%s' "${TASK}" | jq -r '.urls.get // empty')
if [ -z "${RESULT_URL}" ]; then RESULT_URL="https://api.wavespeed.ai/api/v3/predictions/${PREDICTION_ID}/result"; fi

# 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) printf '%s\n' "${RESULT}" | jq . >&2; exit 1 ;;
    created|processing) sleep 2 ;;
    *) printf 'Unexpected status: %s
' "${STATUS}" >&2; exit 1 ;;
  esac
done

Parameters

Task Submission Parameters

Request Parameters

ParameterTypeRequiredDefaultRangeDescription
imagestringYes-URL of the image to segment and analyze
promptstringNo-Text description to guide which objects or regions to segment
point_promptsarray<object>No-0 ~ 1000 itemsList of point coordinates to mark specific locations for segmentation (foreground or background)
box_promptsarray<object>No-0 ~ 1000 itemsList of bounding boxes to define rectangular regions for segmentation
apply_maskbooleanNotrue-Whether to overlay the segmentation mask on the original image
enable_sync_modebooleanNofalse-If set to `true`, the request attempts to wait for the generated result and return outputs in the same response. If the result is not ready within the sync wait window, the API can return a timeout body while the task continues processing. This option is only available via the API and is supported only by some models.

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.urls.getstringURL to retrieve the prediction result
data.statusstringStatus of the task: created, processing, completed, or failed
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.urls.getstringURL to poll for the prediction result
data.statusstringStatus: created, processing, completed, or failed
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.