POST
/
segment-anything-2

The default Gateway used in this guide is the public Livepeer.cloud Gateway. It is free to use but not intended for production-ready applications. For production-ready applications, consider using the Livepeer Studio Gateway, which requires an API token. Alternatively, you can set up your own Gateway node or partner with one via the ai-video channel on Discord.

Please note that the exact parameters, default values, and responses may vary between models. For more information on model-specific parameters, please refer to the respective model documentation available in the segment-anything-2 pipeline. Not all parameters might be available for a given model.

Authorizations

Authorization
string
headerrequired

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

multipart/form-data
image
file
required

Image to segment.

model_id
string
default: required

Hugging Face model ID used for image generation.

point_coords
string

Nx2 array of point prompts to the model, where each point is in (X,Y) in pixels.

point_labels
string

Labels for the point prompts, where 1 indicates a foreground point and 0 indicates a background point.

box
string

A length 4 array given as a box prompt to the model, in XYXY format.

mask_input
string

A low-resolution mask input to the model, typically from a previous prediction iteration, with the form 1xHxW (H=W=256 for SAM).

multimask_output
boolean
default: true

If true, the model will return three masks for ambiguous input prompts, often producing better masks than a single prediction.

return_logits
boolean
default: true

If true, returns un-thresholded mask logits instead of a binary mask.

normalize_coords
boolean
default: true

If true, the point coordinates will be normalized to the range [0,1], with point_coords expected to be with respect to image dimensions.

Response

200 - application/json

Response model for object segmentation.

masks
string
required

The generated masks.

scores
string
required

The model's confidence scores for each generated mask.

logits
string
required

The raw, unnormalized predictions (logits) for the masks.