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]

only added the helper that converts

naaa760a24b43cbdfbe
diff --git a/litellm/llms/vertex_ai/batches/transformation.py b/litellm/llms/vertex_ai/batches/transformation.py
index 22cd0bd402a..a0adb3e55a8 100644
--- a/litellm/llms/vertex_ai/batches/transformation.py
+++ b/litellm/llms/vertex_ai/batches/transformation.py
@@ -1,5 +1,5 @@
from litellm._uuid import uuid
-from typing import Dict
+from typing import Any, Dict
from litellm.llms.vertex_ai.common_utils import (
_convert_vertex_datetime_to_openai_datetime,
@@ -67,6 +67,33 @@ class VertexAIBatchTransformation:
),
)
+ @classmethod
+ def transform_vertex_ai_batch_list_response_to_openai_list_response(
+ cls, response: Dict[str, Any]
+ ) -> Dict[str, Any]:
+ """
+ Transforms Vertex AI batch list response into OpenAI-compatible list response.
+ """
+
+ batch_jobs = response.get("batchPredictionJobs", []) or []
+ data = [
+ cls.transform_vertex_ai_batch_response_to_openai_batch_response(job)
+ for job in batch_jobs
+ ]
+
+ first_id = data[0].id if len(data) > 0 else None
+ last_id = data[-1].id if len(data) > 0 else None
+ next_page_token = response.get("nextPageToken")
+
+ return {
+ "object": "list",
+ "data": data,
+ "first_id": first_id,
+ "last_id": last_id,
+ "has_more": bool(next_page_token),
+ "next_page_token": next_page_token,
+ }
+
@classmethod
def _get_batch_id_from_vertex_ai_batch_response(
cls, response: VertexBatchPredictionResponse