Sam3 Image
SAM3 enables precise object segmentation and tracking in images and videos using natural language and visual prompts.
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) 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
https://api.segmind.com/v1/sam3-imageParameters
imagerequiredstring (uri)Input image URL or base64 string. Use high-resolution images for better accuracy.
boxes_inputoptionalstringBounding box to specify the type of objects to segment. ex: [[100, 150, 200, 250]]
nullmax_masksoptionalintegerLimit number of masks returned. 0 for no limit.
0Range: 0 - 100point_labels_inputoptionalstringLabels for each point: 1=foreground, 0=background. Helps refine model predictions.
"[[1]]"points_inputoptionalstringPoint coordinates to specify the object for segmentation, ex: [[300, 400]] or [[150, 200], [300, 400]] for multiple points
nullpoints_per_sideoptionalintegerDensity for automatic mask creation. Use higher values for finer details.
32Range: 0 - 128pred_iou_threshoptionalnumberSet IoU score filter. Higher for stricter quality.
0.88Range: 0.5 - 1return_masksoptionalbooleanReturn each mask separately
falsereturn_overlayoptionalbooleanGet overlays on input image. Useful for visual assessments
falsereturn_previewoptionalbooleanGet combined preview mask. Useful for quick results checks.
truetext_promptoptionalstringOptional text prompt to guide model focus. Examples: 'animal', 'plant'.
nullthresholdoptionalnumberAdjust confidence threshold for detection. Use 0.5 for balanced results.
0.5Range: 0.1 - 1Response Type
Returns: Image
Common Error Codes
The API returns standard HTTP status codes. Detailed error messages are provided in the response body.
Bad Request
Invalid parameters or request format
Unauthorized
Missing or invalid API key
Forbidden
Insufficient permissions
Not Found
Model or endpoint not found
Insufficient Credits
Not enough credits to process request
Rate Limited
Too many requests
Server Error
Internal server error
Bad Gateway
Service temporarily unavailable
Timeout
Request timed out