#Sora 2 code

1 messages · Page 1 of 1 (latest)

potent plinthBOT
#

Hi @wary current. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

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.

#

@wary current Kapa.ai is still learning and improving, please let me know how I did by reacting below.