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: generation config empty for batch

Sameer Kankutec374345e12fd
diff --git a/litellm/batches/main.py b/litellm/batches/main.py
index 126eb09a51c..3367f567a7f 100644
--- a/litellm/batches/main.py
+++ b/litellm/batches/main.py
@@ -404,6 +404,7 @@ def _handle_retrieve_batch_providers_without_provider_config(
_retrieve_batch_request: RetrieveBatchRequest,
_is_async: bool,
custom_llm_provider: Literal["openai", "azure", "vertex_ai", "bedrock", "hosted_vllm", "anthropic"] = "openai",
+ logging_obj: Optional[Any] = None,
):
api_base: Optional[str] = None
if custom_llm_provider in OPENAI_COMPATIBLE_BATCH_AND_FILES_PROVIDERS:
@@ -499,6 +500,7 @@ def _handle_retrieve_batch_providers_without_provider_config(
vertex_credentials=vertex_credentials,
timeout=timeout,
max_retries=optional_params.max_retries,
+ logging_obj=logging_obj,
)
elif custom_llm_provider == "anthropic":
api_base = (
@@ -662,6 +664,7 @@ def retrieve_batch(
_retrieve_batch_request=_retrieve_batch_request,
_is_async=_is_async,
timeout=timeout,
+ logging_obj=litellm_logging_obj,
)
except Exception as e:
diff --git a/litellm/llms/vertex_ai/batches/handler.py b/litellm/llms/vertex_ai/batches/handler.py
index 12ce8b48aaf..36f5e65e7a2 100644
--- a/litellm/llms/vertex_ai/batches/handler.py
+++ b/litellm/llms/vertex_ai/batches/handler.py
@@ -142,6 +142,7 @@ class VertexAIBatchPrediction(VertexLLM):
vertex_location: Optional[str],
timeout: Union[float, httpx.Timeout],
max_retries: Optional[int],
+ logging_obj: Optional[Any] = None,
) -> Union[LiteLLMBatch, Coroutine[Any, Any, LiteLLMBatch]]:
sync_handler = _get_httpx_client()
@@ -187,8 +188,30 @@ class VertexAIBatchPrediction(VertexLLM):
return self._async_retrieve_batch(
api_base=api_base,
headers=headers,
+ logging_obj=logging_obj,
)
+ # Log the request using logging_obj if available
+ if logging_obj is not None:
+ from litellm.litellm_core_utils.litellm_logging import Logging
+ if isinstance(logging_obj, Logging):
+ logging_obj.pre_call(
+ input="",
+ api_key="",
+ additional_args={
+ "complete_input_dict": {},
+ "api_base": api_base,
+ "headers": headers,
+ "request_str": (
+ f"\nGET Request Sent from LiteLLM:\n"
+ f"curl -X GET \\\n"
+ f"{api_base} \\\n"
+ f"-H 'Authorization: Bearer ***REDACTED***' \\\n"
+ f"-H 'Content-Type: application/json; charset=utf-8'\n"
+ ),
+ },
+ )
+
response = sync_handler.get(
url=api_base,
headers=headers,
@@ -207,10 +230,33 @@ class VertexAIBatchPrediction(VertexLLM):
self,
api_base: str,
headers: Dict[str, str],
+ logging_obj: Optional[Any] = None,
) -> LiteLLMBatch:
client = get_async_httpx_client(
llm_provider=litellm.LlmProviders.VERTEX_AI,
)
+
+ # Log the request using logging_obj if available
+ if logging_obj is not None:
+ from litellm.litellm_core_utils.litellm_logging import Logging
+ if isinstance(logging_obj, Logging):
+ logging_obj.pre_call(
+ input="",
+ api_key="",
+ additional_args={
+ "complete_input_dict": {},
+ "api_base": api_base,
+ "headers": headers,
+ "request_str": (
+ f"\nGET Request Sent from LiteLLM:\n"
+ f"curl -X GET \\\n"
+ f"{api_base} \\\n"
+ f"-H 'Authorization: Bearer ***REDACTED***' \\\n"
+ f"-H 'Content-Type: application/json; charset=utf-8'\n"
+ ),
+ },
+ )
+
response = await client.get(
url=api_base,
headers=headers,
diff --git a/litellm/llms/vertex_ai/gemini/transformation.py b/litellm/llms/vertex_ai/gemini/transformation.py
index 96e0963a920..3004f39b973 100644
--- a/litellm/llms/vertex_ai/gemini/transformation.py
+++ b/litellm/llms/vertex_ai/gemini/transformation.py
@@ -591,7 +591,7 @@ def _transform_request_body(
data["toolConfig"] = tool_choice
if safety_settings is not None:
data["safetySettings"] = safety_settings
- if generation_config is not None:
+ if generation_config is not None and len(generation_config) > 0:
data["generationConfig"] = generation_config
if cached_content is not None:
data["cachedContent"] = cached_content