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
fix(vertex_ai): default missing items on array schemas
mateo-berri860843953daa
diff --git a/litellm/llms/vertex_ai/common_utils.py b/litellm/llms/vertex_ai/common_utils.pyindex ccd4d4f2934..8a6b5ddd70b 100644--- a/litellm/llms/vertex_ai/common_utils.py+++ b/litellm/llms/vertex_ai/common_utils.py@@ -599,6 +599,8 @@ def process_items(schema, depth=0):if isinstance(schema, dict):if "items" in schema and schema["items"] == {}:schema["items"] = {"type": "object"}+ elif schema.get("type") == "array" and "items" not in schema:+ schema["items"] = {"type": "object"}for key, value in schema.items():if isinstance(value, dict):process_items(value, depth + 1)diff --git a/tests/test_litellm/llms/vertex_ai/test_vertex_ai_common_utils.py b/tests/test_litellm/llms/vertex_ai/test_vertex_ai_common_utils.pyindex ef93375c3cd..5d8dec75456 100644--- a/tests/test_litellm/llms/vertex_ai/test_vertex_ai_common_utils.py+++ b/tests/test_litellm/llms/vertex_ai/test_vertex_ai_common_utils.py@@ -225,7 +225,11 @@ def test_build_vertex_schema():"metadata": {"type": "object"},"callbacks": {"anyOf": [- {"type": "array", "nullable": True},+ {+ "type": "array",+ "items": {"type": "object"},+ "nullable": True,+ },{"type": "object", "nullable": True},]},@@ -288,6 +292,23 @@ def test_process_items_basic():process_items(schema)assert schema["properties"]["nested"]["items"] == {"type": "object"}+ # Test array with no items field at all - Vertex requires items to be present+ schema = {"type": "array"}+ process_items(schema)+ assert schema["items"] == {"type": "object"}++ # Test array missing items inside anyOf branch+ schema = {+ "type": "object",+ "properties": {+ "callbacks": {+ "anyOf": [{"type": "array"}, {"type": "object"}],+ }+ },+ }+ process_items(schema)+ assert schema["properties"]["callbacks"]["anyOf"][0]["items"] == {"type": "object"}+def test_vertex_ai_complex_response_schema():import json