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(batches): satisfy LIT010/LIT011/reportPrivateUsage budgets for new fields
mubashir1osmani2bfa1613b483
diff --git a/litellm/batches/batch_utils.py b/litellm/batches/batch_utils.pyindex 20aa3c755bd..6f6de18b04e 100644--- a/litellm/batches/batch_utils.py+++ b/litellm/batches/batch_utils.py@@ -221,8 +221,8 @@ def calculate_vertex_ai_batch_cost_and_usage(total_tokens = 0prompt_tokens = 0completion_tokens = 0- successful_requests = 0- failed_requests = 0+ successful_requests = 0 # rebind-ok: loop accumulator, matches total_cost/total_tokens above+ failed_requests = 0 # rebind-ok: loop accumulator, matches total_cost/total_tokens aboveactual_model_name: Final = model_name or "gemini-2.0-flash-001"for response in vertex_ai_batch_responses:diff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.pyindex 9d035afbde2..c795b181064 100644--- a/litellm/litellm_core_utils/litellm_logging.py+++ b/litellm/litellm_core_utils/litellm_logging.py@@ -2574,8 +2574,8 @@ class Logging(LiteLLMLoggingBaseClass):batch_cost: Final = kwargs.get("batch_cost", None)batch_usage = kwargs.get("batch_usage", None)batch_models = kwargs.get("batch_models", None)- batch_successful_requests = kwargs.get("batch_successful_requests", None)- batch_failed_requests = kwargs.get("batch_failed_requests", None)+ batch_successful_requests: Final = kwargs.get("batch_successful_requests", None)+ batch_failed_requests: Final = kwargs.get("batch_failed_requests", None)has_explicit_batch_data: Final = all(x is not None for x in (batch_cost, batch_usage, batch_models))should_compute_batch_data: Final = (@@ -2584,12 +2584,12 @@ class Logging(LiteLLMLoggingBaseClass):if has_explicit_batch_data:result._hidden_params["response_cost"] = batch_costresult._hidden_params["batch_models"] = batch_models- result._hidden_params["batch_successful_requests"] = batch_successful_requests- result._hidden_params["batch_failed_requests"] = batch_failed_requests+ result._hidden_params["batch_successful_requests"] = batch_successful_requests # pyright: ignore[reportPrivateUsage] # rebind-ok: same result._hidden_params pattern as response_cost/batch_models above+ result._hidden_params["batch_failed_requests"] = batch_failed_requests # pyright: ignore[reportPrivateUsage] # rebind-ok: same pattern as aboveresult.usage = batch_usageelif should_compute_batch_data:- batch_result = await _handle_completed_batch(+ batch_result: Final = await _handle_completed_batch(batch=result,custom_llm_provider=self.custom_llm_provider,litellm_params=self.litellm_params,@@ -2597,8 +2597,8 @@ class Logging(LiteLLMLoggingBaseClass):result._hidden_params["response_cost"] = batch_result.costresult._hidden_params["batch_models"] = batch_result.models- result._hidden_params["batch_successful_requests"] = batch_result.successful_requests- result._hidden_params["batch_failed_requests"] = batch_result.failed_requests+ result._hidden_params["batch_successful_requests"] = batch_result.successful_requests # pyright: ignore[reportPrivateUsage] # rebind-ok: same pattern as above+ result._hidden_params["batch_failed_requests"] = batch_result.failed_requests # pyright: ignore[reportPrivateUsage] # rebind-ok: same pattern as aboveresult.usage = batch_result.usagestart_time, end_time, result = self._success_handler_helper_fn(diff --git a/litellm/proxy/_types.py b/litellm/proxy/_types.pyindex 297fc1bd201..cbc8c003868 100644--- a/litellm/proxy/_types.py+++ b/litellm/proxy/_types.py@@ -15,7 +15,7 @@ from pydantic import (field_validator,model_validator,)-from typing_extensions import NotRequired, Required, TypedDict+from typing_extensions import NotRequired, ReadOnly, Required, TypedDictfrom litellm._uuid import uuidfrom litellm.constants import DEFAULT_STAGGER_WINDOW_SECONDS, MCP_STDIO_ALLOWED_COMMANDS@@ -3462,8 +3462,8 @@ class SpendLogsMetadata(TypedDict):status: StandardLoggingPayloadStatusproxy_server_request: str | Nonebatch_models: list[str] | None- batch_successful_requests: int | None- batch_failed_requests: int | None+ batch_successful_requests: ReadOnly[int | None]+ batch_failed_requests: ReadOnly[int | None]error_information: StandardLoggingPayloadErrorInformation | Noneusage_object: dict | Nonemodel_map_information: StandardLoggingModelInformation | None