Segmind First Magnitude Serverless API

Turn one product photo into a finished social commercial. Segmind First Magnitude writes and films three shots with music, keeps your product true to the photo and ends on a branded end card, in 9:16, 1:1 or 16:9.

~11m
~$4.2074
 1import requests
 2import time
 3import json
 4
 5api_key = "YOUR_API_KEY"
 6url = "https://api.segmind.com/workflows/v2/6b03d839984df6ef596530ec-v2"
 7
 8data = {
 9    "product_photo": "https://images.segmind.com/public/45aa9d58268673d3dcfd9069e8a7a93a.jpeg",
10    "product_name": "BRISA sparkling yuzu soda",
11    "brief": "Summer launch for Gen Z. Ice cold, zesty, low sugar. Rooftop pool at golden hour, playful and bright.",
12    "call_to_action": "Now in stores. Grab yours.",
13    "shape": "9:16",
14    "length": "12",
15    "quality": "Standard (720p)"
16}
17
18def poll_for_result(poll_url):
19    """Poll the API until the generation is complete"""
20    while True:
21        response = requests.get(
22            poll_url,
23            headers={'x-api-key': api_key}
24        )
25        result = response.json()
26
27        if result['status'] == 'COMPLETED':
28            # Parse the output (it's a JSON string)
29            outputs = json.loads(result['output'])
30            return outputs
31        elif result['status'] == 'FAILED':
32            raise Exception(result.get('error', 'Generation failed'))
33
34        # Wait 7 seconds before polling again
35        time.sleep(7)
36
37# Make the initial request
38response = requests.post(
39    url,
40    json=data,
41    headers={
42        'x-api-key': api_key,
43        'Content-Type': 'application/json'
44    }
45)
46
47if response.status_code == 200:
48    result = response.json()
49    print('Request queued:', result)
50
51    # Start polling for results
52    outputs = poll_for_result(result['poll_url'])
53    print('Generation complete:', outputs)
54else:
55    print(f"Error: {response.status_code}")
56    print(response.text)

API Endpoint

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

Parameters

product_photooptional
string (uri)

Product Photo

Default: "https://images.segmind.com/public/45aa9d58268673d3dcfd9069e8a7a93a.jpeg"
product_nameoptional
string

Product Name

Default: "BRISA sparkling yuzu soda"
briefoptional
string

Brief

Default: "Summer launch for Gen Z. Ice cold, zesty, low sugar. Rooftop pool at golden hour, playful and bright."
call_to_actionoptional
string

Call To Action

Default: "Now in stores. Grab yours."
shapeoptional
string

Shape

Default: "9:16"
lengthoptional
string

Length

Default: "12"
qualityoptional
string

Quality

Default: "Standard (720p)"

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