Model API

Segment Anything 2

SAM 2 is a model for segmenting images and videos in real-time.

Model id

Use this in every request
sam2/image

Run it

Quote the input, start the generation with the quote, then poll the job. Set RAYWAKE_API_KEY first; see Authentication.

# 1. Price the exact input (quotes are valid for up to 10 minutes)
curl -s https://api.raywake.com/v1/quotes \
  -H "Authorization: Bearer $RAYWAKE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "sam2/image",
  "input": {
    "image_url": "https://example.com/input.png"
  }
}'

# 2. Start the generation with the quote_id from step 1
curl -s https://api.raywake.com/v1/generate \
  -H "Authorization: Bearer $RAYWAKE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"model": "sam2/image", "quote_id": "QUOTE_ID", "input": {"image_url":"https://example.com/input.png"}}'

# 3. Poll until the status is terminal
curl -s https://api.raywake.com/v1/jobs/JOB_ID \
  -H "Authorization: Bearer $RAYWAKE_API_KEY"

Input

Input fields for sam2/image
NameTypeDescription
image_urlrequiredstring (image URL)
URL of the image to be segmented
promptsarray of objects
List of prompts to segment the image
box_promptsarray of objects
Coordinates for boxes
apply_maskboolean
Apply the mask on the image.

Default: false

sync_modeboolean
If `True`, the media will be returned as a data URI and the output data won't be available in the request history.

Default: false

output_formatstring (enum)
The format of the generated image.

Default: png

One of: jpeg, png, webp

Output

A succeeded job lists its results under outputs, stored on our side. See Jobs for every field.

Job excerpt
"outputs": [
  { "type": "image", "url": "https://…", "mime_type": "image/png", "thumbnail_url": "https://…" }
]

Pricing

  • up to$0.53/ run

The exact charge for your input comes from a quote. How charges settle