/videos
/videos
| Feature | Supported |
| Cost Tracking | ✅ |
| Logging | ✅ (Full request/response logging) |
| Fallbacks | ✅ (Between supported models) |
| Load Balancing | ✅ |
| Guardrails Support | ✅ Content moderation and safety checks |
| Proxy Server Support | ✅ Full proxy integration with virtual keys |
| Spend Management | ✅ Budget tracking and rate limiting |
| Supported Providers | openai, azure, gemini, vertex_ai, runwayml |
tip
LiteLLM은 OpenAI Video Generation API 스펙을 따릅니다.
LiteLLM Python SDK 사용법
빠른 시작
from litellm import video_generation, video_status, video_contentimport osimport timeos.environ["OPENAI_API_KEY"] = "sk-.."# Generate videoresponse = video_generation(
model="openai/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"Initial Status: {response.status}")# Check status until video is readywhile True:
status_response = video_status(
video_id=response.id
)
print(f"Current Status: {status_response.status}")
if status_response.status == "completed":
break
elif status_response.status == "failed":
print("Video generation failed")
break
time.sleep(10) # Wait 10 seconds before checking again# Download video content when readyvideo_bytes = video_content(
video_id=response.id)# Save to filewith open("generated_video.mp4", "wb") as f: f.write(video_bytes)
비동기 사용법
from litellm import avideo_generation, avideo_status, avideo_contentimport os, asyncioos.environ["OPENAI_API_KEY"] = "sk-.."async def test_async_video():
response = await avideo_generation(
model="openai/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"Initial Status: {response.status}")
# Check status until video is ready
while True:
status_response = await avideo_status(
video_id=response.id
)
print(f"Current Status: {status_response.status}")
if status_response.status == "completed":
break
elif status_response.status == "failed":
print("Video generation failed")
break
await asyncio.sleep(10) # Wait 10 seconds before checking again
# Download video content when ready
video_bytes = await avideo_content(
video_id=response.id
)
# Save to file
with open("generated_video.mp4", "wb") as f:
f.write(video_bytes)asyncio.run(test_async_video())
비디오 상태 확인
from litellm import video_statusstatus_response = video_status(
video_id="video_1234567890")print(f"Video Status: {status_response.status}")
print(f"Created At: {status_response.created_at}")
print(f"Model: {status_response.model}")
비디오 목록
비디오를 나열하려면 디코딩할 video_id가 없으므로 제공자를 지정해야 해요:
from litellm import video_list# List videos from OpenAIvideos = video_list(custom_llm_provider="openai")for video in videos: print(f"Video ID: {video['id']}")
참조 이미지로 비디오 생성
from litellm import video_generation# Video generation with reference imageresponse = video_generation(
model="openai/sora-2",
prompt="A cat playing with a ball of yarn in a sunny garden",
input_reference=open("path/to/image.jpg", "rb"), # Reference image as file object
seconds="8",
size="720x1280")print(f"Video ID: {response.id}")
비디오 Remix (비디오 편집)
from litellm import video_remix# Remix an existing video by its ID with a new promptresponse = video_remix(
video_id="video_1234567890",
prompt="Make the cat jump higher",
custom_llm_provider="openai")print(f"Video ID: {response.id}")
선택적 파라미터
response = video_generation(
model="openai/sora-2",
prompt="A cat playing with a ball of yarn in a sunny garden",
seconds="8", # Video duration in seconds
size="720x1280", # Video dimensions
input_reference=open("path/to/image.jpg", "rb"), # Reference image as file object
user="user_123" # User identifier for tracking)
Azure 비디오 생성
from litellm import video_generationimport osos.environ["AZURE_OPENAI_API_KEY"] = "your-azure-api-key"os.environ["AZURE_OPENAI_API_BASE"] = "https://your-resource.openai.azure.com/"os.environ["AZURE_OPENAI_API_VERSION"] = "2024-02-15-preview"response = video_generation(
model="azure/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}")
LiteLLM Proxy 사용법
LiteLLM은 완전한 비디오 생성 워크플로를 위한 OpenAI API 호환 비디오 엔드포인트를 제공합니다:
/videos- 새 비디오 생성/videos/remix- 참조 이미지로 기존 비디오 편집/videos/status- 비디오 생성 상태 확인/videos/retrieval- 완료된 비디오 다운로드
설정
litellm proxy config.yaml에 다음을 추가하세요.
model_list:
- model_name: sora-2
litellm_params:
model: openai/sora-2
api_key: os.environ/OPENAI_API_KEY
- model_name: azure-sora-2
litellm_params:
model: azure/sora-2
api_key: os.environ/AZURE_OPENAI_API_KEY
api_base: os.environ/AZURE_OPENAI_API_BASE
litellm 시작:
litellm --config /path/to/config.yaml# RUNNING on http://0.0.0.0:4000
비디오 생성 요청 테스트:
curl --location 'http://localhost:4000/v1/videos' \--header 'Content-Type: application/json' \--header 'x-litellm-api-key: ***' \--data '{
"model": "sora-2",
"prompt": "A beautiful sunset over the ocean"}'
비디오 상태 요청 테스트:
curl --location 'http://localhost:4000/v1/videos/{video_id}' \--header 'x-litellm-api-key: ***'
비디오 조회 요청 테스트:
curl --location 'http://localhost:4000/v1/videos/{video_id}/content' \--header 'x-litellm-api-key: ***' \--output video.mp4
비디오 remix 요청 테스트:
curl --location --request POST 'http://localhost:4000/v1/videos/{video_id}/remix' \--header 'Content-Type: application/json' \--header 'x-litellm-api-key: ***' \--data '{
"prompt": "New remix instructions"}'
비디오 목록 요청 테스트(custom_llm_provider 필요):
# Note: video_list requires custom_llm_provider since there's no video_id to decode fromcurl --location 'http://localhost:4000/v1/videos?custom_llm_provider=openai' \--header 'x-litellm-api-key: ***' Or using headercurl --location 'http://localhost:4000/v1/videos' \--header 'x-litellm-api-key: ***' \--header 'custom-llm-provider: azure'
Character, Edit, Extension 엔드포인트
LiteLLM proxy는 이러한 OpenAI 호환 비디오 라우트도 지원합니다:
POST /v1/videos/charactersGET /v1/videos/characters/{character_id}POST /v1/videos/editsPOST /v1/videos/extensions
라우팅 동작(target_model_names, 인코딩된 ID, 제공자 override)
POST /v1/videos/characters는POST /v1/videos처럼target_model_names를 지원합니다.- character 생성 시
target_model_names가 제공되면 LiteLLM은 반환된character_id를 라우팅 메타데이터로 인코딩합니다. GET /v1/videos/characters/{character_id}는 인코딩된 character ID를 직접 받아들입니다. LiteLLM은 내부적으로 ID를 디코딩하고 올바른 모델/제공자 메타데이터로 라우팅합니다.POST /v1/videos/edits와POST /v1/videos/extensions는 둘 다 지원합니다:- 일반
video.id - LiteLLM이 반환한 인코딩된
video.id값
- 일반
custom_llm_provider는 다른 proxy 엔드포인트와 같은 패턴으로 제공할 수 있어요:- header:
custom-llm-provider - query:
?custom_llm_provider=... - body:
custom_llm_provider(또는 해당 시extra_body.custom_llm_provider)
- header:
target_model_names로 character 생성
curl --location 'http://localhost:4000/v1/videos/characters' \--header "Authorization: Bearer ***" \-F 'name=hero' \-F 'target_model_names=gpt-5.6-terra' \-F 'video=@/path/to/character.mp4'
예시 응답(인코딩된 id):
{
"id": "character_...",
"object": "character",
"created_at": 1712697600,
"name": "hero"
}
인코딩된 character_id로 character 조회
curl --location 'http://localhost:4000/v1/videos/characters/character_...' \--header "Authorization: Bearer ***"
인코딩된 video.id로 비디오 편집
curl --location 'http://localhost:4000/v1/videos/edits' \--header "Authorization: Bearer ***" \--header 'Content-Type: application/json' \--data '{
"prompt": "Make this brighter",
"video": { "id": "video_..." }}'
extra_body에서 제공자 override로 비디오 확장
curl --location 'http://localhost:4000/v1/videos/extensions' \--header "Authorization: Bearer ***" \--header 'Content-Type: application/json' \--data '{
"prompt": "Continue this scene",
"seconds": "4",
"video": { "id": "video_..." },
"extra_body": { "custom_llm_provider": "openai" }}'
Azure 비디오 생성 요청 테스트:
curl http://localhost:4000/v1/videos \
-H "Authorization: Bearer ***" \
-H "Content-Type: application/json" \
-d '{
"model": "azure-sora-2",
"prompt": "A cat playing with a ball of yarn in a sunny garden",
"seconds": "8",
"size": "720x1280"
}'
LiteLLM Proxy와 함께 OpenAI Client 사용
표준 OpenAI Python 클라이언트를 사용해 LiteLLM의 비디오 엔드포인트와 상호작용할 수 있어요. LiteLLM의 제공자 추상화와 proxy 기능을 유지하면서 친숙한 인터페이스를 제공합니다.
설정
먼저 OpenAI 클라이언트가 LiteLLM proxy를 가리키도록 구성하세요:
from openai import OpenAI# Point the OpenAI client to your LiteLLM proxyclient = OpenAI(
api_key="sk-", # Your LiteLLM proxy API key
base_url="http://localhost:4000/v1" # Your LiteLLM proxy URL)
비디오 생성
OpenAI 클라이언트 인터페이스로 새 비디오를 생성하세요:
# Basic video generationresponse = 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 imageresponse = 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}")
비디오 상태 확인
비디오 생성 상태를 확인하세요:
# Check video statusstatus_response = client.videos.retrieve(
video_id="video_6900378779308191a7359266e59b53fc01cd6bbd27a70763")print(f"Status: {status_response.status}")
print(f"Progress: {status_response.progress}%")# Poll until completionimport timewhile 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 all videosvideos = client.videos.list()for video in videos.data: print(f"Video ID: {video.id}, Status: {video.status}")
비디오 콘텐츠 다운로드
완료된 비디오를 다운로드하세요:
# Download video contentresponse = client.videos.download_content(
video_id="video_68fa2938848c8190bb718f977503aba6092ab18d68938fed")# Save the video to filewith open("generated_video.mp4", "wb") as f: f.write(response.content)print("Video downloaded successfully!")
비디오 Remix (편집)
새 지침으로 기존 비디오를 편집하세요:
# Remix/edit an existing videoresponse = 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}")
완전한 워크플로 예시
완전한 비디오 생성 워크플로를 보여주는 전체 예시입니다:
from openai import OpenAIimport time# Initialize clientclient = OpenAI(
api_key="sk-",
base_url="http://localhost:4000/v1")# 1. Generate videoprint("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.idprint(f"Video generation started. ID: {video_id}")# 2. Poll for completionprint("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 videoif 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 videoprint("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}")
요청/응답 형식
info
LiteLLM은 OpenAI Video Generation API 스펙을 따릅니다. 완전한 세부 사항은 공식 OpenAI Video Generation 문서를 참고하세요.
예시 요청
{
"model": "openai/sora-2",
"prompt": "A cat playing with a ball of yarn in a sunny garden",
"seconds": "8",
"size": "720x1280",
"user": "user_123"
}
요청 파라미터
| Parameter | Type | Required | Description |
| model | string | Yes | The video generation model to use (e.g., "openai/sora-2") |
| prompt | string | Yes | Text description of the desired video |
| seconds | string | No | Video duration in seconds (e.g., "8", "16") |
| size | string | No | Video dimensions (e.g., "720x1280", "1280x720") |
| input_reference | file object | No | Reference image for video generation (not supported by remix) |
| user | string | No | User identifier for tracking |
| video_id | string | Yes (status/retrieval) | Video ID for status checking or retrieval |
비디오 생성 요청 예시
비디오 생성의 경우:
{
"model": "sora-2",
"prompt": "A cat playing with a ball of yarn in a sunny garden",
"seconds": "8",
"size": "720x1280"
}
참조 이미지로 비디오 생성의 경우:
{
"model": "sora-2",
"prompt": "A cat playing with a ball of yarn in a sunny garden",
"input_reference": open("path/to/image.jpg", "rb"), # File object
"seconds": "8",
"size": "720x1280"
}
비디오 상태 확인의 경우:
{
"video_id": "video_1234567890",
"model": "sora-2"
}
비디오 조회의 경우:
{
"video_id": "video_1234567890",
"model": "sora-2"
}
응답 형식
응답은 다음 구조의 OpenAI 비디오 생성 형식을 따릅니다:
{
"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
}
}
응답 필드
| Field | Type | Description |
| id | string | Unique identifier for the video |
| object | string | Always "video" for video responses |
| status | string | Video processing status ("queued", "processing", "completed") |
| created_at | integer | Unix timestamp when the video was created |
| model | string | The model used for video generation |
| size | string | Video dimensions |
| seconds | string | Video duration in seconds |
| usage | object | Token usage and duration information |
지원 제공자
| Provider | Link to Usage | | OpenAI | Usage | | Azure | Usage | | Gemini | Usage | | Vertex AI | Usage | | RunwayML | Usage |