Skip to main contentSkip to footer
ExamplescriptintermediateRunnableguided-flow

Sora Remix

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

High-level flow

How this example moves from input to execution and reviewable output
Sora Remix -> Initialize OpenAI client -> Render the visible result -> video

Trigger

Sora Remix

Runtime

Initialize OpenAI client

Outcome

Render the visible result

Why this page exists

This example is shown as both real source code and a product-facing interaction pattern so learners can connect implementation, UX, and doctrine without leaving the library.

Visual flowReal sourceSandbox or walkthroughMCP access
How should this example be used in the platform?

Use the sandbox to understand the experience pattern first, then inspect the source to see how the product boundary, model boundary, and doctrine boundary are actually implemented.

UX pattern: Inspectable flow with visible system boundaries
Source references
Library entry
models-openai-08-video-5-sora-remix
Source path
content/example-library/sources/models/openai/08-video/5-sora-remix.py
Libraries
openai, pillow, pydantic, python-dotenv, requests
Runtime requirements
OPENAI_API_KEY
Related principles

5-sora-remix.py

python
import os
from datetime import datetime
from openai import OpenAI
from utils.downloader import download_sora_video

openai = OpenAI()

# Character description for consistency
CHARACTER = (
    "A 30-year-old male programmer with short dark hair, beard, wearing a black t-shirt"
)

shots = [
    # Shot 1: Kitchen Hook - The attention grabber
    f"{CHARACTER} standing in a modern kitchen, holding a coffee mug, looking directly at the camera with wide eyes and an excited expression. He says: 'OpenAI just dropped Sora 2 API at 2am... I've been up all night, this is INSANE.' Natural morning light from window, handheld camera feel, shot on Sony FX3, shallow depth of field, vertical 9:16 format. Kitchen counter and coffee machine visible in background.",
    # Shot 2: Walking/Hallway Transition - The value proposition
    "The same man walking through a hallway toward his office, maintaining his appearance from the previous shot. Gesturing animatedly while talking to the camera. He says with enthusiasm: 'Generate videos with 10 lines of Python. B-roll? Done. Product demos? Easy.' Tracking shot following him, natural indoor lighting transitioning to office glow, shot on Sony FX3 with gimbal, cinematic movement, vertical format.",
    # Shot 3: Office Desk Payoff - The promise
    "The same man now sitting at his professional studio desk with Shure SM7B microphone on boom arm. Same appearance and clothing. Dark background with soft blue LED light glow. He leans forward with a confident smile and says: 'In this video I'll show you how to use Sora 2 API and the prompting tricks that work. Let's go.' Professional three-point lighting, shot on Sony FX3, cinematic depth of field, vertical 9:16 format.",
]

# Create unique sequence folder
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
output_dir = f"./output/sequence_{timestamp}"
os.makedirs(output_dir, exist_ok=True)

print("Creating 3-shot sequence using remix...\n")
print(f"Output folder: {output_dir}\n")

# --------------------------------------------------------------
# Create Shot 1
# --------------------------------------------------------------

print("Generating Shot 1...")
video = openai.videos.create(
    model="sora-2",
    prompt=shots[0],
    size="720x1280",
    seconds="8",
)

print("Shot 1 generation started:", video)
video = download_sora_video(video, output_dir, "shot_1")

# --------------------------------------------------------------
# Remix to Shot 2
# --------------------------------------------------------------

print("\nGenerating Shot 2 via remix...")
remix_video = openai.videos.remix(
    video_id=video.id,
    prompt=shots[1],
)

print("Shot 2 generation started:", remix_video)
remix_video = download_sora_video(remix_video, output_dir, "shot_2")

# --------------------------------------------------------------
# Remix to Shot 3
# --------------------------------------------------------------

print("\nGenerating Shot 3 via remix...")
remix_video_2 = openai.videos.remix(
    video_id=video.id,
    prompt=shots[2],
)

print("Shot 3 generation started:", remix_video_2)
remix_video_2 = download_sora_video(remix_video_2, output_dir, "shot_3")

print(f"\n✓ All 3 shots saved to {output_dir}/")
print("\nUse 6-sora-sequence.py to stitch them together!")
What should the learner inspect in the code?

Look for the exact place where system scope is bounded: schema definitions, prompt framing, runtime configuration, and the call site that turns user intent into a concrete model or workflow action.

Look for output contracts and validation
Look for the exact execution call
Look for what the product could expose to the user
How does the sandbox relate to the source?

The sandbox should make the UX legible: what the user sees, what the system is deciding, and how the result becomes reviewable. The source then shows how that behavior is actually implemented.

Read the implementation summary.
Step through the user and system states.
Inspect the source code with the highlighted doctrine decisions in mind.
SandboxInspectable flow with visible system boundaries
Interaction walkthrough

Use the sandbox to step through the user-visible experience, the system work behind it, and the doctrine choice the example is making.

UX explanation

The sandbox explains what the user should see, what the system is doing, and where control or inspectability must remain explicit.

AI design explanation

The page turns raw source into a product-facing pattern: what the model is allowed to decide, what the product should expose, and where deterministic code or review should take over.

Interaction walkthrough

  1. 1Read the implementation summary.
  2. 2Step through the user and system states.
  3. 3Inspect the source code with the highlighted doctrine decisions in mind.

Visible to the user

A script demonstrating openai + pillow.

System work

The product prepares a bounded model or workflow task.

Why it matters

The interface should make the delegated task legible before automation happens.

Used in courses and paths

This example currently stands on its own in the library, but it still connects to the principle system and the broader example family.

Related principles

    Runtime architecture

    Use this example in your agents

    This example is also available through the blueprint’s agent-ready layer. Use the For agents page for the public MCP, deterministic exports, and Claude/Cursor setup.

    Define triggers, context, and boundaries before increasing autonomy
    Make control, observability, and recovery explicit in the runtime
    Choose the right operational patterns before delegating to workflows