#Sora 2 code

1 messages · Page 1 of 1 (latest)

split roostBOT
#

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

#

If you are looking for example code to generate a video using the Sora 2 model via the OpenAI API, here is a sample in both JavaScript and Python, as provided in the official documentation:

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)

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 the prompt and parameters as needed for your use case. You will need a valid OpenAI API key to use these examples. If you meant something else by "Sora 2 code," please clarify your request.

Source: Video generation with Sora – Generate a video

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

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