Add OpenAI Videos API endpoint support with Sora integration #15476
+2,864
−25
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Title
Add OpenAI Videos API endpoint support with Sora integration
Relevant issues
Fixes LIT-1258
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/litellm/
directory, Adding at least 1 test is a hard requirement - see detailsmake test-unit
Type
🆕 New Feature
Changes
Overview
This PR adds comprehensive support for OpenAI's Videos API endpoints, enabling video generation using Sora and Sora-2 models through LiteLLM's unified interface.
Key Features Added
1. Video Endpoints Implementation
litellm/proxy/openai_videos_endpoints/
video_endpoints.py
: FastAPI endpoints for all video operations__init__.py
: Module initializationPOST /v1/videos
- Create videoGET /v1/videos/{video_id}
- Retrieve video detailsGET /v1/videos/{video_id}/content
- Download video contentDELETE /v1/videos/{video_id}
- Delete videoGET /v1/videos
- List videos2. Core Video Logic
litellm/videos/
main.py
: Core video generation and management functions__init__.py
: Module exportscreate_video()
/acreate_video()
- Generate videosvideo_retrieve()
/avideo_retrieve()
- Get video detailsvideo_content()
/avideo_content()
- Download video contentvideo_delete()
/avideo_delete()
- Delete videosvideo_list()
/avideo_list()
- List videos3. OpenAI Integration
litellm/llms/openai/openai.py
OpenAIVideosAPI
class for direct HTTP requestsmultipart/form-data
requests withinput_reference
parameter4. Cost Calculation Integration
litellm/cost_calculator.py
input_cost_per_video_per_second
pricing modellitellm/litellm_core_utils/llm_cost_calc/utils.py
cost_per_video_per_second
metric supportsora-2
: $0.10 per secondsora-2-pro
: $0.30 per secondTechnical Details
API Compatibility
prompt
,model
,seconds
,size
)input_reference
parameter for image-guided video generationmultipart/form-data
handling for file uploadsCost Management
Usage Example
This implementation provides a complete, production-ready solution for OpenAI video generation through LiteLLM's unified interface.