Skip to content

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]

fix: update response_format test for vertex_ai's intentional schema diff

Julio Quinteros Pro9b92ea16ab6e
diff --git a/tests/test_litellm/test_utils.py b/tests/test_litellm/test_utils.py
index 7f0b3b5b501..55e635f3e17 100644
--- a/tests/test_litellm/test_utils.py
+++ b/tests/test_litellm/test_utils.py
@@ -1139,20 +1139,25 @@ def test_pre_process_non_default_params(model, custom_llm_provider):
provider_config=provider_config,
)
print(processed_non_default_params)
+ # Vertex AI / Gemini uses Pydantic's model_json_schema() which doesn't
+ # include additionalProperties: False (Gemini rejects it). Other
+ # providers use OpenAI's to_strict_json_schema() which does.
+ expected_schema = {
+ "properties": {
+ "x": {"title": "X", "type": "string"},
+ "y": {"title": "Y", "type": "string"},
+ },
+ "required": ["x", "y"],
+ "title": "ResponseFormat",
+ "type": "object",
+ }
+ if custom_llm_provider not in ("vertex_ai", "vertex_ai_beta", "gemini"):
+ expected_schema["additionalProperties"] = False
assert processed_non_default_params == {
"response_format": {
"type": "json_schema",
"json_schema": {
- "schema": {
- "properties": {
- "x": {"title": "X", "type": "string"},
- "y": {"title": "Y", "type": "string"},
- },
- "required": ["x", "y"],
- "title": "ResponseFormat",
- "type": "object",
- "additionalProperties": False,
- },
+ "schema": expected_schema,
"name": "ResponseFormat",
"strict": True,
},