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): narrow batch cost kwargs before the breakdown and drop node access in test

mubashir1osmani538cd2c3b00d
diff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.py
index 3a616e7961d..03486f4f729 100644
--- a/litellm/litellm_core_utils/litellm_logging.py
+++ b/litellm/litellm_core_utils/litellm_logging.py
@@ -2906,7 +2906,11 @@ class Logging(LiteLLMLoggingBaseClass):
result.usage = batch_usage
batch_prompt_cost: Final = kwargs.get("batch_prompt_cost", None)
batch_completion_cost: Final = kwargs.get("batch_completion_cost", None)
- if batch_prompt_cost is not None and batch_completion_cost is not None:
+ if (
+ isinstance(batch_prompt_cost, float)
+ and isinstance(batch_completion_cost, float)
+ and isinstance(batch_cost, float)
+ ):
self.set_cost_breakdown(
input_cost=batch_prompt_cost,
output_cost=batch_completion_cost,
diff --git a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailContent.test.tsx b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailContent.test.tsx
index 91778d2a98a..a893e9bffd0 100644
--- a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailContent.test.tsx
+++ b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailContent.test.tsx
@@ -163,11 +163,13 @@ describe("LogDetailContent", () => {
/>,
);
- const section = screen.getByText("Batch Results").closest('[data-slot="card"]') as HTMLElement;
- expect(within(section).getByText("batch_abc123")).toBeInTheDocument();
- expect(within(section).getByText("2")).toBeInTheDocument();
- expect(within(section).getByText("1")).toBeInTheDocument();
- expect(within(section).getByText("gemini-2.5-flash")).toBeInTheDocument();
+ expect(screen.getByText("Batch Results")).toBeInTheDocument();
+ expect(screen.getByText("batch_abc123")).toBeInTheDocument();
+ expect(screen.getByText("Successful Requests")).toBeInTheDocument();
+ expect(screen.getByText("2")).toBeInTheDocument();
+ expect(screen.getByText("Failed Requests")).toBeInTheDocument();
+ expect(screen.getByText("1")).toBeInTheDocument();
+ expect(screen.getByText("gemini-2.5-flash")).toBeInTheDocument();
});
it("still renders the batch id when a legacy row carries no counts", () => {