Skip to main content

Endpoint

POST https://api.samuraiapi.in/v1/videos/generations

How It Works

Video generation is asynchronous. You submit a job and poll for the result:
  1. POST to /v1/videos/generations → receive a job id
  2. GET /v1/videos/generations/{id} → poll until status: "completed"
  3. Download the video from the returned URL

Request Parameters

ParameterTypeRequiredDescription
modelstringVideo model ID
promptstringText description of the video
durationintegerDuration in seconds (model-dependent)
aspect_ratiostring"16:9", "9:16", "1:1"
image_urlstringSource image for image-to-video

Example

import time
import requests

headers = {
    "Authorization": "Bearer sk-samurai-YOUR_KEY",
    "Content-Type": "application/json"
}

# Submit job
job = requests.post(
    "https://api.samuraiapi.in/v1/videos/generations",
    headers=headers,
    json={
        "model": "sora-turbo",
        "prompt": "A lone samurai walking through a misty forest at dawn",
        "duration": 5,
        "aspect_ratio": "16:9"
    }
).json()

# Poll for completion
while True:
    result = requests.get(
        f"https://api.samuraiapi.in/v1/videos/generations/{job['id']}",
        headers=headers
    ).json()
    
    if result["status"] == "completed":
        print(f"Video URL: {result['url']}")
        break
    elif result["status"] == "failed":
        print(f"Failed: {result['error']}")
        break
    
    time.sleep(10)

Available Models

ModelProviderMax DurationNotes
sora-2OpenAI20sBest coherence
sora-turboOpenAI5sFast generation
veo-3Google10sNative audio
veo-3.1Google10sImproved quality
luma-dream-machineLuma AI5sImage-to-video
hailuo-videoMiniMax6sFast, cinematic
kling-1.6Kuaishou10sHigh fidelity
runway-gen3Runway10sCinema-grade