Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:BerriAI Litellm Videos API

From Leeroopedia
Revision as of 12:11, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/BerriAI_Litellm_Videos_API.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Property Value
sources litellm/videos/main.py
domains Video Generation, Video Management, OpenAI, Multimedia
last_updated 2026-02-15 16:00 GMT

Overview

The Videos API module provides a unified interface for video generation, content download, remixing, listing, and status retrieval, with automatic provider detection from encoded video IDs and support for mock responses.

Description

This module implements five operation categories through sync/async function pairs: video_generation/avideo_generation for creating videos from text prompts, video_content/avideo_content for downloading video bytes, video_remix/avideo_remix for remixing existing videos with new prompts, video_list/avideo_list for listing all videos with pagination, and video_status/avideo_status for checking video generation progress. All functions use the @client decorator and typed overloads for async/sync return type differentiation.

A distinctive feature is the decode_video_id_with_provider() function used by video_content, video_remix, and video_status to auto-detect the provider from an encoded video ID, falling back to "openai" if decoding fails. The module uses BaseVideoConfig loaded via ProviderConfigManager.get_provider_video_config(), VideoGenerationRequestUtils for parameter extraction and mapping, and CallTypes for logging classification (e.g., create_video, video_remix, video_list, video_retrieve). Video generation supports optional parameters including input_reference (image guide), seconds (clip duration), size (resolution), and user (end-user ID).

Usage

Import this module when you need to generate videos from text prompts, download generated video content, remix existing videos, list videos, or check video generation status. It maps to the OpenAI /v1/videos endpoint family.

Code Reference

Source Location

Property Value
Repository github.com/BerriAI/litellm
File litellm/videos/main.py
Lines 1096
Module litellm.videos.main

Signature

@client
def video_generation(
    prompt: str,
    model: Optional[str] = None,
    input_reference: Optional[FileTypes] = None,
    seconds: Optional[str] = None,
    size: Optional[str] = None,
    user: Optional[str] = None,
    timeout=600,
    custom_llm_provider=None,
    extra_headers=None, extra_query=None, extra_body=None,
    **kwargs,
) -> Union[VideoObject, Coroutine[Any, Any, VideoObject]]

@client
def video_content(video_id: str, ...) -> Union[bytes, Coroutine[Any, Any, bytes]]

@client
def video_remix(video_id: str, prompt: str, ...) -> Union[VideoObject, Coroutine]

@client
def video_list(after=None, limit=None, order=None, ...) -> Union[List[VideoObject], Coroutine]

@client
def video_status(video_id: str, ...) -> Union[VideoObject, Coroutine]

Import

from litellm.videos.main import (
    video_generation, avideo_generation,
    video_content, avideo_content,
    video_remix, avideo_remix,
    video_list, avideo_list,
    video_status, avideo_status,
)

I/O Contract

Inputs

Parameter Type Required Description
prompt str For generation/remix Text description of the video to generate
model Optional[str] No Video model identifier; defaults to DEFAULT_VIDEO_ENDPOINT_MODEL
video_id str For content/remix/status The ID of the video (may contain encoded provider info)
input_reference Optional[FileTypes] No Image reference to guide video generation
seconds Optional[str] No Video clip duration in seconds
size Optional[str] No Output resolution (width x height)
after Optional[str] No Pagination cursor for list
limit Optional[int] No Number of items to return
order Optional[str] No Sort order: "asc" or "desc"
custom_llm_provider Optional[str] No Provider override; auto-detected from model or video_id

Outputs

Function Return Type Description
video_generation VideoObject The generated video object with ID, status, and metadata
video_content bytes Raw video content as bytes for saving to file
video_remix VideoObject The remixed video object
video_list List[VideoObject] List of video objects
video_status VideoObject Video object with current status and progress info

Usage Examples

import litellm

# Generate a video
video = litellm.video_generation(
    prompt="A serene sunset over mountains with birds flying",
    model="openai/sora",
    size="1920x1080",
    seconds="10",
)
print(f"Video ID: {video.id}, Status: {video.status}")

# Check video status
status = litellm.video_status(video_id=video.id)
print(f"Progress: {status.status}")
import asyncio
import litellm

async def main():
    # Generate and download a video
    video = await litellm.avideo_generation(
        prompt="A cat playing with a ball of yarn",
    )

    # Wait for completion and download
    video_bytes = await litellm.avideo_content(video_id=video.id)
    with open("cat_video.mp4", "wb") as f:
        f.write(video_bytes)

    # Remix the video
    remixed = await litellm.avideo_remix(
        video_id=video.id,
        prompt="Make it a dog instead of a cat",
    )
    print(f"Remixed Video ID: {remixed.id}")

asyncio.run(main())

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment