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(ui): show and edit key-level router settings on a virtual key (#36674)

Yassin Kortam50ff555d7900
diff --git a/ui/litellm-dashboard/src/components/common_components/RouterSettingsSummary.test.tsx b/ui/litellm-dashboard/src/components/common_components/RouterSettingsSummary.test.tsx
new file mode 100644
index 00000000000..51eecc421a7
--- /dev/null
+++ b/ui/litellm-dashboard/src/components/common_components/RouterSettingsSummary.test.tsx
@@ -0,0 +1,28 @@
+import { render, screen } from "@testing-library/react";
+import { describe, expect, it } from "vitest";
+import RouterSettingsSummary from "./RouterSettingsSummary";
+
+describe("RouterSettingsSummary", () => {
+ it("should list each configured fallback mapping", () => {
+ render(
+ <RouterSettingsSummary
+ routerSettings={{
+ fallbacks: [{ "gpt-4": ["gpt-4o", "claude-sonnet"] }, { "gpt-4o": ["gpt-4o-mini"] }],
+ num_retries: 3,
+ }}
+ />,
+ );
+
+ expect(screen.getByText("gpt-4")).toBeInTheDocument();
+ expect(screen.getByText("gpt-4o, claude-sonnet")).toBeInTheDocument();
+ expect(screen.getByText("gpt-4o")).toBeInTheDocument();
+ expect(screen.getByText("gpt-4o-mini")).toBeInTheDocument();
+ expect(screen.getByText("Number of Retries: 3")).toBeInTheDocument();
+ });
+
+ it("should show the empty state when every setting is null", () => {
+ render(<RouterSettingsSummary routerSettings={{ fallbacks: null, num_retries: null }} />);
+
+ expect(screen.getByText("No router settings configured")).toBeInTheDocument();
+ });
+});
diff --git a/ui/litellm-dashboard/src/components/common_components/RouterSettingsSummary.tsx b/ui/litellm-dashboard/src/components/common_components/RouterSettingsSummary.tsx
new file mode 100644
index 00000000000..daaddc0cdfb
--- /dev/null
+++ b/ui/litellm-dashboard/src/components/common_components/RouterSettingsSummary.tsx
@@ -0,0 +1,56 @@
+import { Badge } from "@/components/ui/badge";
+import { hasRouterSettings } from "./routerSettingsPayload";
+
+interface RouterSettingsSummaryProps {
+ routerSettings: Record<string, unknown> | null | undefined;
+ emptyText?: string;
+}
+
+const fallbackEntries = (fallbacks: unknown): Array<[string, string[]]> => {
+ if (!Array.isArray(fallbacks)) return [];
+ return fallbacks.flatMap((entry) =>
+ entry && typeof entry === "object" ? (Object.entries(entry) as Array<[string, string[]]>) : [],
+ );
+};
+
+export default function RouterSettingsSummary({
+ routerSettings,
+ emptyText = "No router settings configured",
+}: RouterSettingsSummaryProps) {
+ if (!hasRouterSettings(routerSettings)) {
+ return <div className="text-gray-400">{emptyText}</div>;
+ }
+
+ const settings = routerSettings as Record<string, unknown>;
+ const fallbacks = fallbackEntries(settings.fallbacks);
+
+ return (
+ <div className="space-y-1 text-sm">
+ {settings.routing_strategy != null && (
+ <div>
+ Routing Strategy: <Badge variant="secondary">{String(settings.routing_strategy)}</Badge>
+ </div>
+ )}
+ {settings.num_retries != null && <div>Number of Retries: {String(settings.num_retries)}</div>}
+ {settings.allowed_fails != null && <div>Allowed Failures: {String(settings.allowed_fails)}</div>}
+ {settings.cooldown_time != null && <div>Cooldown Time: {String(settings.cooldown_time)}s</div>}
+ {settings.timeout != null && <div>Timeout: {String(settings.timeout)}s</div>}
+ {settings.retry_after != null && <div>Retry After: {String(settings.retry_after)}s</div>}
+ {Boolean(settings.enable_tag_filtering) && <div>Tag Filtering: Enabled</div>}
+ {fallbacks.length > 0 && (
+ <div>
+ <div>Fallbacks:</div>
+ <div className="mt-1 space-y-1">
+ {fallbacks.map(([model, targets]) => (
+ <div key={model} className="text-xs text-gray-600">
+ <span className="font-medium">{model}</span>
+ <span className="mx-1 text-gray-400">-&gt;</span>
+ {Array.isArray(targets) ? targets.join(", ") : String(targets)}
+ </div>
+ ))}
+ </div>
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/ui/litellm-dashboard/src/components/common_components/routerSettingsPayload.test.ts b/ui/litellm-dashboard/src/components/common_components/routerSettingsPayload.test.ts
new file mode 100644
index 00000000000..542ed17d7a2
--- /dev/null
+++ b/ui/litellm-dashboard/src/components/common_components/routerSettingsPayload.test.ts
@@ -0,0 +1,115 @@
+import { describe, expect, it } from "vitest";
+import { hasRouterSettings, routerSettingsEditorValue, routerSettingsUpdate } from "./routerSettingsPayload";
+
+describe("hasRouterSettings", () => {
+ it("should treat unset, empty and all-null settings as absent", () => {
+ expect(hasRouterSettings(undefined)).toBe(false);
+ expect(hasRouterSettings(null)).toBe(false);
+ expect(hasRouterSettings({})).toBe(false);
+ expect(
+ hasRouterSettings({ num_retries: null, fallbacks: [], model_group_alias: {}, enable_tag_filtering: false }),
+ ).toBe(false);
+ });
+
+ it("should detect configured settings", () => {
+ expect(hasRouterSettings({ num_retries: 3 })).toBe(true);
+ expect(hasRouterSettings({ fallbacks: [{ "gpt-4": ["gpt-4o"] }] })).toBe(true);
+ expect(hasRouterSettings({ enable_tag_filtering: true })).toBe(true);
+ expect(hasRouterSettings({ num_retries: 0 })).toBe(true);
+ });
+});
+
+describe("routerSettingsEditorValue", () => {
+ it("should hand the editor only the fields it renders", () => {
+ expect(
+ routerSettingsEditorValue({
+ num_retries: 2,
+ tag_routing_prefix: "team-",
+ fallbacks: [{ "gpt-4": ["gpt-4o"] }],
+ }),
+ ).toStrictEqual({ router_settings: { num_retries: 2, fallbacks: [{ "gpt-4": ["gpt-4o"] }] } });
+ });
+
+ it("should keep an explicitly stored null so the editor renders it as empty", () => {
+ expect(routerSettingsEditorValue({ num_retries: null })).toStrictEqual({ router_settings: { num_retries: null } });
+ });
+
+ it("should leave the editor uninitialised when the key has no stored settings", () => {
+ expect(routerSettingsEditorValue(null)).toBeUndefined();
+ expect(routerSettingsEditorValue(undefined)).toBeUndefined();
+ });
+});
+
+describe("routerSettingsUpdate", () => {
+ const fallbacks = [{ "gpt-4": ["gpt-4o"] }];
+ // Accepted by UpdateRouterConfig on /key/update but not rendered by the accordion.
+ const unsupported = {
+ tag_routing_prefix: "team-",
+ model_group_retry_policy: { "gpt-4": { TimeoutErrorRetries: 2 } },
+ };
+
+ // The editor is a fixed-field form, so the merge has to hold two opposing guarantees at once:
+ // routing fields it cannot render survive, and a field it does render that the admin emptied
+ // is still sent as null. Orderings vary because an object spread resolves collisions by position.
+ const storedOrderings: Array<[string, Record<string, unknown>]> = [
+ ["unsupported fields first", { ...unsupported, num_retries: 2, fallbacks }],
+ ["unsupported fields last", { num_retries: 2, fallbacks, ...unsupported }],
+ [
+ "unsupported fields interleaved",
+ {
+ tag_routing_prefix: unsupported.tag_routing_prefix,
+ num_retries: 2,
+ model_group_retry_policy: unsupported.model_group_retry_policy,
+ fallbacks,
+ },
+ ],
+ ];
+
+ it.each(storedOrderings)(
+ "should keep unsupported stored fields and still clear an emptied editor field (%s)",
+ (_ordering, stored) => {
+ const result = routerSettingsUpdate({ num_retries: 4, fallbacks: null }, stored);
+
+ expect(result).toMatchObject({ ...unsupported, num_retries: 4, fallbacks: null });
+ },
+ );
+
+ it("should send an empty object, not a null blob, when the last stored setting is cleared", () => {
+ expect(routerSettingsUpdate({ fallbacks: null, num_retries: null }, { fallbacks, num_retries: 2 })).toEqual({});
+ });
+
+ it("should keep clearing owned fields explicitly while an unsupported setting still stands", () => {
+ expect(routerSettingsUpdate({ fallbacks: null, num_retries: null }, { fallbacks, ...unsupported })).toMatchObject({
+ ...unsupported,
+ fallbacks: null,
+ num_retries: null,
+ });
+ });
+
+ it("should null every editor-owned field the editor left out", () => {
+ expect(routerSettingsUpdate({ fallbacks: null }, { timeout: 30, ...unsupported })).toEqual({
+ ...unsupported,
+ routing_strategy: null,
+ allowed_fails: null,
+ cooldown_time: null,
+ num_retries: null,
+ timeout: null,
+ retry_after: null,
+ fallbacks: null,
+ context_window_fallbacks: null,
+ retry_policy: null,
+ model_group_alias: null,
+ enable_tag_filtering: null,
+ routing_strategy_args: null,
+ });
+ });
+
+ it("should send the edited settings when the user configured something", () => {
+ expect(routerSettingsUpdate({ fallbacks }, null)).toMatchObject({ fallbacks });
+ });
+
+ it("should leave the field off when nothing is stored and nothing was configured", () => {
+ expect(routerSettingsUpdate({ fallbacks: null, num_retries: null }, {})).toBeUndefined();
+ expect(routerSettingsUpdate(undefined, { fallbacks })).toBeUndefined();
+ });
+});
diff --git a/ui/litellm-dashboard/src/components/common_components/routerSettingsPayload.ts b/ui/litellm-dashboard/src/components/common_components/routerSettingsPayload.ts
new file mode 100644
index 00000000000..1d048425a6d
--- /dev/null
+++ b/ui/litellm-dashboard/src/components/common_components/routerSettingsPayload.ts
@@ -0,0 +1,63 @@
+import { RouterSettingsAccordionValue } from "./RouterSettingsAccordion";
+
+export type RouterSettings = RouterSettingsAccordionValue["router_settings"];
+
+const EDITOR_OWNED_FIELDS: Record<keyof RouterSettings, true> = {
+ routing_strategy: true,
+ allowed_fails: true,
+ cooldown_time: true,
+ num_retries: true,
+ timeout: true,
+ retry_after: true,
+ fallbacks: true,
+ context_window_fallbacks: true,
+ retry_policy: true,
+ model_group_alias: true,
+ enable_tag_filtering: true,
+ routing_strategy_args: true,
+};
+
+const EDITOR_OWNED_KEYS = Object.keys(EDITOR_OWNED_FIELDS) as Array<keyof RouterSettings>;
+
+const isMeaningfulRouterSetting = (value: unknown): boolean => {
+ if (value === null || value === undefined || value === "" || value === false) return false;
+ if (Array.isArray(value)) return value.length > 0;
+ if (typeof value === "object") return Object.keys(value).length > 0;
+ return true;
+};
+
+export const hasRouterSettings = (settings: Record<string, unknown> | null | undefined): boolean =>
+ settings != null && Object.values(settings).some(isMeaningfulRouterSetting);
+
+/**
+ * The stored settings narrowed to what the editor renders. The stored blob is untyped JSON
+ * from /key/info, so this projection is the one place it is read as RouterSettings.
+ */
+export const routerSettingsEditorValue = (
+ stored: Record<string, unknown> | null | undefined,
+): RouterSettingsAccordionValue | undefined =>
+ stored
+ ? {
+ router_settings: Object.fromEntries(
+ EDITOR_OWNED_KEYS.filter((key) => key in stored).map((key) => [key, stored[key]]),
+ ) as RouterSettings,
+ }
+ : undefined;
+
+/**
+ * Router settings to put on a /key/update payload, or undefined to leave the field off.
+ * The editor only renders EDITOR_OWNED_FIELDS, so its value is merged over the stored object
+ * rather than replacing it, and routing fields the editor cannot show survive an unrelated edit.
+ * Emptying every field sends {}, which the proxy reads as "no key-level override" so the key
+ * falls back to its team and global settings, where an all-null blob would pin it to nulls.
+ */
+export const routerSettingsUpdate = (
+ edited: RouterSettings | null | undefined,
+ stored: Record<string, unknown> | null | undefined,
+): Record<string, unknown> | undefined => {
+ if (!edited) return undefined;
+ const editorOwned = Object.fromEntries(EDITOR_OWNED_KEYS.map((key) => [key, edited[key] ?? null]));
+ const merged: Record<string, unknown> = { ...stored, ...editorOwned };
+ if (hasRouterSettings(merged)) return merged;
+ return hasRouterSettings(stored) ? {} : undefined;
+};
diff --git a/ui/litellm-dashboard/src/components/common_components/routerSettingsWiring.test.tsx b/ui/litellm-dashboard/src/components/common_components/routerSettingsWiring.test.tsx
new file mode 100644
index 00000000000..d6ed0ae07db
--- /dev/null
+++ b/ui/litellm-dashboard/src/components/common_components/routerSettingsWiring.test.tsx
@@ -0,0 +1,79 @@
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import { render, screen, waitFor } from "@testing-library/react";
+import type { ReactElement, ReactNode } from "react";
+import { describe, expect, it, vi } from "vitest";
+import type { FallbackGroup } from "../Settings/RouterSettings/Fallbacks/FallbackGroupConfig";
+import type { RouterSettingsFormValue } from "../router_settings/RouterSettingsForm";
+import RouterSettingsAccordion from "./RouterSettingsAccordion";
+import { routerSettingsEditorValue } from "./routerSettingsPayload";
+
+vi.mock("../networking", () => ({
+ getRouterSettingsCall: vi.fn().mockResolvedValue({}),
+}));
+
+vi.mock("@/components/llm_calls/fetch_models", () => ({
+ fetchAvailableModels: vi.fn().mockResolvedValue([{ model_group: "gpt-5.5" }, { model_group: "gpt-4o-mini" }]),
+ fetchAvailableModelsForTeam: vi.fn().mockResolvedValue([]),
+}));
+
+vi.mock("@tremor/react", () => ({
+ TabGroup: ({ children }: { children: ReactNode }) => <div>{children}</div>,
+ TabList: ({ children }: { children: ReactNode }) => <div>{children}</div>,
+ Tab: ({ children }: { children: ReactNode }) => <div>{children}</div>,
+ TabPanels: ({ children }: { children: ReactNode }) => <div>{children}</div>,
+ TabPanel: ({ children }: { children: ReactNode }) => <div>{children}</div>,
+}));
+
+vi.mock("../router_settings/RouterSettingsForm", () => ({
+ default: ({ value }: { value: RouterSettingsFormValue }) => (
+ <div data-testid="loadbalancing">{JSON.stringify(value.routerSettings)}</div>
+ ),
+}));
+
+vi.mock("../Settings/RouterSettings/Fallbacks/FallbackSelectionForm", () => ({
+ FallbackSelectionForm: ({ groups }: { groups: FallbackGroup[] }) => (
+ <div data-testid="fallbacks">
+ {groups.map((g) => `${g.primaryModel ?? "none"}->${g.fallbackModels.join("|") || "none"}`).join(" ")}
+ </div>
+ ),
+}));
+
+// Captured verbatim from GET /key/info on a live proxy for a key created through the UI.
+// tag_routing_prefix is stored on the key and accepted by /key/update, but the accordion
+// has no control for it, so the projection must drop it without losing the rest.
+const KEY_INFO_ROUTER_SETTINGS: Record<string, unknown> = {
+ fallbacks: [{ "gpt-5.5": ["gpt-4o-mini"] }],
+ num_retries: 3,
+ tag_routing_prefix: "team-",
+};
+
+const renderAccordion = (stored: Record<string, unknown> | null): ReactElement => (
+ <QueryClientProvider client={new QueryClient({ defaultOptions: { queries: { retry: false } } })}>
+ <RouterSettingsAccordion accessToken="test-token" value={routerSettingsEditorValue(stored)} />
+ </QueryClientProvider>
+);
+
+describe("key router settings wiring, /key/info payload through to rendered output", () => {
+ it("should prefill both tabs from the stored settings", async () => {
+ render(renderAccordion(KEY_INFO_ROUTER_SETTINGS));
+
+ await waitFor(() => {
+ expect(screen.getByTestId("fallbacks")).toHaveTextContent("gpt-5.5->gpt-4o-mini");
+ });
+ expect(JSON.parse(screen.getByTestId("loadbalancing").textContent ?? "{}")).toMatchObject({ num_retries: 3 });
+ });
+
+ it("should not leak a field the accordion has no control for into the editor", async () => {
+ render(renderAccordion(KEY_INFO_ROUTER_SETTINGS));
+
+ await waitFor(() => expect(screen.getByTestId("loadbalancing")).toBeInTheDocument());
+ expect(screen.getByTestId("loadbalancing").textContent).not.toContain("tag_routing_prefix");
+ });
+
+ it("should render an empty editor for a key holding only fields it cannot show", async () => {
+ render(renderAccordion({ tag_routing_prefix: "team-" }));
+
+ await waitFor(() => expect(screen.getByTestId("fallbacks")).toHaveTextContent("none->none"));
+ expect(JSON.parse(screen.getByTestId("loadbalancing").textContent ?? "null")).toEqual({});
+ });
+});
diff --git a/ui/litellm-dashboard/src/components/key_team_helpers/key_list.tsx b/ui/litellm-dashboard/src/components/key_team_helpers/key_list.tsx
index 920d1f4af5a..caa5e0a38f0 100644
--- a/ui/litellm-dashboard/src/components/key_team_helpers/key_list.tsx
+++ b/ui/litellm-dashboard/src/components/key_team_helpers/key_list.tsx
@@ -95,6 +95,7 @@ export interface KeyResponse {
object_permission?: ObjectPermission | null;
access_group_ids?: string[];
budget_fallbacks?: Record<string, string[]>;
+ router_settings?: Record<string, unknown> | null;
budget_limits?: Array<{ budget_duration: string; max_budget: number; reset_at?: string }>;
auto_rotate?: boolean;
rotation_interval?: string;
diff --git a/ui/litellm-dashboard/src/components/templates/key_edit_view.test.tsx b/ui/litellm-dashboard/src/components/templates/key_edit_view.test.tsx
index fb8ab87e45f..caad6fc30fc 100644
--- a/ui/litellm-dashboard/src/components/templates/key_edit_view.test.tsx
+++ b/ui/litellm-dashboard/src/components/templates/key_edit_view.test.tsx
@@ -59,6 +59,24 @@ vi.mock("../organisms/create_key_button", () => ({
fetchTeamModels: vi.fn().mockResolvedValue(["team-model-1", "team-model-2"]),
}));
+const routerSettingsMocks = vi.hoisted(() => ({
+ receivedValue: undefined as { router_settings: Record<string, unknown> } | undefined,
+ editedValue: null as Record<string, unknown> | null,
+}));
+
+vi.mock("../common_components/RouterSettingsAccordion", async () => {
+ const { forwardRef, useImperativeHandle } = await import("react");
+ return {
+ default: forwardRef(({ value }: { value?: { router_settings: Record<string, unknown> } }, ref) => {
+ routerSettingsMocks.receivedValue = value;
+ useImperativeHandle(ref, () => ({
+ getValue: () => ({ router_settings: routerSettingsMocks.editedValue ?? value?.router_settings ?? {} }),
+ }));
+ return <div data-testid="router-settings-accordion" />;
+ }),
+ };
+});
+
vi.mock("@/app/(dashboard)/hooks/organizations/useOrganizations", () => ({
useOrganizations: vi.fn().mockReturnValue({
data: [
@@ -160,6 +178,83 @@ describe("KeyEditView", () => {
last_rotation_at: undefined,
key_rotation_at: undefined,
};
+ describe("router settings", () => {
+ const UNSUPPORTED_STORED_FIELD = { tag_routing_prefix: "team-" };
+ const STORED_ROUTER_SETTINGS = {
+ num_retries: 2,
+ fallbacks: [{ "gpt-4": ["gpt-4o"] }],
+ ...UNSUPPORTED_STORED_FIELD,
+ };
+
+ const renderWithRouterSettings = (onSubmit: (values: Record<string, unknown>) => Promise<void>) =>
+ renderWithProviders(
+ <KeyEditView
+ keyData={{ ...MOCK_KEY_DATA, router_settings: STORED_ROUTER_SETTINGS }}
+ onCancel={() => {}}
+ onSubmit={onSubmit}
+ accessToken="test-token"
+ userID="test-user"
+ userRole="proxy_admin"
+ premiumUser={true}
+ />,
+ );
+
+ beforeEach(() => {
+ routerSettingsMocks.receivedValue = undefined;
+ routerSettingsMocks.editedValue = null;
+ });
+
+ it("should load the fields it renders into the editor and withhold the ones it does not", async () => {
+ renderWithRouterSettings(async () => {});
+
+ await waitFor(() => {
+ expect(routerSettingsMocks.receivedValue).toStrictEqual({
+ router_settings: { num_retries: 2, fallbacks: [{ "gpt-4": ["gpt-4o"] }] },
+ });
+ });
+ });
+
+ it("should submit edited fallbacks alongside routing fields the editor cannot show", async () => {
+ const onSubmit = vi.fn().mockResolvedValue(undefined);
+ renderWithRouterSettings(onSubmit);
+ routerSettingsMocks.editedValue = { num_retries: 2, fallbacks: [{ "gpt-4": ["gpt-4o", "gpt-4o-mini"] }] };
+
+ fireEvent.click(screen.getByText("Save Changes"));
+
+ await waitFor(() => {
+ expect(onSubmit).toHaveBeenCalledWith(
+ expect.objectContaining({
+ router_settings: expect.objectContaining({
+ ...UNSUPPORTED_STORED_FIELD,
+ num_retries: 2,
+ fallbacks: [{ "gpt-4": ["gpt-4o", "gpt-4o-mini"] }],
+ }),
+ }),
+ );
+ });
+ });
+
+ it("should submit cleared router settings so removing every fallback is persisted", async () => {
+ const onSubmit = vi.fn().mockResolvedValue(undefined);
+ renderWithRouterSettings(onSubmit);
+ routerSettingsMocks.editedValue = { num_retries: null, fallbacks: null };
+
+ fireEvent.click(screen.getByText("Save Changes"));
+
+ await waitFor(() => {
+ expect(onSubmit).toHaveBeenCalledWith(
+ expect.objectContaining({
+ router_settings: expect.objectContaining({
+ ...UNSUPPORTED_STORED_FIELD,
+ num_retries: null,
+ fallbacks: null,
+ }),
+ }),
+ );
+ });
+ });
+ });
+
it("should render", async () => {
const { getByText } = renderWithProviders(
<KeyEditView
diff --git a/ui/litellm-dashboard/src/components/templates/key_edit_view.tsx b/ui/litellm-dashboard/src/components/templates/key_edit_view.tsx
index 36dc02f7bd0..87a6d68ebc4 100644
--- a/ui/litellm-dashboard/src/components/templates/key_edit_view.tsx
+++ b/ui/litellm-dashboard/src/components/templates/key_edit_view.tsx
@@ -6,7 +6,7 @@ import PolicySelector from "@/components/policies/PolicySelector";
import { InfoCircleOutlined } from "@ant-design/icons";
import { TextInput, Button as TremorButton } from "@tremor/react";
import { Form, Input, Select, Switch, Tooltip } from "antd";
-import { useEffect, useState } from "react";
+import { useEffect, useRef, useState } from "react";
import { hasCapability } from "../../utils/capabilities";
import { isProxyAdminRole, rolesWithWriteAccess } from "../../utils/roles";
import AgentSelector from "../agent_management/AgentSelector";
@@ -17,6 +17,8 @@ import KeyLifecycleSettings from "../common_components/KeyLifecycleSettings";
import PassThroughRoutesSelector from "../common_components/PassThroughRoutesSelector";
import RateLimitTypeFormItem from "../common_components/RateLimitTypeFormItem";
import OrganizationDropdown from "../common_components/OrganizationDropdown";
+import RouterSettingsAccordion, { RouterSettingsAccordionRef } from "../common_components/RouterSettingsAccordion";
+import { routerSettingsEditorValue, routerSettingsUpdate } from "../common_components/routerSettingsPayload";
import { extractLoggingSettings, formatMetadataForDisplay, stripTagsFromMetadata } from "../key_info_utils";
import { estimateFields, estimateRules, estimateTooltips, withNormalizedEstimates } from "./estimatedOutputTokens";
import { canonicalBudgetDuration, keyTypeFromRoutes } from "./keyEditFieldNormalizers";
@@ -91,6 +93,7 @@ export function KeyEditView({
const [budgetFallbacks, setBudgetFallbacks] = useState<Record<string, string[]>>(
keyData.budget_fallbacks && typeof keyData.budget_fallbacks === "object" ? keyData.budget_fallbacks : {},
);
+ const routerSettingsRef = useRef<RouterSettingsAccordionRef>(null);
const { data: organizations, isLoading: isOrganizationsLoading } = useOrganizations();
const { data: projects } = useProjects();
const { data: uiSettingsData } = useUISettings();
@@ -286,6 +289,14 @@ export function KeyEditView({
values.budget_fallbacks = {};
}
+ const routerSettings = routerSettingsUpdate(
+ routerSettingsRef.current?.getValue()?.router_settings,
+ keyData.router_settings,
+ );
+ if (routerSettings) {
+ values.router_settings = routerSettings;
+ }
+
await onSubmit(withNormalizedEstimates(values));
} finally {
setIsKeySaving(false);
@@ -799,6 +810,15 @@ export function KeyEditView({
<Input value={projectDisplay ?? ""} disabled />
</Form.Item>
)}
+ <Form.Item label="Router Settings">
+ <RouterSettingsAccordion
+ ref={routerSettingsRef}
+ accessToken={accessToken || ""}
+ teamId={keyData.team_id}
+ value={routerSettingsEditorValue(keyData.router_settings)}
+ />
+ </Form.Item>
+
<Form.Item label="Logging Settings" name="logging_settings">
<EditLoggingSettings
value={form.getFieldValue("logging_settings")}
diff --git a/ui/litellm-dashboard/src/components/templates/key_info_view.test.tsx b/ui/litellm-dashboard/src/components/templates/key_info_view.test.tsx
index 680fbe9ff1e..d2390a633d5 100644
--- a/ui/litellm-dashboard/src/components/templates/key_info_view.test.tsx
+++ b/ui/litellm-dashboard/src/components/templates/key_info_view.test.tsx
@@ -189,6 +189,25 @@ describe("KeyInfoView", () => {
});
});
+ it("should render the key's saved router fallbacks", async () => {
+ vi.mocked(useAuthorized).mockReturnValue(baseUseAuthorizedMock);
+
+ renderWithProviders(
+ <KeyInfoView
+ keyData={{ ...MOCK_KEY_DATA, router_settings: { num_retries: 2, fallbacks: [{ "gpt-4": ["gpt-4o"] }] } }}
+ onClose={() => {}}
+ keyId={"test-key-id"}
+ onKeyDataUpdate={() => {}}
+ teams={[]}
+ />,
+ );
+
+ expect(await screen.findByText("Router Settings")).toBeInTheDocument();
+ expect(screen.getByText("gpt-4")).toBeInTheDocument();
+ expect(screen.getByText("gpt-4o")).toBeInTheDocument();
+ expect(screen.getByText("Number of Retries: 2")).toBeInTheDocument();
+ });
+
it("should render tags", async () => {
vi.mocked(useAuthorized).mockReturnValue(baseUseAuthorizedMock);
diff --git a/ui/litellm-dashboard/src/components/templates/key_info_view.tsx b/ui/litellm-dashboard/src/components/templates/key_info_view.tsx
index 6fd6547a995..f7720874968 100644
--- a/ui/litellm-dashboard/src/components/templates/key_info_view.tsx
+++ b/ui/litellm-dashboard/src/components/templates/key_info_view.tsx
@@ -13,6 +13,8 @@ import { isProxyAdminRole, isUserTeamAdminForSingleTeam, rolesWithWriteAccess }
import { mapDisplayToInternalNames, mapInternalToDisplayNames } from "../callback_info_helpers";
import AutoRotationView from "../common_components/AutoRotationView";
import DeleteResourceModal from "../common_components/DeleteResourceModal";
+import RouterSettingsSummary from "../common_components/RouterSettingsSummary";
+import { hasRouterSettings } from "../common_components/routerSettingsPayload";
import { extractLoggingSettings, formatMetadataForDisplay, stripTagsFromMetadata } from "../key_info_utils";
import { KeyResponse } from "../key_team_helpers/key_list";
import LoggingSettingsView from "../logging_settings_view";
@@ -837,6 +839,15 @@ export default function KeyInfoView({
</div>
)}
+ {hasRouterSettings(currentKeyData.router_settings) && (
+ <div>
+ <Text className="font-medium">Router Settings</Text>
+ <div className="mt-1">
+ <RouterSettingsSummary routerSettings={currentKeyData.router_settings} />
+ </div>
+ </div>
+ )}
+
<div>
<Text className="font-medium">Tags</Text>
<div className="flex flex-wrap gap-2 mt-1">