Last active
October 6, 2025 19:00
-
-
Save tadasgedgaudas/a7e502bcd1d83295a906cd872f7647bd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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