Videos

Generate videos from text prompts using the video_generate capability

Turn a text prompt into a video with a single function call.

Diagram

Video Generation

📝 Prompt

🎬 video_generate

✅ MP4

Quick Start

  1. Generate a video

    Omit model to use the canonical default openai/sora-2.

    python
    from praisonai.capabilities import video_generate
    
    result = video_generate("A cat playing with yarn")
    print(result.url)
  2. Async generation
    python
    import asyncio
    from praisonai.capabilities import avideo_generate
    
    async def main():
        result = await avideo_generate("A sunset over the ocean")
        print(result.url)
    
    asyncio.run(main())

How It Works

The prompt is sent to a LiteLLM video route, and a VideoResult is returned with the video URL or job ID.

StepWhat happens
PromptYou describe the video in plain text
RouteThe model string selects the provider (default openai/sora-2)
ResultA VideoResult with url, id, status, and model

Configuration Options

OptionTypeDefaultDescription
promptstrRequiredText description of the video
modelstr"openai/sora-2"Provider-prefixed LiteLLM route
durationint5Video length in seconds
aspect_ratiostr"16:9"Aspect ratio ("16:9", "9:16", "1:1")
timeoutfloat600.0Request timeout in seconds
api_keystrNoneOptional API key override
api_basestrNoneOptional API base URL override
metadatadictNoneOptional metadata for tracing

The VideoResult object exposes url, id, status, model, and metadata.


Common Patterns

Choose a specific model:

python
from praisonai.capabilities import video_generate

result = video_generate("A city skyline at night", model="openai/sora-2-pro")
print(result.url)

Portrait orientation with a longer duration:

python
from praisonai.capabilities import video_generate

result = video_generate(
    "A waterfall in a forest",
    duration=10,
    aspect_ratio="9:16",
)
print(result.url)

Give large videos more time:

python
from praisonai.capabilities import video_generate

result = video_generate("A slow timelapse of clouds", timeout=1200.0)
print(result.status)

Best Practices

Rely on the default model

Omit model to use openai/sora-2, the canonical default shared by every video surface (SDK, capability, MCP, CLI). Only set model when you need a different provider route.

Raise the timeout for long videos

Longer duration values take more time to render. Increase timeout (e.g. 1200.0) to avoid premature timeouts.

Use provider-prefixed routes

Always pass a full LiteLLM route such as openai/sora-2. Bare names like sora are not valid routes and cause routing errors.

Prefer async for batches

Use avideo_generate inside asyncio when generating multiple videos so requests do not block each other.


Related