#Sora 2 code
1 messages · Page 1 of 1 (latest)
Certainly! Here is example code for generating a video using the Sora 2 model via the OpenAI API. This code is directly from the official documentation and demonstrates how to start a render job using JavaScript, Python, and cURL.
JavaScript Example
import OpenAI from 'openai';
const openai = new OpenAI();
let video = await openai.videos.create({
model: 'sora-2',
prompt: "A video of the words 'Thank you' in sparkling letters",
});
console.log('Video generation started: ', video);
Python Example
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)
cURL Example
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 the prompt and parameters as needed for your use case. The API will return a job object with an ID and status, which you can use to monitor progress and download the completed video when ready.
For more details on monitoring progress and retrieving results, see the official Sora video generation guide and retrieving results sections.<br>
Source: Video generation with Sora
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@wary current Kapa.ai is still learning and improving, please let me know how I did by reacting below.