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(vertex_httpx.py): Support gemini 'response_schema' param
Krrish Dholakiaaab09f5b86b8
diff --git a/litellm/llms/vertex_httpx.py b/litellm/llms/vertex_httpx.pyindex 954a30b8010..db61b129b31 100644--- a/litellm/llms/vertex_httpx.py+++ b/litellm/llms/vertex_httpx.py@@ -182,7 +182,12 @@ class GoogleAIStudioGeminiConfig: # key diff from VertexAI - 'frequency_penaltyif param == "max_tokens":optional_params["max_output_tokens"] = valueif param == "response_format" and value["type"] == "json_object": # type: ignore- optional_params["response_mime_type"] = "application/json"+ if value["type"] == "json_object": # type: ignore+ optional_params["response_mime_type"] = "application/json"+ elif value["type"] == "text": # type: ignore+ optional_params["response_mime_type"] = "text/plain"+ if "response_schema" in value: # type: ignore+ optional_params["response_schema"] = value["response_schema"] # type: ignoreif param == "tools" and isinstance(value, list):gtool_func_declarations = []for tool in value:diff --git a/litellm/tests/test_amazing_vertex_completion.py b/litellm/tests/test_amazing_vertex_completion.pyindex f0b243c36eb..4338d63ba60 100644--- a/litellm/tests/test_amazing_vertex_completion.py+++ b/litellm/tests/test_amazing_vertex_completion.py@@ -903,10 +903,10 @@ from litellm.tests.test_completion import response_format_tests@pytest.mark.parametrize("model",[- # "vertex_ai/mistral-large@2407",- # "vertex_ai/mistral-nemo@2407",+ "vertex_ai/mistral-large@2407",+ "vertex_ai/mistral-nemo@2407","vertex_ai/codestral@2405",- # "vertex_ai/meta/llama3-405b-instruct-maas",+ "vertex_ai/meta/llama3-405b-instruct-maas",], #) # "vertex_ai",@pytest.mark.parametrize(@@ -1347,6 +1347,7 @@ def vertex_httpx_mock_post_invalid_schema_response_anthropic(*args, **kwargs):"model, vertex_location, supports_response_schema",[("vertex_ai_beta/gemini-1.5-pro-001", "us-central1", True),+ ("gemini/gemini-1.5-pro", None, True),("vertex_ai_beta/gemini-1.5-flash", "us-central1", False),("vertex_ai/claude-3-5-sonnet@20240620", "us-east5", False),],