ExamplescriptintermediateRunnableguided-flow
Sora Prompting
Runnable example (intermediate) for script using openai, pillow.
Key Facts
- Level
- intermediate
- Runtime
- Python • OpenAI API
- Pattern
- Inspectable flow with visible system boundaries
- Interaction
- Live sandbox • Script
- Updated
- 14 March 2026
Navigate this example
Library
Browse examplesReopen the wider library to compare adjacent patterns and linked learning paths.Interaction
Run sandbox nowTry the interaction directly in this example’s guided sandbox surface.Source
Open full sourceRead the real implementation, highlighted checkpoints, and runtime requirements.MCP
Call via MCPUse the same resource inside agents, deterministic exports, and MCP setup flows.
4-sora-prompting.py
python
from utils.director import SoraDirector
from utils.downloader import download_sora_video
from openai import OpenAI
openai = OpenAI()
director = SoraDirector()
# --------------------------------------------------------------
# Generate a Sora prompt
# --------------------------------------------------------------
prompt = director.generate_sora_prompt(
"A YouTuber excitedly showing OpenAI's new Sora 2 API release to generate hyper-realistic videos with just a few lines of code."
)
print(prompt)
# --------------------------------------------------------------
# Generate a video
# --------------------------------------------------------------
video = openai.videos.create(
model="sora-2",
prompt=prompt,
size="720x1280",
seconds="4",
)
print("Video generation started:", video)
# --------------------------------------------------------------
# Download the video
# --------------------------------------------------------------
video = download_sora_video(video=video, output_folder="./output")