Sam3 Image

SAM3 enables precise object segmentation and tracking in images and videos using natural language and visual prompts.

~4.67s
~$0.005
 1import requests
 2import json
 3
 4url = "https://api.segmind.com/v1/sam3-image"
 5headers = {
 6    "x-api-key": "YOUR_API_KEY",
 7    "Content-Type": "application/json"
 8}
 9
10data = {
11    "image": "https://segmind-resources.s3.amazonaws.com/input/6faa9243-e250-424b-b1b9-c5f1e5e93ab9-sample1.jpg",
12    "text_prompt": "plants",
13    "point_labels_input": "[[1]]",
14    "return_preview": true,
15    "return_overlay": false,
16    "return_masks": false,
17    "threshold": 0.5,
18    "points_per_side": 32,
19    "pred_iou_thresh": 0.88,
20    "max_masks": 0
21}
22
23response = requests.post(url, headers=headers, json=data)
24
25if response.status_code == 200:
26    result = response.json()
27    print(json.dumps(result, indent=2))
28else:
29    print(f"Error: {response.status_code}")
30    print(response.text)

API Endpoint

POSThttps://api.segmind.com/v1/sam3-image

Parameters

imagerequired
string (uri)

Input image URL or base64 string. Use high-resolution images for better accuracy.

boxes_inputoptional
string

Bounding box to specify the type of objects to segment. ex: [[100, 150, 200, 250]]

Default: null
max_masksoptional
integer

Limit number of masks returned. 0 for no limit.

Default: 0Range: 0 - 100
point_labels_inputoptional
string

Labels for each point: 1=foreground, 0=background. Helps refine model predictions.

Default: "[[1]]"
points_inputoptional
string

Point coordinates to specify the object for segmentation, ex: [[300, 400]] or [[150, 200], [300, 400]] for multiple points

Default: null
points_per_sideoptional
integer

Density for automatic mask creation. Use higher values for finer details.

Default: 32Range: 0 - 128
pred_iou_threshoptional
number

Set IoU score filter. Higher for stricter quality.

Default: 0.88Range: 0.5 - 1
return_masksoptional
boolean

Return each mask separately

Default: false
return_overlayoptional
boolean

Get overlays on input image. Useful for visual assessments

Default: false
return_previewoptional
boolean

Get combined preview mask. Useful for quick results checks.

Default: true
text_promptoptional
string

Optional text prompt to guide model focus. Examples: 'animal', 'plant'.

Default: null
thresholdoptional
number

Adjust confidence threshold for detection. Use 0.5 for balanced results.

Default: 0.5Range: 0.1 - 1

Response Type

Returns: Image

Common Error Codes

The API returns standard HTTP status codes. Detailed error messages are provided in the response body.

400

Bad Request

Invalid parameters or request format

401

Unauthorized

Missing or invalid API key

403

Forbidden

Insufficient permissions

404

Not Found

Model or endpoint not found

406

Insufficient Credits

Not enough credits to process request

429

Rate Limited

Too many requests

500

Server Error

Internal server error

502

Bad Gateway

Service temporarily unavailable

504

Timeout

Request timed out