#Code sora 2

1 messages · Page 1 of 1 (latest)

ebon moatBOT
#

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

#

To generate videos using Sora 2 via the OpenAI API, you need to use the /videos endpoint. Below is example code in JavaScript and Python for starting a Sora 2 video generation job. You must have API access and an API key.

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 will receive a job object with an ID and status. You can then poll the status or use webhooks to know when the video is ready. Once completed, download the MP4 using the provided video ID.

For more details and advanced usage (such as using image references or downloading results), see the official documentation:


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