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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Add new videos endpoints
Sameer Kankute79c787b85d4c
diff --git a/litellm/proxy/video_endpoints/utils.py b/litellm/proxy/video_endpoints/utils.pynew file mode 100644index 00000000000..36203bdc77e--- /dev/null+++ b/litellm/proxy/video_endpoints/utils.py@@ -0,0 +1,56 @@+from typing import Any, Dict, Optional++import orjson++from litellm.types.videos.utils import encode_character_id_with_provider+++def extract_model_from_target_model_names(target_model_names: Any) -> Optional[str]:+ if isinstance(target_model_names, str):+ target_model_names = [m.strip() for m in target_model_names.split(",") if m.strip()]+ elif not isinstance(target_model_names, list):+ return None+ return target_model_names[0] if target_model_names else None+++def get_custom_provider_from_data(data: Dict[str, Any]) -> Optional[str]:+ custom_llm_provider = data.get("custom_llm_provider")+ if custom_llm_provider:+ return custom_llm_provider++ extra_body = data.get("extra_body")+ if isinstance(extra_body, str):+ try:+ parsed_extra_body = orjson.loads(extra_body)+ if isinstance(parsed_extra_body, dict):+ extra_body = parsed_extra_body+ except Exception:+ extra_body = None++ if isinstance(extra_body, dict):+ extra_body_custom_llm_provider = extra_body.get("custom_llm_provider")+ if isinstance(extra_body_custom_llm_provider, str):+ return extra_body_custom_llm_provider++ return None+++def encode_character_id_in_response(+ response: Any, custom_llm_provider: str, model_id: Optional[str]+) -> Any:+ if isinstance(response, dict) and response.get("id"):+ response["id"] = encode_character_id_with_provider(+ character_id=response["id"],+ provider=custom_llm_provider,+ model_id=model_id,+ )+ return response++ character_id = getattr(response, "id", None)+ if isinstance(character_id, str) and character_id:+ response.id = encode_character_id_with_provider(+ character_id=character_id,+ provider=custom_llm_provider,+ model_id=model_id,+ )+ return responsediff --git a/litellm/types/llms/openai.py b/litellm/types/llms/openai.pyindex 0184919b543..a2df3f2e0d6 100644--- a/litellm/types/llms/openai.py+++ b/litellm/types/llms/openai.py@@ -2187,6 +2187,7 @@ class CreateVideoRequest(TypedDict, total=False):model: Optional[str] - The video generation model to use (defaults to sora-2)seconds: Optional[str] - Clip duration in seconds (defaults to 4 seconds)size: Optional[str] - Output resolution formatted as width x height (defaults to 720x1280)+ characters: Optional[List[Dict[str, str]]] - Character references to include in generationuser: Optional[str] - A unique identifier representing your end-userextra_headers: Optional[Dict[str, str]] - Additional headersextra_body: Optional[Dict[str, str]] - Additional body parameters@@ -2198,6 +2199,7 @@ class CreateVideoRequest(TypedDict, total=False):model: Optional[str]seconds: Optional[str]size: Optional[str]+ characters: Optional[List[Dict[str, str]]]user: Optional[str]extra_headers: Optional[Dict[str, str]]extra_body: Optional[Dict[str, str]]diff --git a/litellm/types/utils.py b/litellm/types/utils.pyindex 892c9578b94..f20958f3f84 100644--- a/litellm/types/utils.py+++ b/litellm/types/utils.py@@ -358,6 +358,14 @@ class CallTypes(str, Enum):avideo_retrieve_job = "avideo_retrieve_job"video_delete = "video_delete"avideo_delete = "avideo_delete"+ video_create_character = "video_create_character"+ avideo_create_character = "avideo_create_character"+ video_get_character = "video_get_character"+ avideo_get_character = "avideo_get_character"+ video_edit = "video_edit"+ avideo_edit = "avideo_edit"+ video_extension = "video_extension"+ avideo_extension = "avideo_extension"vector_store_file_create = "vector_store_file_create"avector_store_file_create = "avector_store_file_create"vector_store_file_list = "vector_store_file_list"@@ -700,6 +708,26 @@ API_ROUTE_TO_CALL_TYPES = {],"/videos/{video_id}/remix": [CallTypes.avideo_remix, CallTypes.video_remix],"/v1/videos/{video_id}/remix": [CallTypes.avideo_remix, CallTypes.video_remix],+ "/videos/characters": [+ CallTypes.avideo_create_character,+ CallTypes.video_create_character,+ ],+ "/v1/videos/characters": [+ CallTypes.avideo_create_character,+ CallTypes.video_create_character,+ ],+ "/videos/characters/{character_id}": [+ CallTypes.avideo_get_character,+ CallTypes.video_get_character,+ ],+ "/v1/videos/characters/{character_id}": [+ CallTypes.avideo_get_character,+ CallTypes.video_get_character,+ ],+ "/videos/edits": [CallTypes.avideo_edit, CallTypes.video_edit],+ "/v1/videos/edits": [CallTypes.avideo_edit, CallTypes.video_edit],+ "/videos/extensions": [CallTypes.avideo_extension, CallTypes.video_extension],+ "/v1/videos/extensions": [CallTypes.avideo_extension, CallTypes.video_extension],# Vector Stores"/vector_stores": [CallTypes.avector_store_create, CallTypes.vector_store_create],"/v1/vector_stores": [@@ -3465,6 +3493,9 @@ class SpecialEnums(Enum):LITELLM_MANAGED_VIDEO_COMPLETE_STR = ("litellm:custom_llm_provider:{};model_id:{};video_id:{}")+ LITELLM_MANAGED_VIDEO_CHARACTER_COMPLETE_STR = (+ "litellm:custom_llm_provider:{};model_id:{};character_id:{}"+ )class ServiceTier(Enum):diff --git a/litellm/types/videos/main.py b/litellm/types/videos/main.pyindex 880fec7640d..2ee44944bcc 100644--- a/litellm/types/videos/main.py+++ b/litellm/types/videos/main.py@@ -82,6 +82,7 @@ class VideoCreateOptionalRequestParams(TypedDict, total=False):model: Optional[str]seconds: Optional[str]size: Optional[str]+ characters: Optional[List[Dict[str, str]]]user: Optional[str]extra_headers: Optional[Dict[str, str]]extra_body: Optional[Dict[str, str]]