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
openai(video): use GET for /videos/{id}/content by returning empty params; add tests to assert GET (#16672)
pnookala-godaddyf599a462c153
diff --git a/litellm/llms/openai/videos/transformation.py b/litellm/llms/openai/videos/transformation.pyindex 9848477f32d..8f5d41fe467 100644--- a/litellm/llms/openai/videos/transformation.py+++ b/litellm/llms/openai/videos/transformation.py@@ -178,10 +178,10 @@ class OpenAIVideoConfig(BaseVideoConfig):# Construct the URL for video content downloadurl = f"{api_base.rstrip('/')}/{original_video_id}/content"- # Add video_id as query parameter- params = {"video_id": original_video_id}-- return url, params+ # No additional data needed for GET content request+ data: Dict[str, Any] = {}++ return url, datadef transform_video_remix_request(self,@@ -404,4 +404,4 @@ class OpenAIVideoConfig(BaseVideoConfig):if isinstance(image, BufferedReader):files_list.append((field_name, (image.name, image, image_content_type)))else:- files_list.append((field_name, ("input_reference.png", image, image_content_type)))\ No newline at end of file+ files_list.append((field_name, ("input_reference.png", image, image_content_type)))diff --git a/tests/test_litellm/test_video_generation.py b/tests/test_litellm/test_video_generation.pyindex b11e38b32bb..3ba4a9ddda2 100644--- a/tests/test_litellm/test_video_generation.py+++ b/tests/test_litellm/test_video_generation.py@@ -14,6 +14,7 @@ import litellmfrom litellm.types.videos.main import VideoObject, VideoResponsefrom litellm.videos.main import video_generation, avideo_generation, video_status, avideo_statusfrom litellm.llms.openai.videos.transformation import OpenAIVideoConfig+from litellm.llms.custom_httpx.llm_http_handler import BaseLLMHTTPHandlerfrom litellm.cost_calculator import default_video_cost_calculatorfrom litellm.litellm_core_utils.litellm_logging import Logging as LitellmLoggingfrom litellm.integrations.custom_logger import CustomLogger@@ -713,5 +714,51 @@ class TestVideoLogging:# The important thing is that the logging payload is created and recognized+def test_openai_transform_video_content_request_empty_params():+ """OpenAI content transform should return empty params to ensure GET is used."""+ config = OpenAIVideoConfig()+ url, params = config.transform_video_content_request(+ video_id="video_123",+ api_base="https://api.openai.com/v1/videos",+ litellm_params={},+ headers={},+ )++ assert url == "https://api.openai.com/v1/videos/video_123/content"+ assert params == {}+++def test_video_content_handler_uses_get_for_openai():+ """HTTP handler must use GET (not POST) for OpenAI content download."""+ handler = BaseLLMHTTPHandler()+ config = OpenAIVideoConfig()++ mock_client = MagicMock()+ mock_response = MagicMock()+ mock_response.content = b"mp4-bytes"+ mock_client.get.return_value = mock_response++ with patch(+ "litellm.llms.custom_httpx.llm_http_handler._get_httpx_client",+ return_value=mock_client,+ ):+ result = handler.video_content_handler(+ video_id="video_abc",+ video_content_provider_config=config,+ custom_llm_provider="openai",+ litellm_params={"api_base": "https://api.openai.com/v1"},+ logging_obj=MagicMock(),+ timeout=5.0,+ api_key="sk-test",+ _is_async=False,+ )++ assert result == b"mp4-bytes"+ mock_client.get.assert_called_once()+ assert not mock_client.post.called+ called_url = mock_client.get.call_args.kwargs["url"]+ assert called_url == "https://api.openai.com/v1/videos/video_abc/content"++if __name__ == "__main__":pytest.main([__file__])