#help
1 messages · Page 1 of 1 (latest)
To get started with Sora 2 and generate videos programmatically, you need access to the OpenAI API and use the appropriate endpoint. Here’s a basic example of how to generate a video using Sora 2 with code:
Example: Generate a Video with Sora 2 (Python)
from openai import OpenAI
openai = OpenAI()
video = openai.videos.create(
model="sora-2",
prompt="A video of a cool cat on a motorcycle in the night",
)
print("Video generation started:", video)
You can also use curl:
curl -X POST "<https://api.openai.com/v1/videos"> \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: multipart/form-data" \
-F prompt="Wide tracking shot of a teal coupe driving through a desert highway, heat ripples visible, hard sun overhead." \
-F model="sora-2" \
-F size="1280x720" \
-F seconds="8"
- Replace
$OPENAI_API_KEYwith your actual API key. - The
promptdescribes the video you want to generate. - The
modelshould be set to"sora-2"for Sora 2. - You can specify
sizeandsecondsfor resolution and duration.
Note: You need to have API access to Sora 2. Access is available to API users on tiers 1–5, but your organization must be verified. See API Organization Verification for details. If you don’t have access, you can request it through your OpenAI account or organization admin source.
For more details and advanced usage, see the official Sora video generation guide.