Segmind Gluon Serverless API
Make the shots your edit is missing: Segmind Gluon turns a clip of your scene and one line of text into a matching insert or cutaway, with the same clothes, props, light, colour and grain. For ads, social and film. Up to 1080p, in H.264, HEVC 10-bit or ProRes.
1import requests
2import time
3import json
4
5api_key = "YOUR_API_KEY"
6url = "https://api.segmind.com/workflows/v2/6ae7688bfd80737db2d9fded-v2"
7
8data = {
9 "scene_clip": "https://images.segmind.com/public/0565255e6369ae0adaca6a62c5514c0b.mp4",
10 "insert_shot": "the camera slowly pushes in as his hand picks up a freshly lit cigarette from the glass ashtray on his desk and lifts it up out of frame, smoke trailing",
11 "duration": 4,
12 "resolution": "720p",
13 "delivery": "H.264 mp4 (plays everywhere)",
14 "reference_1": [],
15 "reference_2": [],
16 "reference_3": []
17}
18
19def poll_for_result(poll_url):
20 """Poll the API until the generation is complete"""
21 while True:
22 response = requests.get(
23 poll_url,
24 headers={'x-api-key': api_key}
25 )
26 result = response.json()
27
28 if result['status'] == 'COMPLETED':
29 # Parse the output (it's a JSON string)
30 outputs = json.loads(result['output'])
31 return outputs
32 elif result['status'] == 'FAILED':
33 raise Exception(result.get('error', 'Generation failed'))
34
35 # Wait 7 seconds before polling again
36 time.sleep(7)
37
38# Make the initial request
39response = requests.post(
40 url,
41 json=data,
42 headers={
43 'x-api-key': api_key,
44 'Content-Type': 'application/json'
45 }
46)
47
48if response.status_code == 200:
49 result = response.json()
50 print('Request queued:', result)
51
52 # Start polling for results
53 outputs = poll_for_result(result['poll_url'])
54 print('Generation complete:', outputs)
55else:
56 print(f"Error: {response.status_code}")
57 print(response.text) 1import requests
2import time
3import json
4
5api_key = "YOUR_API_KEY"
6url = "https://api.segmind.com/workflows/v2/6ae7688bfd80737db2d9fded-v2"
7
8data = {
9 "scene_clip": "https://images.segmind.com/public/0565255e6369ae0adaca6a62c5514c0b.mp4",
10 "insert_shot": "the camera slowly pushes in as his hand picks up a freshly lit cigarette from the glass ashtray on his desk and lifts it up out of frame, smoke trailing",
11 "duration": 4,
12 "resolution": "720p",
13 "delivery": "H.264 mp4 (plays everywhere)",
14 "reference_1": [],
15 "reference_2": [],
16 "reference_3": []
17}
18
19def poll_for_result(poll_url):
20 """Poll the API until the generation is complete"""
21 while True:
22 response = requests.get(
23 poll_url,
24 headers={'x-api-key': api_key}
25 )
26 result = response.json()
27
28 if result['status'] == 'COMPLETED':
29 # Parse the output (it's a JSON string)
30 outputs = json.loads(result['output'])
31 return outputs
32 elif result['status'] == 'FAILED':
33 raise Exception(result.get('error', 'Generation failed'))
34
35 # Wait 7 seconds before polling again
36 time.sleep(7)
37
38# Make the initial request
39response = requests.post(
40 url,
41 json=data,
42 headers={
43 'x-api-key': api_key,
44 'Content-Type': 'application/json'
45 }
46)
47
48if response.status_code == 200:
49 result = response.json()
50 print('Request queued:', result)
51
52 # Start polling for results
53 outputs = poll_for_result(result['poll_url'])
54 print('Generation complete:', outputs)
55else:
56 print(f"Error: {response.status_code}")
57 print(response.text)API Endpoint
https://api.segmind.com/workflows/v2/6ae7688bfd80737db2d9fded-v2Parameters
scene_clipoptionalstring (uri)Scene Clip
"https://images.segmind.com/public/0565255e6369ae0adaca6a62c5514c0b.mp4"insert_shotoptionalstringInsert Shot
"the camera slowly pushes in as his hand picks up a freshly lit cigarette from the glass ashtray on his desk and lifts it up out of frame, smoke trailing"durationoptionalnumberDuration
4resolutionoptionalstringResolution
"720p"deliveryoptionalstringDelivery
"H.264 mp4 (plays everywhere)"reference_1optionalstring (uri)Reference 1
[]reference_2optionalstring (uri)Reference 2
[]reference_3optionalstring (uri)Reference 3
[]Response Format
Returns: Polling-based asynchronous response
Initial request returns a poll_url. Poll every 7 seconds until status is COMPLETED.
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
Workflow 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