What You’ll Build
By the end of this guide, you’ll have a working Sora agent that:- Accepts natural language prompts for video generation
- Manages OpenAI API credentials securely
- Tracks video generation status in real-time
- Displays generated videos in your working directory
- Handles errors gracefully with helpful feedback
Prerequisites
Before starting, make sure you have:- Opperator installed (see Installation)
- Python 3.8 or higher
- OpenAI API key with Sora access (Get one here)
- Basic familiarity with Python
Creating the Sora Agent
1
Bootstrap the agent
Use the Opperator CLI to quickly create the agent structure:This command:
- Creates the agent directory at
~/.config/opperator/agents/sora_agent/ - Sets up a Python virtual environment
- Installs the Opperator SDK
- Registers the agent in
agents.yaml - Uses
--no-startso we can add our code before running it
2
Configure API Key
Set up your OpenAI API key using the CLI:This will prompt you to enter your API key securely. The key is stored in Opperator’s secret manager, where your agent can access it via
get_secret("openai_api_key").Alternatively, you can provide the key inline:3
Implement the agent logic
Replace the contents of This implementation provides two main commands:
main.py with the following implementation:generate_video: Creates videos from text promptslist_generations: Shows all generated videos
get_secret("openai_api_key").4
Start the agent
Start your Sora agent:Or launch the Opperator TUI and switch to your Sora agent:In the TUI:
- Press
Shift+Tabto open the agent picker - Select
sora_agent - You’re ready to start generating videos!
agents.yaml when you ran the bootstrap command.Using Your Sora Agent
Generate Your First Video
Simply describe the video you want in natural language:generate_video command with your prompt. You’ll see:
- Real-time status updates in the sidebar
- Logs showing generation progress
- The final video path when complete
Use Slash Commands
For direct control, you can call commands explicitly:List Your Videos
Check all generated videos:Next Steps
Continue Learning
Deepen your understanding of the Opperator SDK features used in this guide:Lifecycle Events
React to conversations and agent activation
State Management
Persist data across conversations
System Prompts
Guide the LLM with dynamic agent state
Custom Sidebars
Display status and progress in the TUI