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.

~8m 21s
~$3.3283
 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

POSThttps://api.segmind.com/workflows/v2/6ae7688bfd80737db2d9fded-v2

Parameters

scene_clipoptional
string (uri)

Scene Clip

Default: "https://images.segmind.com/public/0565255e6369ae0adaca6a62c5514c0b.mp4"
insert_shotoptional
string

Insert Shot

Default: "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"
durationoptional
number

Duration

Default: 4
resolutionoptional
string

Resolution

Default: "720p"
deliveryoptional
string

Delivery

Default: "H.264 mp4 (plays everywhere)"
reference_1optional
string (uri)

Reference 1

Default: []
reference_2optional
string (uri)

Reference 2

Default: []
reference_3optional
string (uri)

Reference 3

Default: []

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.

400

Bad Request

Invalid parameters or request format

401

Unauthorized

Missing or invalid API key

403

Forbidden

Insufficient permissions

404

Not Found

Workflow 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