From 4b33bfed412446ca2eea3502ffb2f8d9f67e8464 Mon Sep 17 00:00:00 2001 From: Ritika shrestha <87307821+ritsth@users.noreply.github.com> Date: Mon, 29 Jun 2026 13:07:48 -0700 Subject: [PATCH] fix(vertex_ai): do not advertise logprobs for gemini 3+ models Gemini 3+ does not support logprobs on Vertex AI, but get_supported_openai_params listed logprobs/top_logprobs unconditionally, so the params were forwarded and Vertex returned an opaque 400. Gate them behind _is_gemini_3_or_newer, matching the existing penalty-parameter handling, so logprobs is dropped (or cleanly rejected) for gemini 3+ while gemini 2.x keeps it. Fixes #31600 --- .../vertex_and_google_ai_studio_gemini.py | 6 ++++-- .../test_vertex_and_google_ai_studio_gemini.py | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py b/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py index 678877c0721..58096f6bd83 100644 --- a/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py +++ b/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py @@ -325,8 +325,6 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig): "stop", "extra_headers", "seed", - "logprobs", - "top_logprobs", "modalities", "audio", "parallel_tool_calls", @@ -339,6 +337,10 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig): if self._supports_penalty_parameters(model): supported_params.extend(["frequency_penalty", "presence_penalty"]) + # Gemini 3+ models do not support logprobs on Vertex AI + if not VertexGeminiConfig._is_gemini_3_or_newer(model): + supported_params.extend(["logprobs", "top_logprobs"]) + if supports_reasoning(model): supported_params.append("reasoning_effort") supported_params.append("thinking") 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.py index 20e7aec377b..b6bc50dd305 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 @@ -5210,3 +5210,20 @@ class TestModelResponseIteratorCleanup: mock_iterator.aclose.assert_awaited_once() mock_response.aclose.assert_awaited_once() + + +@pytest.mark.parametrize( + "model, expect_logprobs", + [ + ("gemini-2.5-flash", True), + ("gemini-2.5-pro", True), + ("gemini-3.5-flash", False), + ("gemini-3-pro-preview", False), + ("gemini-3.1-flash", False), + ], +) +def test_logprobs_not_advertised_for_gemini_3(model, expect_logprobs): + """Gemini 3+ does not support logprobs on Vertex AI (#31600).""" + params = VertexGeminiConfig().get_supported_openai_params(model) + assert ("logprobs" in params) is expect_logprobs + assert ("top_logprobs" in params) is expect_logprobs