Skip to content

Instantly share code, notes, and snippets.

@tadasgedgaudas
Last active October 6, 2025 19:00
Show Gist options
  • Select an option

  • Save tadasgedgaudas/a7e502bcd1d83295a906cd872f7647bd to your computer and use it in GitHub Desktop.

Select an option

Save tadasgedgaudas/a7e502bcd1d83295a906cd872f7647bd to your computer and use it in GitHub Desktop.
import time
from openai import OpenAI
import base64
API_KEY="sk-YOUR-KEY"
client = OpenAI(api_key=API_KEY)
response = client.videos.create(
model="sora-2-pro",
prompt="Generate a video of a dog getting pulled over by a police officer",
)
while True:
response = client.videos.retrieve(response.id)
print(response)
if response.status == "completed":
break
time.sleep(1)
response = client.videos.download_content(
video_id=response.id,
)
print(response)
content = response.read()
print(f"Downloaded {len(content)} bytes")
# Write the video content to an MP4 file
with open("sora_video.mp4", "wb") as f:
f.write(content)
print("Video saved to sora_video.mp4")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment