π Built by Moon Dev
An AI-powered video generation agent using OpenAI's Sora 2 API for parallel video creation from text prompts.
The Video Agent leverages OpenAI's Sora 2 model to generate videos directly from text descriptions. It supports parallel video generation, allowing you to queue multiple video ideas that process simultaneously in the background.
- β¨ Text-to-Video Generation: Create videos directly from text prompts using Sora 2
- π Parallel Processing: 9 worker threads process multiple videos simultaneously
- βοΈ Configurable Settings: Control resolution, duration, and aspect ratio
- π± Multi-Format Support: Generate for TikTok (9:16), YouTube (16:9), Instagram (1:1), and more
- πΎ Auto-Save Organization: Videos saved in date-organized folders
- π Live Status Tracking: Monitor all video jobs in real-time
-
OpenAI API Key with Sora Access
- Get API key from: https://platform.openai.com/api-keys
β οΈ Important: Sora 2 API requires explicit access/invitation from OpenAI- Not broadly public yet - join waitlist or contact OpenAI sales
-
Add API Key to
.envOPENAI_KEY=your_openai_api_key_here
-
Upgrade OpenAI Package
pip install openai --upgrade pip freeze > requirements.txt
python src/agents/video_agent.pyWhen you run the agent, you'll see an interactive prompt:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β π Moon Dev's Sora 2 Video Generation Agent β
β Parallel video generation with OpenAI Sora 2 β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βοΈ Video Settings:
Model: sora-2 | Resolution: 720p | Duration: 8s
Aspect Ratio: 9:16
Format: Vertical (TikTok, Reels, Shorts)
π‘ Pro Tips:
- Type '/status' to see all jobs
- Type '/quit' to exit
- Videos process in parallel - queue multiple ideas!
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
TYPE YOUR VIDEO IDEA BELOW:
β€
Here are some example video ideas you can try:
A cinematic shot of Bitcoin charts rising dramatically with traders celebrating in the background
A slow-motion explosion of green candles as the market pumps, with confetti falling
Traders screaming and crying "Bitcoin is going to zero!" but then one person says "I'm buying. No gamble, no future."
An aesthetic time-lapse of a trading desk with multiple monitors showing crypto charts
A dramatic scene of a whale entering the ocean while crypto prices spike
/status- View all video jobs and their current status/quitor/exit- Shutdown the agent gracefully
Edit settings at the top of src/agents/video_agent.py:
# Sora 2 Configuration
MODEL = "sora-2" # Options: "sora-2", "sora-2-pro"
DEFAULT_RESOLUTION = "720p" # Options: "1080p", "720p"
DEFAULT_DURATION = 8 # Seconds: 4, 8, or 12
MAX_WORKERS = 9 # Number of parallel video generation threads
# Aspect Ratio Configuration
DEFAULT_ASPECT_RATIO = "9:16" # Change this for different video formats!| Aspect Ratio | Description | Best For |
|---|---|---|
9:16 |
Vertical | TikTok, Instagram Reels, YouTube Shorts |
16:9 |
Widescreen | YouTube videos, landscape content |
1:1 |
Square | Instagram feed posts |
4:3 |
Classic TV | Traditional video format |
21:9 |
Cinematic | Ultra-wide, cinematic content |
sora-2: Standard model, 720p resolution, faster output ($0.10/second)sora-2-pro: Premium model, 1080p resolution, higher quality ($0.30-$0.50/second)
Videos go through several states during generation:
- β³ Queued: Video job created, waiting for worker
- π¬ Generating: Worker actively processing the video
- β Completed: Video generated and saved successfully
- β Failed: Error occurred during generation
Type /status at any time to see all your video jobs:
================================================================================
π VIDEO GENERATION STATUS
================================================================================
π Summary:
β³ Queued: 2
π¬ Generating: 3
β
Completed: 5
β Failed: 0
π All Jobs:
β
video_69037464de... [COMPLETED] (127s)
Created: 10:21:15
Prompt: Traders screaming Bitcoin is going to zero...
Video: src/data/video_agent/2025-10-30/102317_Traders_screaming_Bitcoin.mp4
Videos are automatically organized by date:
src/data/video_agent/
βββ 2025-10-30/
β βββ 102317_Traders_screaming_Bitcoin.mp4
β βββ 103045_Cinematic_shot_of_Bitcoin.mp4
β βββ 104512_Whale_entering_ocean.mp4
βββ 2025-10-31/
β βββ ...
Filename Format: HHMMSS_[first_30_chars_of_prompt].mp4
- Sora 2: $0.10 per second of video
- Sora 2 Pro: $0.30-$0.50 per second of video
| Duration | Sora 2 | Sora 2 Pro |
|---|---|---|
| 4 seconds | $0.40 | $1.20-$2.00 |
| 8 seconds | $0.80 | $2.40-$4.00 |
| 12 seconds | $1.20 | $3.60-$6.00 |
Pro Tip: Start with 4-8 second videos at 720p to test before scaling up!
Solution: Upgrade your OpenAI package
pip install openai --upgradeYou need OpenAI SDK version 2.6.1 or higher.
Reason: Sora 2 API is not broadly public yet
Solutions:
- Check if you have Sora API access at: https://platform.openai.com/account/api-keys
- Join the Sora API waitlist
- Contact OpenAI sales for enterprise access
- ChatGPT Plus subscribers can use Sora via the web interface (not API)
The agent has a 20-minute timeout per video. If videos consistently timeout:
- Reduce
DEFAULT_DURATIONfrom 12s to 8s or 4s - Simplify your prompts
- Use
sora-2instead ofsora-2-pro - Check OpenAI status page for API slowdowns
Fixed in latest version! The agent now adds proper delays and spacing to prevent worker status messages from interrupting the prompt.
Good prompts are:
- Specific: Describe exactly what you want to see
- Visual: Focus on visual elements, not abstract concepts
- Detailed: Include camera angles, lighting, mood
- Actionable: Describe what's happening in the scene
β Bad: "Make a video about Bitcoin"
β Good: "A cinematic slow-motion shot of a golden Bitcoin coin rotating in space with stars in the background, dramatic lighting from the right side"
β Bad: "Crypto trading video"
β Good: "A professional trading desk with 4 monitors showing green candlestick charts, a trader's hands typing on a mechanical keyboard, modern office with city skyline visible through windows, golden hour lighting"
- Market crash/pump reactions
- Whale activity visualizations
- Technical analysis chart animations
- Trading desk setups
- Crypto coin showcases
- Market sentiment scenes
- Educational explainer visuals
The agent runs 9 worker threads simultaneously, meaning you can:
- Queue up 10 video ideas in a row
- Walk away while they all generate in parallel
- Come back to 10 completed videos
Example Workflow:
β€ First video idea
β€ Second video idea
β€ Third video idea
...
β€ /status # Check progress
...
β€ /quit # When all done
All videos will process in the background while you continue adding more!
- Requires explicit invitation from OpenAI
- ChatGPT Plus/Pro has Sora access (web only, not API)
- API access is separate and requires waitlist/approval
- Expected to roll out gradually to developers
OpenAI may have rate limits on:
- Number of concurrent video generations
- Total seconds of video per hour/day
- API request frequency
The agent handles this by queuing jobs and processing them as workers become available.
- Sora 2 generates realistic, physically accurate videos
- Quality depends heavily on prompt engineering
- Results may vary - experiment with different descriptions
- Pro version offers higher resolution and quality
# Main components:
- create_video_job() # Creates video generation job via API
- poll_video_job() # Monitors job status and downloads result
- video_worker() # Background worker that processes jobs
- save_video_bytes() # Saves downloaded video to disk
- display_status() # Shows status of all jobs
- main() # Interactive CLI loopKey Design Features:
- Thread-safe job tracking with locks
- Queue-based worker distribution
- Graceful shutdown handling
- Auto-retry logic for polling
- Date-organized file output
- Generate Video Clips: Use Sora to create short trading reaction clips
- Combine with Audio: Add voiceovers or music in post-production
- Post to Social Media: Share on TikTok, Reels, Shorts
- Scale Content: Generate dozens of videos in parallel
- Market analysis visuals
- Strategy explanation scenes
- Reaction videos to market moves
- Educational content backgrounds
- Thumbnail/intro animations
- Social media clips
- Chat Agent: Monitors live stream chat and responds
- Twitter Agent: Creates tweet content using AI
- Clips Agent: Helps clip long videos into shorter segments
- Phone Agent: AI agent for handling phone calls
Python Packages:
openai >= 2.6.1- OpenAI SDK with Sora supportpython-dotenv- Environment variable managementtermcolor- Colored terminal outputrequests- HTTP requests
External Services:
- OpenAI API key with Sora 2 access
- OpenAI Sora 2 Release: https://openai.com/sora
- Sora API Docs: https://platform.openai.com/docs/guides/video-generation
- Moon Dev YouTube: Weekly updates and tutorials
- Discord Community: https://discord.gg/8UPuVZ53bh
π Built with love by Moon Dev - Democratizing AI agent development
Part of the Moon Dev AI Agents for Trading ecosystem - 48+ specialized agents, all open source.