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
feat: Update video metadata handling and media resolution checks for Gemini models
Vinh Pham Huu61aee29b41fa
diff --git a/litellm/llms/vertex_ai/gemini/transformation.py b/litellm/llms/vertex_ai/gemini/transformation.pyindex d49a16fa908..5eaac5e48cb 100644--- a/litellm/llms/vertex_ai/gemini/transformation.py+++ b/litellm/llms/vertex_ai/gemini/transformation.py@@ -139,14 +139,20 @@ def _apply_gemini_metadata() -> PartType:"""Apply media_resolution and video_metadata parameters to a Gemini part.- Both are supported across all Gemini models (1.x, 2.x, 3+).++ - Per-part media_resolution: Gemini 3+ only (2.x uses generation_config global).+ - video_metadata (fps, startOffset, endOffset): all Gemini models (1.x, 2.x, 3+)."""if model is None:return part+ from .vertex_and_google_ai_studio_gemini import VertexGeminiConfig+part_dict = dict(part)- if media_resolution_enum is not None:+ if media_resolution_enum is not None and VertexGeminiConfig._is_gemini_3_or_newer(+ model+ ):part_dict["media_resolution"] = media_resolution_enumif video_metadata is not None:diff --git a/tests/test_litellm/llms/vertex_ai/gemini/test_vertex_and_google_ai_studio_gemini.py b/tests/test_litellm/llms/vertex_ai/gemini/test_vertex_and_google_ai_studio_gemini.pyindex f77bba56cb4..1ea7486a515 100644--- a/tests/test_litellm/llms/vertex_ai/gemini/test_vertex_and_google_ai_studio_gemini.py+++ b/tests/test_litellm/llms/vertex_ai/gemini/test_vertex_and_google_ai_studio_gemini.py@@ -3511,8 +3511,18 @@ def test_video_metadata_supported_for_all_gemini_models():assert file_part is not None, f"{model}: file part should exist"assert "video_metadata" in file_part, f"{model}: video_metadata should be present"assert file_part["video_metadata"]["fps"] == 5, f"{model}: fps should be 5"++ # Per-part media_resolution is Gemini 3+ only; 2.x uses generation_config global+ for model in ["gemini-3-pro-preview"]:+ contents = _gemini_convert_messages_with_history(messages=messages, model=model)+ file_part = next(p for p in contents[0]["parts"] if "file_data" in p)assert "media_resolution" in file_part, f"{model}: media_resolution should be present"+ for model in ["gemini-1.5-pro", "gemini-2.5-flash", "gemini-2.5-pro"]:+ contents = _gemini_convert_messages_with_history(messages=messages, model=model)+ file_part = next(p for p in contents[0]["parts"] if "file_data" in p)+ assert "media_resolution" not in file_part, f"{model}: per-part media_resolution should not be set"+def test_chunk_parser_handles_prompt_feedback_block():"""Test chunk_parser correctly handles promptFeedback.blockReason"""