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(batches): satisfy LIT010/LIT011/reportPrivateUsage budgets for new fields

mubashir1osmani2bfa1613b483
diff --git a/litellm/batches/batch_utils.py b/litellm/batches/batch_utils.py
index 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 = 0
prompt_tokens = 0
completion_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 above
actual_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.py
index 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_cost
result._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 above
result.usage = batch_usage
elif 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.cost
result._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 above
result.usage = batch_result.usage
start_time, end_time, result = self._success_handler_helper_fn(
diff --git a/litellm/proxy/_types.py b/litellm/proxy/_types.py
index 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, TypedDict
from litellm._uuid import uuid
from litellm.constants import DEFAULT_STAGGER_WINDOW_SECONDS, MCP_STDIO_ALLOWED_COMMANDS
@@ -3462,8 +3462,8 @@ class SpendLogsMetadata(TypedDict):
status: StandardLoggingPayloadStatus
proxy_server_request: str | None
batch_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 | None
usage_object: dict | None
model_map_information: StandardLoggingModelInformation | None