From 15e5a8251e1c6331c4013fa8f744c5e54988000a Mon Sep 17 00:00:00 2001 From: Sameer Kankute Date: Wed, 10 Dec 2025 23:00:01 +0530 Subject: [PATCH 1/2] fix: respect videos content db creds --- litellm/llms/openai/videos/transformation.py | 1 + litellm/videos/main.py | 7 ----- tests/test_litellm/test_video_generation.py | 31 ++++++++++++++++++++ 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/litellm/llms/openai/videos/transformation.py b/litellm/llms/openai/videos/transformation.py index abdcd2fbe7b..8762d8c0b83 100644 --- a/litellm/llms/openai/videos/transformation.py +++ b/litellm/llms/openai/videos/transformation.py @@ -180,6 +180,7 @@ class OpenAIVideoConfig(BaseVideoConfig): # Construct the URL for video content download url = f"{api_base.rstrip('/')}/{original_video_id}/content" + print("🔥 [OPENAI VIDEO CONTENT] URL:", url) # No additional data needed for GET content request data: Dict[str, Any] = {} diff --git a/litellm/videos/main.py b/litellm/videos/main.py index 74e41ed5be3..db09ab04f11 100644 --- a/litellm/videos/main.py +++ b/litellm/videos/main.py @@ -271,7 +271,6 @@ def video_generation( # noqa: PLR0915 @client def video_content( video_id: str, - api_base: Optional[str] = None, timeout: Optional[float] = None, custom_llm_provider: Optional[str] = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -384,8 +383,6 @@ def video_content( @client async def avideo_content( video_id: str, - api_key: Optional[str] = None, - api_base: Optional[str] = None, timeout: Optional[float] = None, custom_llm_provider: Optional[str] = None, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -400,8 +397,6 @@ async def avideo_content( Parameters: - `video_id` (str): The identifier of the video whose content to download - - `api_key` (Optional[str]): The API key to use for authentication - - `api_base` (Optional[str]): The base URL for the API - `timeout` (Optional[float]): The timeout for the request in seconds - `custom_llm_provider` (Optional[str]): The LLM provider to use - `extra_headers` (Optional[Dict[str, Any]]): Additional headers @@ -425,8 +420,6 @@ async def avideo_content( func = partial( video_content, video_id=video_id, - api_key=api_key, - api_base=api_base, timeout=timeout, custom_llm_provider=custom_llm_provider, extra_headers=extra_headers, diff --git a/tests/test_litellm/test_video_generation.py b/tests/test_litellm/test_video_generation.py index 567f7d53fe4..87012f05155 100644 --- a/tests/test_litellm/test_video_generation.py +++ b/tests/test_litellm/test_video_generation.py @@ -832,6 +832,37 @@ def test_video_content_handler_uses_get_for_openai(): assert called_url == "https://api.openai.com/v1/videos/video_abc/content" +def test_video_content_respects_api_base_and_api_key_from_kwargs(): + """Test that video_content respects api_base and api_key from kwargs (simulating database entry).""" + from litellm.videos.main import video_content + + # Mock the handler to capture litellm_params + captured_litellm_params = None + + def capture_litellm_params(*args, **kwargs): + nonlocal captured_litellm_params + captured_litellm_params = kwargs.get("litellm_params") + return b"mp4-bytes" + + with patch('litellm.videos.main.base_llm_http_handler') as mock_handler: + mock_handler.video_content_handler = capture_litellm_params + + # Call video_content with api_base and api_key in kwargs (simulating database entry) + # This simulates how the router passes model config from database via **kwargs + result = video_content( + video_id="video_test_123", + custom_llm_provider="azure", + api_base="https://test-resource.openai.azure.com/", # Passed via kwargs by router + api_key="test-api-key-from-db", # Passed via kwargs by router + ) + + # Verify that api_base and api_key from kwargs were included in litellm_params + assert captured_litellm_params is not None + assert captured_litellm_params.get("api_base") == "https://test-resource.openai.azure.com/" + assert captured_litellm_params.get("api_key") == "test-api-key-from-db" + assert result == b"mp4-bytes" + + def test_openai_video_config_has_async_transform(): """Ensure OpenAIVideoConfig exposes async_transform_video_content_response at runtime.""" cfg = OpenAIVideoConfig() From 44d57b695a4c93bbb1d210310dc846126ff05d17 Mon Sep 17 00:00:00 2001 From: Sameer Kankute Date: Thu, 11 Dec 2025 08:22:22 +0530 Subject: [PATCH 2/2] remove print statment --- litellm/llms/openai/videos/transformation.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/litellm/llms/openai/videos/transformation.py b/litellm/llms/openai/videos/transformation.py index 8762d8c0b83..3073b22e1ca 100644 --- a/litellm/llms/openai/videos/transformation.py +++ b/litellm/llms/openai/videos/transformation.py @@ -1,18 +1,21 @@ -from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union from io import BufferedReader -from typing import cast +from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union, cast + import httpx from httpx._types import RequestFiles +import litellm from litellm.llms.base_llm.videos.transformation import BaseVideoConfig -from litellm.types.videos.main import VideoCreateOptionalRequestParams +from litellm.llms.openai.image_edit.transformation import ImageEditRequestUtils +from litellm.secret_managers.main import get_secret_str from litellm.types.llms.openai import CreateVideoRequest from litellm.types.router import GenericLiteLLMParams -from litellm.secret_managers.main import get_secret_str -from litellm.types.videos.main import VideoObject -from litellm.types.videos.utils import encode_video_id_with_provider, extract_original_video_id -import litellm -from litellm.llms.openai.image_edit.transformation import ImageEditRequestUtils +from litellm.types.videos.main import VideoCreateOptionalRequestParams, VideoObject +from litellm.types.videos.utils import ( + encode_video_id_with_provider, + extract_original_video_id, +) + if TYPE_CHECKING: from litellm.litellm_core_utils.litellm_logging import Logging as _LiteLLMLoggingObj @@ -180,7 +183,6 @@ class OpenAIVideoConfig(BaseVideoConfig): # Construct the URL for video content download url = f"{api_base.rstrip('/')}/{original_video_id}/content" - print("🔥 [OPENAI VIDEO CONTENT] URL:", url) # No additional data needed for GET content request data: Dict[str, Any] = {}