@avclabs.ai/media-mcp
Node.js >=18 · MIT License
Image Segmentation (SAM3)
<>sam3_predictSAM3 image segmentation (supports local path, URL, or Base64 image)
Use SAM3 segmentation API to analyze images and generate inference results (masks, boxes, scores).
Input options
| Parameter | Type | Required | Description |
|---|---|---|---|
| imagePath | string | No | Absolute path to local image. Supports common formats (PNG, JPG, JPEG) |
| imageUrl | string | No | Publicly accessible image URL. Must be publicly accessible, does not support links requiring login or signature |
| imageBase64 | string | No | Base64 encoded image data. Large images will have large base64 data, transfer may take longer |
| prompt | string | Yes | English text prompt specifying the target object to segment in the image. SAM3 model only accepts English prompts |
Returns:
| Field | Type | Description |
|---|---|---|
| masks | array | 2D array. Each element is a binary mask (values 0 or 1) with the same dimensions as the input image, marking the pixel-level position of detected objects in the image. The i-th mask in the array corresponds to the i-th detected object instance. |
| boxes | array | 2D array. Each element is a bounding box coordinate in [x1, y1, x2, y2] format, representing the rectangular region of detected objects in the image. Coordinate system: origin (0, 0) at top-left of image, x-axis grows right, y-axis grows down, units in pixels. |
| scores | array | 1D array. Each element is the confidence score for the corresponding detection result, ranging from 0 to 1. Higher scores indicate greater model confidence. |
Request Example
json
{
"imagePath": "/home/user/images/cat.jpg",
"prompt": "find all cats"
}Response Example
json
{
"masks": [
[[0, 0, 1, ...], [0, 1, 1, ...], ...],
[[0, 0, 0, ...], [0, 0, 1, ...], ...]
],
"boxes": [
[120, 80, 300, 450],
[400, 200, 600, 500]
],
"scores": [0.95, 0.87]
}Truncated return example (not completed within 50s)
json
{
"success": true,
"status": "processing",
"task_id": "xxx",
"message": "Task is still processing (waited about 50 seconds). Please retry later or record this task_id for manual follow-up.",
"note": "The synchronous wait for this long-running task has been truncated."
}FAQ → FAQ
