Skip to main content
Generate videos from text or images with the responses API. The API returns generated videos as base64-encoded data. For information about all request and response fields, see the responses API reference. For available video generation models, see Supported models.
The responses API follows the provider-agnostic Open Responses specification.

Generate a video

To generate a video, set input 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.
Send a prompt, decode the returned video data, and save the video:
generate-video.py
The generated video should look similar to the following:

Generate a video from an image

To generate a video from an image, set input to a user message containing:
  • An input_image block with an image URL or base64-encoded data URI.
  • An input_text block describing how to animate the image.
The following example reads a local image named input.png, encodes it as a data URI, and saves the generated video as output-image-to-video.mp4.
Encode the input image, send it with a prompt, and save the generated video:
generate-video-from-image.py