Sam V2 Video
SAM v2 Video by Meta AI, allows promptable segmentation of objects in videos.
1import requests
2import json
3
4url = "https://api.segmind.com/v1/sam-v2-video"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "input_video": "https://segmind-resources.s3.amazonaws.com/input/650fd563-ca86-4c29-8bce-165b6e23bd41-couple_dance.mp4",
12 "prompt": "man",
13 "overlay_mask": true
14}
15
16response = requests.post(url, headers=headers, json=data)
17
18if response.status_code == 200:
19 result = response.json()
20 print(json.dumps(result, indent=2))
21else:
22 print(f"Error: {response.status_code}")
23 print(response.text) 1import requests
2import json
3
4url = "https://api.segmind.com/v1/sam-v2-video"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "input_video": "https://segmind-resources.s3.amazonaws.com/input/650fd563-ca86-4c29-8bce-165b6e23bd41-couple_dance.mp4",
12 "prompt": "man",
13 "overlay_mask": true
14}
15
16response = requests.post(url, headers=headers, json=data)
17
18if response.status_code == 200:
19 result = response.json()
20 print(json.dumps(result, indent=2))
21else:
22 print(f"Error: {response.status_code}")
23 print(response.text)API Endpoint
https://api.segmind.com/v1/sam-v2-videoParameters
input_videorequiredstring (uri)Input video
"https://segmind-resources.s3.amazonaws.com/input/650fd563-ca86-4c29-8bce-165b6e23bd41-couple_dance.mp4"overlay_maskrequiredbooleanWhether to overlay a mask on the video
truepromptrequiredstringText prompt for processing the video
"man"coordinatesoptionalstringCoordinates for image selection (optional): Provide either a prompt or coordinates. If a prompt is provided, coordinates will be ignored. For a single coordinate, use the format [834,74]. For multiple coordinates, use [[839,74], [844,20], ...].
nullremove_coordinatesoptionalstringCoordinates to be removed (optional), format is similar to Coordinates
nullResponse Type
Returns: Video
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