Requirements
-
An API key. The code below assumes you set it
in an environment variable:
-
The
openaiPython package. You can install it with this command:
Generate a video
To generate a video, setinput to a text description of the video and set
generation parameters in provider_options.image.
The following example generates a video from a text prompt and saves it as
output-text-to-video.mp4.
Generate a video from an image
To generate a video from an image, setinput to a user message containing:
- An
input_imageblock with an image URL or base64-encoded data URI. - An
input_textblock describing how to animate the image.
input.png, encodes it as a
data URI, and saves the generated video as output-image-to-video.mp4.