From dfc74d3806786841735d73e09110aee6a47c1b96 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 2 Sep 2026 11:48:50 +0000 Subject: [PATCH] fix(ui): show per-second pricing for video models instead of $0.00 token costs Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../components/AllModelsTable.test.tsx | 33 +++++++++++++ .../components/ModelsTableColumns.tsx | 36 +++++++------- .../utils/modelDataTransformer.test.ts | 47 +++++++++++++++++++ .../utils/modelDataTransformer.ts | 16 +++++++ .../src/components/model_dashboard/types.ts | 7 +++ .../src/components/model_info_view.test.tsx | 31 ++++++++++++ .../src/components/model_info_view.tsx | 6 +-- .../molecules/models/ModelPricingSummary.tsx | 27 +++++++++++ 8 files changed, 183 insertions(+), 20 deletions(-) create mode 100644 ui/litellm-dashboard/src/components/molecules/models/ModelPricingSummary.tsx diff --git a/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/components/AllModelsTable.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/components/AllModelsTable.test.tsx index 8ba71e82d48..3663477dd5a 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/components/AllModelsTable.test.tsx +++ b/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/components/AllModelsTable.test.tsx @@ -183,6 +183,39 @@ describe("AllModelsTable", () => { expect(screen.queryByText(/^\$/)).not.toBeInTheDocument(); }); + it("renders the per-second rate instead of $0.00 token costs for a video model priced per second", () => { + const { rerender } = render( + , + ); + expect(screen.getByText("$0.40/s")).toBeInTheDocument(); + expect(screen.queryByText("$0.00")).not.toBeInTheDocument(); + + rerender( + , + ); + expect(screen.getByText("$0.60")).toBeInTheDocument(); + expect(screen.getByText("$0.015/s")).toBeInTheDocument(); + expect(screen.queryByText("$0.00")).not.toBeInTheDocument(); + }); + it("collapses extra access groups behind a +N more badge", () => { render( + {label} + {value} + + ); +} - if (inputCost == null && outputCost == null) { +function CostsCell({ model }: { model: ModelData }) { + const { input_cost: inputCost, output_cost: outputCost, output_cost_per_second: perSecond } = model; + const hasPerSecond = perSecond != null; + const showInput = inputCost != null && (!hasPerSecond || Number(inputCost) > 0); + const showOutput = outputCost != null && (!hasPerSecond || Number(outputCost) > 0); + + if (!showInput && !showOutput && !hasPerSecond) { return -; } return ( - {inputCost != null && ( - - IN - ${inputCost} - - )} - {outputCost != null && ( - - OUT - ${outputCost} - - )} + {showInput && } + {showOutput && } + {hasPerSecond && } } /> diff --git a/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/utils/modelDataTransformer.test.ts b/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/utils/modelDataTransformer.test.ts index 42b76726922..29b017b8549 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/utils/modelDataTransformer.test.ts +++ b/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/utils/modelDataTransformer.test.ts @@ -101,6 +101,53 @@ describe("transformModelData", () => { expect(result.data[0].output_cost).toBeNull(); }); + it("keeps per-second pricing and resolution tiers for video models priced per second", () => { + const rawData = { + data: [ + { + model_name: "veo-3.1-fast", + litellm_params: { model: "vertex_ai/veo-3.1-fast-generate-001" }, + model_info: { + input_cost_per_token: 0, + output_cost_per_token: 0, + output_cost_per_second: 0.1, + output_cost_per_second_1080p: 0.12, + output_cost_per_second_4k: 0.3, + }, + }, + { + model_name: "gpt-4", + litellm_params: { model: "gpt-4" }, + model_info: { input_cost_per_token: 0.0000015, output_cost_per_token: 0.000002 }, + }, + ], + }; + + const result = transformModelData(rawData, mockGetProviderFromModel); + + expect(result.data[0].output_cost_per_second).toBe(0.1); + expect(result.data[0].output_cost_per_second_tiers).toEqual([ + { resolution: "1080p", cost: 0.12 }, + { resolution: "4k", cost: 0.3 }, + ]); + expect(result.data[1].output_cost_per_second).toBeNull(); + expect(result.data[1].output_cost_per_second_tiers).toEqual([]); + }); + + it("prefers a per-second override from litellm_params over model_info", () => { + const rawData = { + data: [ + { + model_name: "veo-3.1", + litellm_params: { model: "vertex_ai/veo-3.1-generate-001", output_cost_per_second: 0.5 }, + model_info: { output_cost_per_second: 0.4 }, + }, + ], + }; + + expect(transformModelData(rawData, mockGetProviderFromModel).data[0].output_cost_per_second).toBe(0.5); + }); + it("should handle missing model_info", () => { const rawData = { data: [ diff --git a/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/utils/modelDataTransformer.ts b/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/utils/modelDataTransformer.ts index 963fba57507..438bbc379c9 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/utils/modelDataTransformer.ts +++ b/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/utils/modelDataTransformer.ts @@ -1,3 +1,16 @@ +import { PerSecondCostTier } from "@/components/model_dashboard/types"; + +const PER_SECOND_TIER_KEY = /^output_cost_per_second_(.+)$/; + +export const perSecondCostTiers = (modelInfo: Record | null | undefined): PerSecondCostTier[] => + Object.entries(modelInfo ?? {}).flatMap(([key, value]) => { + const resolution = PER_SECOND_TIER_KEY.exec(key)?.[1]; + return resolution !== undefined && typeof value === "number" ? [{ resolution, cost: value }] : []; + }); + +export const formatPerSecondCost = (cost: number): string => + `$${cost.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 6 })}/s`; + /** * Utility function to transform raw model data into the format expected by UI components * This creates a new transformed data object without mutating the original @@ -55,6 +68,9 @@ export const transformModelData = (rawModelData: any, getProviderFromModel: (mod transformedData[i].provider = provider; transformedData[i].input_cost = input_cost; transformedData[i].output_cost = output_cost; + transformedData[i].output_cost_per_second = + curr_model?.litellm_params?.output_cost_per_second ?? model_info?.output_cost_per_second ?? null; + transformedData[i].output_cost_per_second_tiers = perSecondCostTiers(model_info); transformedData[i].litellm_model_name = litellm_model_name; // Convert Cost in terms of Cost per 1M tokens diff --git a/ui/litellm-dashboard/src/components/model_dashboard/types.ts b/ui/litellm-dashboard/src/components/model_dashboard/types.ts index e58204995dd..dd9a5b36058 100644 --- a/ui/litellm-dashboard/src/components/model_dashboard/types.ts +++ b/ui/litellm-dashboard/src/components/model_dashboard/types.ts @@ -1,3 +1,8 @@ +export interface PerSecondCostTier { + resolution: string; + cost: number; +} + export interface ModelInfo { id: string; created_at: string; @@ -27,6 +32,8 @@ export interface ModelData { litellm_model_name: string; input_cost: number; output_cost: number; + output_cost_per_second?: number | null; + output_cost_per_second_tiers?: PerSecondCostTier[]; max_tokens: number; max_input_tokens: number; api_base?: string; diff --git a/ui/litellm-dashboard/src/components/model_info_view.test.tsx b/ui/litellm-dashboard/src/components/model_info_view.test.tsx index 768183907db..b15e406b790 100644 --- a/ui/litellm-dashboard/src/components/model_info_view.test.tsx +++ b/ui/litellm-dashboard/src/components/model_info_view.test.tsx @@ -426,6 +426,37 @@ describe("ModelInfoView", () => { }); }); + it("shows per-second pricing with resolution tiers instead of $0.00 per 1M tokens for a video model", async () => { + mockUseModelsInfo.mockReturnValue({ + data: { + data: [ + { + ...defaultModelData, + model_name: "veo-3.1-fast", + litellm_params: { model: "vertex_ai/veo-3.1-fast-generate-001" }, + model_info: { + ...defaultModelData.model_info, + input_cost_per_token: 0, + output_cost_per_token: 0, + output_cost_per_second: 0.1, + output_cost_per_second_1080p: 0.12, + output_cost_per_second_4k: 0.3, + }, + }, + ], + }, + isLoading: false, + error: null, + }); + + render(, { wrapper }); + + expect(await screen.findByText("Output: $0.10/s")).toBeInTheDocument(); + expect(screen.getByText("Output (1080p): $0.12/s")).toBeInTheDocument(); + expect(screen.getByText("Output (4k): $0.30/s")).toBeInTheDocument(); + expect(screen.queryByText(/\$0\.00\/1M tokens/)).not.toBeInTheDocument(); + }); + it("should display edit settings button when user can edit model", async () => { render(, { wrapper }); await waitFor(() => { diff --git a/ui/litellm-dashboard/src/components/model_info_view.tsx b/ui/litellm-dashboard/src/components/model_info_view.tsx index 35afcdb2985..49e890a2563 100644 --- a/ui/litellm-dashboard/src/components/model_info_view.tsx +++ b/ui/litellm-dashboard/src/components/model_info_view.tsx @@ -41,6 +41,7 @@ import { testConnectionRequest, } from "./networking"; import { Logo } from "@/components/molecules/logo/Logo"; +import { ModelPricingSummary } from "@/components/molecules/models/ModelPricingSummary"; import UpdateModelCredentialsModal from "./update_model_credentials_modal"; import ModelInfoEditForm, { type ModelEditFormValues, type TouchedPricingField } from "./ModelInfoEditForm"; import { Tag } from "./tag_management/types"; @@ -698,10 +699,7 @@ export default function ModelInfoView({

Pricing

-
-

Input: ${modelData.input_cost}/1M tokens

-

Output: ${modelData.output_cost}/1M tokens

-
+
diff --git a/ui/litellm-dashboard/src/components/molecules/models/ModelPricingSummary.tsx b/ui/litellm-dashboard/src/components/molecules/models/ModelPricingSummary.tsx new file mode 100644 index 00000000000..bf0c2b6806c --- /dev/null +++ b/ui/litellm-dashboard/src/components/molecules/models/ModelPricingSummary.tsx @@ -0,0 +1,27 @@ +import { formatPerSecondCost } from "@/app/(dashboard)/models-and-endpoints/utils/modelDataTransformer"; +import { ModelData } from "@/components/model_dashboard/types"; + +type PricingFields = Pick< + ModelData, + "input_cost" | "output_cost" | "output_cost_per_second" | "output_cost_per_second_tiers" +>; + +export function ModelPricingSummary({ model }: { model: PricingFields }) { + const perSecond = model.output_cost_per_second; + const hasPerSecond = perSecond != null; + const showInput = !hasPerSecond || Number(model.input_cost) > 0; + const showOutput = !hasPerSecond || Number(model.output_cost) > 0; + + return ( +
+ {showInput &&

Input: ${model.input_cost}/1M tokens

} + {showOutput &&

Output: ${model.output_cost}/1M tokens

} + {hasPerSecond &&

Output: {formatPerSecondCost(perSecond)}

} + {(model.output_cost_per_second_tiers ?? []).map(({ resolution, cost }) => ( +

+ Output ({resolution}): {formatPerSecondCost(cost)} +

+ ))} +
+ ); +}