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
refactor(ui): type the budgets list against the generated API schema
Yuneng Jiang6a327aee6585
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/budgets/_components/BudgetTableColumns.tsx b/ui/litellm-dashboard/src/app/(dashboard)/budgets/_components/BudgetTableColumns.tsxindex 8cca2caf214..d1192468359 100644--- a/ui/litellm-dashboard/src/app/(dashboard)/budgets/_components/BudgetTableColumns.tsx+++ b/ui/litellm-dashboard/src/app/(dashboard)/budgets/_components/BudgetTableColumns.tsx@@ -26,14 +26,14 @@ import { cn } from "@/lib/cva.config";const serverFilter: FilterFn<budgetItem> = () => true;serverFilter.autoRemove = () => false;-function RateLimitCell({ value }: { value: number | null }) {+function RateLimitCell({ value }: { value: number | null | undefined }) {if (value == null) {return <span className="text-muted-foreground">n/a</span>;}return <span className="tabular-nums">{value}</span>;}-function BudgetDurationCell({ value }: { value: string | null }) {+function BudgetDurationCell({ value }: { value: string | null | undefined }) {if (!value) {return <span className="text-muted-foreground">Not set</span>;}diff --git a/ui/litellm-dashboard/src/app/(dashboard)/hooks/budgets/useBudgets.ts b/ui/litellm-dashboard/src/app/(dashboard)/hooks/budgets/useBudgets.tsindex e5f24e5412d..50151e59d3d 100644--- a/ui/litellm-dashboard/src/app/(dashboard)/hooks/budgets/useBudgets.ts+++ b/ui/litellm-dashboard/src/app/(dashboard)/hooks/budgets/useBudgets.ts@@ -6,27 +6,15 @@ import { useCallback } from "react";import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";import { apiClient, budgetCreateCall, budgetUpdateCall, budgetDeleteCall } from "@/components/networking";+import type { components } from "@/lib/http/schema";import { createQueryKeys } from "../common/queryKeysFactory";-import {- useResourceList,- type ResourceListPage,- type ResourceListQuery,- type ResourceListResult,-} from "../common/useResourceList";+import { useResourceList, type ResourceListQuery, type ResourceListResult } from "../common/useResourceList";import { serializeBudgetFilters } from "./budgetFilters";-export interface budgetItem {- budget_id: string;- max_budget: number | null;- soft_budget: number | null;- rpm_limit: number | null;- tpm_limit: number | null;- budget_duration: string | null;- budget_reset_at: string | null;- created_at: string;- updated_at: string;-}+export type budgetItem = components["schemas"]["BudgetListItem"];++type BudgetListResponse = components["schemas"]["ListResponse_BudgetListItem_"];export const BUDGET_LIST_PATH = "/management/v1/budgets";@@ -39,8 +27,8 @@ export const useBudgetList = (): ResourceListResult<budgetItem> => {const { accessToken } = useAuthorized();const fetchPage = useCallback(- (query: ResourceListQuery, signal: AbortSignal): Promise<ResourceListPage<budgetItem>> =>- apiClient.get<ResourceListPage<budgetItem>>(BUDGET_LIST_PATH, { accessToken, query, signal }),+ (query: ResourceListQuery, signal: AbortSignal): Promise<BudgetListResponse> =>+ apiClient.get<BudgetListResponse>(BUDGET_LIST_PATH, { accessToken, query, signal }),[accessToken],);diff --git a/ui/litellm-dashboard/src/app/(dashboard)/hooks/common/useResourceList.ts b/ui/litellm-dashboard/src/app/(dashboard)/hooks/common/useResourceList.tsindex fb40d108234..8a6376b2248 100644--- a/ui/litellm-dashboard/src/app/(dashboard)/hooks/common/useResourceList.ts+++ b/ui/litellm-dashboard/src/app/(dashboard)/hooks/common/useResourceList.ts@@ -5,16 +5,13 @@ import { useQuery, type UseQueryOptions } from "@tanstack/react-query";import type { ColumnFiltersState, OnChangeFn, PaginationState, SortingState } from "@tanstack/react-table";import { useCallback, useMemo, useState } from "react";+import type { components } from "@/lib/http/schema";import { DEBOUNCE_WAIT_MS } from "@/utils/debounceConstants";export type ResourceListQuery = Readonly<Record<string, string | number>>;-export interface ResourceListMeta {- total_count: number;- page: number;- page_size: number;- total_pages: number;-}+/** The management list envelope. The generated response models are monomorphic, so only `data` is generic here. */+export type ResourceListMeta = components["schemas"]["ListMeta"];export interface ResourceListPage<TRow> {data: TRow[];