Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix errors in videos documentation (#15996)

Sameer Kankute59189c0579c2
diff --git a/docs/my-website/docs/providers/azure/videos.md b/docs/my-website/docs/providers/azure/videos.md
index 22e714a8ecf..d088c63f710 100644
--- a/docs/my-website/docs/providers/azure/videos.md
+++ b/docs/my-website/docs/providers/azure/videos.md
@@ -31,7 +31,7 @@ os.environ["AZURE_OPENAI_API_VERSION"] = "2024-02-15-preview"
### Basic Usage
```python
-from litellm import video_generation, video_status, video_retrieval
+from litellm import video_generation, video_status, video_content
import os
import time
@@ -68,7 +68,7 @@ while True:
time.sleep(10) # Wait 10 seconds before checking again
# Download video content when ready
-video_bytes = video_retrieval(
+video_bytes = video_content(
video_id=response.id,
model="azure/sora-2"
)
@@ -146,10 +146,10 @@ client = openai.OpenAI(
)
# request sent to model set on litellm proxy, `litellm --model`
-response = client.videos.generations.create(
+response = client.videos.create(
model="azure-sora-2",
prompt="A cat playing with a ball of yarn in a sunny garden",
- seconds="8",
+ seconds=8,
size="720x1280"
)
@@ -210,7 +210,7 @@ general_settings:
```python
# Download video content
-video_bytes = video_retrieval(
+video_bytes = video_content(
video_id="video_1234567890",
model="azure/sora-2"
)
@@ -242,7 +242,7 @@ def generate_and_download_video(prompt):
time.sleep(30)
# Step 3: Download video
- video_bytes = litellm.video_retrieval(
+ video_bytes = litellm.video_content(
video_id=video_id,
model="azure/sora-2"
)
diff --git a/docs/my-website/docs/providers/openai/videos.md b/docs/my-website/docs/providers/openai/videos.md
index 4dc18da77bd..473279e60ef 100644
--- a/docs/my-website/docs/providers/openai/videos.md
+++ b/docs/my-website/docs/providers/openai/videos.md
@@ -17,7 +17,7 @@ os.environ["OPENAI_API_KEY"] = "your-api-key"
### Basic Usage
```python
-from litellm import video_generation, video_retrieval
+from litellm import video_generation, video_content
import os
os.environ["OPENAI_API_KEY"] = "your-api-key"
@@ -34,7 +34,7 @@ print(f"Video ID: {response.id}")
print(f"Status: {response.status}")
# Download video content when ready
-video_bytes = video_retrieval(
+video_bytes = video_content(
video_id=response.id,
model="sora-2"
)
@@ -63,7 +63,7 @@ with open("generated_video.mp4", "wb") as f:
```python
# Download video content
-video_bytes = video_retrieval(
+video_bytes = video_content(
video_id="video_1234567890",
model="sora-2"
)
@@ -95,7 +95,7 @@ def generate_and_download_video(prompt):
time.sleep(30)
# Step 3: Download video
- video_bytes = litellm.video_retrieval(
+ video_bytes = litellm.video_content(
video_id=video_id,
model="sora-2"
)
@@ -118,7 +118,7 @@ video_file = generate_and_download_video(
# Video editing with reference image
response = litellm.video_generation(
prompt="Make the cat jump higher",
- input_reference="path/to/image.jpg", # Reference image
+ input_reference=open("path/to/image.jpg", "rb"), # Reference image
model="sora-2",
seconds="8"
)
diff --git a/docs/my-website/docs/videos.md b/docs/my-website/docs/videos.md
index dd96398f8d6..344a0f852df 100644
--- a/docs/my-website/docs/videos.md
+++ b/docs/my-website/docs/videos.md
@@ -21,7 +21,7 @@ LiteLLM follows the [OpenAI Video Generation API specification](https://platform
### Quick Start
```python
-from litellm import video_generation, video_status, video_retrieval
+from litellm import video_generation, video_status, video_content
import os
import time
@@ -56,7 +56,7 @@ while True:
time.sleep(10) # Wait 10 seconds before checking again
# Download video content when ready
-video_bytes = video_retrieval(
+video_bytes = video_content(
video_id=response.id,
model="openai/sora-2"
)
@@ -69,7 +69,7 @@ with open("generated_video.mp4", "wb") as f:
### Async Usage
```python
-from litellm import avideo_generation, avideo_status, avideo_retrieval
+from litellm import avideo_generation, avideo_status, avideo_content
import os, asyncio
os.environ["OPENAI_API_KEY"] = "sk-.."
@@ -103,7 +103,7 @@ async def test_async_video():
await asyncio.sleep(10) # Wait 10 seconds before checking again
# Download video content when ready
- video_bytes = await avideo_retrieval(
+ video_bytes = await avideo_content(
video_id=response.id,
model="openai/sora-2"
)
@@ -241,57 +241,45 @@ litellm --config /path/to/config.yaml
Test video generation request
```bash
-curl http://0.0.0.0:4000/videos/generations \
- -H "Authorization: Bearer sk-1234" \
- -H "Content-Type: application/json" \
- -d '{
+curl --location 'http://localhost:4000/v1/videos' \
+--header 'Content-Type: application/json' \
+--header 'x-litellm-api-key: sk-1234' \
+--data '{
"model": "sora-2",
- "prompt": "A cat playing with a ball of yarn in a sunny garden",
- "seconds": "8",
- "size": "720x1280"
- }'
+ "prompt": "A beautiful sunset over the ocean"
+}'
```
Test video status request
```bash
-curl http://0.0.0.0:4000/videos/status \
- -H "Authorization: Bearer sk-1234" \
- -H "Content-Type: application/json" \
- -d '{
- "video_id": "video_1234567890",
- "model": "sora-2"
- }'
+curl --location 'http://localhost:4000/v1/videos/video_id' \
+--header 'Accept: application/json' \
+--header 'x-litellm-api-key: sk-1234'
+
```
Test video retrieval request
```bash
-curl http://0.0.0.0:4000/videos/retrieval \
- -H "Authorization: Bearer sk-1234" \
- -H "Content-Type: application/json" \
- -d '{
- "video_id": "video_1234567890",
- "model": "sora-2"
- }'
+curl --location 'http://localhost:4000/v1/videos/video_id/content' \
+--header 'Accept: application/json' \
+--header 'x-litellm-api-key: sk-1234'
+
```
Test video remix request
```bash
-curl http://0.0.0.0:4000/videos/remix \
- -H "Authorization: Bearer sk-1234" \
- -H "Content-Type: multipart/form-data" \
- -F 'model=sora-2' \
- -F 'prompt=Make the cat jump higher' \
- -F 'input_reference=@path/to/image.jpg' \
- -F 'seconds=8'
+curl --location --request POST 'http://localhost:4000/v1/videos/string/remix' \
+--header 'Accept: application/json' \
+--header 'x-litellm-api-key: sk-1234'
```
Test Azure video generation request
```bash
-curl http://0.0.0.0:4000/videos/generations \
+curl http://localhost:4000/v1/videos \
-H "Authorization: Bearer sk-1234" \
-H "Content-Type: application/json" \
-d '{
@@ -302,6 +290,188 @@ curl http://0.0.0.0:4000/videos/generations \
}'
```
+## **Using OpenAI Client with LiteLLM Proxy**
+
+You can use the standard OpenAI Python client to interact with LiteLLM's video endpoints. This provides a familiar interface while leveraging LiteLLM's provider abstraction and proxy features.
+
+### Setup
+
+First, configure your OpenAI client to point to your LiteLLM proxy:
+
+```python
+from openai import OpenAI
+
+# Point the OpenAI client to your LiteLLM proxy
+client = OpenAI(
+ api_key="sk-1234", # Your LiteLLM proxy API key
+ base_url="http://localhost:4000/v1" # Your LiteLLM proxy URL
+)
+```
+
+### Video Generation
+
+Generate a new video using the OpenAI client interface:
+
+```python
+# Basic video generation
+response = client.videos.create(
+ model="sora-2",
+ prompt="A cat playing with a ball of yarn in a sunny garden",
+ seconds=8,
+ size="720x1280"
+)
+
+print(f"Video ID: {response.id}")
+print(f"Status: {response.status}")
+```
+
+### Video Generation with Reference Image
+
+Create a video using a reference image:
+
+```python
+# Video generation with reference image
+response = client.videos.create(
+ model="sora-2",
+ prompt="Add clouds to the video",
+ seconds=4,
+ input_reference=open("/path/to/your/image.jpg", "rb")
+)
+
+print(f"Video ID: {response.id}")
+print(f"Status: {response.status}")
+```
+
+### Video Status Checking
+
+Check the status of a video generation:
+
+```python
+# Check video status
+status_response = client.videos.retrieve(
+ video_id="video_6900378779308191a7359266e59b53fc01cd6bbd27a70763"
+)
+
+print(f"Status: {status_response.status}")
+print(f"Progress: {status_response.progress}%")
+
+# Poll until completion
+import time
+
+while status_response.status not in ["completed", "failed"]:
+ time.sleep(10) # Wait 10 seconds
+ status_response = client.videos.retrieve(
+ video_id="video_6900378779308191a7359266e59b53fc01cd6bbd27a70763"
+ )
+ print(f"Current status: {status_response.status}")
+```
+
+### List Videos
+
+Get a list of your videos:
+
+```python
+# List all videos
+videos = client.videos.list()
+
+for video in videos.data:
+ print(f"Video ID: {video.id}, Status: {video.status}")
+```
+
+### Download Video Content
+
+Download the completed video:
+
+```python
+# Download video content
+response = client.videos.download_content(
+ video_id="video_68fa2938848c8190bb718f977503aba6092ab18d68938fed"
+)
+
+# Save the video to file
+with open("generated_video.mp4", "wb") as f:
+ f.write(response.content)
+
+print("Video downloaded successfully!")
+```
+
+### Video Remix (Editing)
+
+Edit an existing video with new instructions:
+
+```python
+# Remix/edit an existing video
+response = client.videos.remix(
+ video_id="video_68fa2574bdd88190873a8af06a370ff407094ddbc4bbb91b",
+ prompt="Slow the cloud movement",
+ seconds=8
+)
+
+print(f"Remix Video ID: {response.id}")
+print(f"Status: {response.status}")
+```
+
+### Complete Workflow Example
+
+Here's a complete example showing the full video generation workflow:
+
+```python
+from openai import OpenAI
+import time
+
+# Initialize client
+client = OpenAI(
+ api_key="sk-1234",
+ base_url="http://localhost:4000/v1"
+)
+
+# 1. Generate video
+print("Generating video...")
+response = client.videos.create(
+ model="sora-2",
+ prompt="A serene lake with mountains in the background",
+ seconds=8,
+ size="1280x720"
+)
+
+video_id = response.id
+print(f"Video generation started. ID: {video_id}")
+
+# 2. Poll for completion
+print("Waiting for video to complete...")
+while True:
+ status = client.videos.retrieve(video_id=video_id)
+ print(f"Status: {status.status}")
+
+ if status.status == "completed":
+ print("Video generation completed!")
+ break
+ elif status.status == "failed":
+ print("Video generation failed!")
+ break
+
+ time.sleep(10)
+
+# 3. Download video
+if status.status == "completed":
+ print("Downloading video...")
+ video_content = client.videos.download_content(video_id=video_id)
+
+ with open(f"video_{video_id}.mp4", "wb") as f:
+ f.write(video_content.content)
+
+ print("Video saved successfully!")
+
+# 4. Optional: Remix the video
+print("Creating a remix...")
+remix_response = client.videos.remix(
+ video_id=video_id,
+ prompt="Add gentle ripples to the lake surface"
+)
+
+print(f"Remix started. ID: {remix_response.id}")
+```
+
## **Request/Response Format**
:::info
@@ -381,19 +551,21 @@ The response follows OpenAI's video generation format with the following structu
```json
{
- "id": "video_1234567890",
- "object": "video",
- "status": "queued",
- "created_at": 1712697600,
- "model": "sora-2",
- "size": "720x1280",
- "seconds": "8",
- "usage": {
- "prompt_tokens": 0,
- "completion_tokens": 0,
- "total_tokens": 0,
- "duration_seconds": 8.0
- }
+ "id": "video_6900378779308191a7359266e59b53fc01cd6bbd27a70763",
+ "object": "video",
+ "status": "queued",
+ "created_at": 1761621895,
+ "completed_at": null,
+ "expires_at": null,
+ "error": null,
+ "progress": 0,
+ "remixed_from_video_id": null,
+ "seconds": "4",
+ "size": "720x1280",
+ "model": "sora-2",
+ "usage": {
+ "duration_seconds": 4.0
+ }
}
```
diff --git a/docs/my-website/sidebars.js b/docs/my-website/sidebars.js
index 82ef79c7870..f83f454aa91 100644
--- a/docs/my-website/sidebars.js
+++ b/docs/my-website/sidebars.js
@@ -432,6 +432,7 @@ const sidebars = {
"providers/openai",
"providers/openai/responses_api",
"providers/openai/text_to_speech",
+ "providers/openai/videos",
]
},
"providers/text_completion_openai",
@@ -444,6 +445,7 @@ const sidebars = {
"providers/azure/azure_responses",
"providers/azure/azure_embedding",
"providers/azure/azure_speech",
+ "providers/azure/videos",
]
},
{
@@ -714,6 +716,7 @@ const sidebars = {
items: [
"adding_provider/directory_structure",
"adding_provider/new_rerank_provider",
+ ]
},
"extras/contributing",
"contributing",