Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion litellm/llms/vertex_ai/common_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def supports_response_json_schema(model: str) -> bool:

# Gemini 2.0+ and 2.5+ models support responseJsonSchema
# Pattern matches: gemini-2.0-*, gemini-2.5-*, gemini-3-*, etc.
gemini_2_plus_pattern = re.compile(r"gemini-([2-9]|[1-9]\d+)\.")
gemini_2_plus_pattern = re.compile(r"gemini-(?:[2-9]|[1-9]\d+)(?:\.|\-)")

@clpatterson clpatterson Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made these non-capture groups (?:) because there is no need to use results from the regex matches later, so no need to store in memory.

This regex pattern now correctly matches gemini-3-*. The previous pattern assumed that each model name has a generation number and point release number separated by a period (i.e. gemini-2.5-*) but did not support model names where only a generation number is provided (i.e. gemini-3-flash-preview).


return bool(gemini_2_plus_pattern.search(model_lower))

Expand Down
24 changes: 19 additions & 5 deletions tests/test_litellm/llms/vertex_ai/test_vertex_ai_common_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
get_vertex_project_id_from_url,
pop_vertex_request_labels,
set_schema_property_ordering,
supports_response_json_schema,
vertex_request_labels_from_litellm_params,
)

Expand Down Expand Up @@ -150,6 +151,23 @@ async def test_get_supports_system_message():
assert result == False


@pytest.mark.parametrize(
"model, expected",
[
("gemini-2.0-flash", True),
("gemini-1.5-pro", False),
("random-model-name", False),
("gemini-3-flash-preview", True),
("gemini-123-pro", True),
("vertex_ai/gemini-3.1-pro-preview", True),
],
)
def test_supports_response_json_schema(model: str, expected: bool):
"""Test supports_response_json_schema correctly detects Gemini 2.0+ model names"""

assert supports_response_json_schema(model) == expected


def test_set_schema_property_ordering_with_excessive_nesting():
"""Test set_schema_property_ordering with excessive nesting > max levels +1 deep."""
# generate a schema with excessive nesting
Expand Down Expand Up @@ -1526,11 +1544,7 @@ def test_vertex_request_labels_from_litellm_params_extracts_requester_metadata()


def test_vertex_request_labels_from_litellm_params_accepts_litellm_metadata():
lp = {
"litellm_metadata": {
"requester_metadata": {"team": "platform", "count": 3}
}
}
lp = {"litellm_metadata": {"requester_metadata": {"team": "platform", "count": 3}}}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

result of running formatting on the file.

assert vertex_request_labels_from_litellm_params(lp) == {"team": "platform"}


Expand Down
Loading