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): set response=null on batch error entries per OpenAI spec
mateo-berri946dfb63c789
diff --git a/litellm/llms/vertex_ai/files/transformation.py b/litellm/llms/vertex_ai/files/transformation.pyindex 7df16723870..01b2125d030 100644--- a/litellm/llms/vertex_ai/files/transformation.py+++ b/litellm/llms/vertex_ai/files/transformation.py@@ -731,25 +731,13 @@ class VertexAIFilesConfig(VertexBase, BaseFilesConfig):has_error = bool(status)if has_error:- # Return error response in OpenAI formatreturn {"id": f"batch_req_{uuid.uuid4()}","custom_id": custom_id,- "response": {- "status_code": 400,- "request_id": "",- "body": {- "error": {- "message": status,- "type": "vertex_ai_error",- "code": "vertex_ai_error",- }- },- },+ "response": None,"error": {- "message": status,- "type": "vertex_ai_error","code": "vertex_ai_error",+ "message": status,},}@@ -789,25 +777,13 @@ class VertexAIFilesConfig(VertexBase, BaseFilesConfig):}except Exception as e:- # If transformation fails, return errorreturn {"id": f"batch_req_{uuid.uuid4()}","custom_id": custom_id,- "response": {- "status_code": 500,- "request_id": "",- "body": {- "error": {- "message": f"Failed to transform response: {str(e)}",- "type": "transformation_error",- "code": "transformation_error",- }- },- },+ "response": None,"error": {- "message": f"Failed to transform response: {str(e)}",- "type": "transformation_error","code": "transformation_error",+ "message": f"Failed to transform response: {str(e)}",},}diff --git a/tests/test_litellm/llms/vertex_ai/files/test_vertex_ai_files_transformation.py b/tests/test_litellm/llms/vertex_ai/files/test_vertex_ai_files_transformation.pyindex 4adad53a98f..58d6d2902db 100644--- a/tests/test_litellm/llms/vertex_ai/files/test_vertex_ai_files_transformation.py+++ b/tests/test_litellm/llms/vertex_ai/files/test_vertex_ai_files_transformation.py@@ -431,10 +431,12 @@ class TestVertexBatchOutputTransformation:)result = json.loads(transformed_content.decode("utf-8"))- # Verify error format- assert result["response"]["status_code"] == 400+ # Per OpenAI Batch output spec, error entries set response to null+ # and populate the top-level error object.+ assert result["response"] is Noneassert result["error"] is not Noneassert "Invalid request" in result["error"]["message"]+ assert result["error"]["code"] == "vertex_ai_error"assert result["custom_id"] == "request-error"def test_transform_vertex_batch_output_legacy_labels_only_sanitized(self, config):