Sam V2 Video

SAM v2 Video by Meta AI, allows promptable segmentation of objects in videos.

~37.56s
~$0.057
 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

POSThttps://api.segmind.com/v1/sam-v2-video

Parameters

input_videorequired
string (uri)

Input video

Default: "https://segmind-resources.s3.amazonaws.com/input/650fd563-ca86-4c29-8bce-165b6e23bd41-couple_dance.mp4"
overlay_maskrequired
boolean

Whether to overlay a mask on the video

Default: true
promptrequired
string

Text prompt for processing the video

Default: "man"
coordinatesoptional
string

Coordinates 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], ...].

Default: null
remove_coordinatesoptional
string

Coordinates to be removed (optional), format is similar to Coordinates

Default: null

Response Type

Returns: Video

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