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
Merge remote-tracking branch 'origin' into feature/vkey-modal-squashed
yuneng-jiang34769fdbf451
diff --cc ui/litellm-dashboard/src/app/login/LoginPage.tsxindex 80372fcddca,2a2915ea350..d54140c5a29--- a/ui/litellm-dashboard/src/app/login/LoginPage.tsx+++ b/ui/litellm-dashboard/src/app/login/LoginPage.tsx@@@ -6,9 -6,7 +6,8 @@@ import LoadingScreen from "@/componentsimport { getProxyBaseUrl } from "@/components/networking";import { getCookie } from "@/utils/cookieUtils";import { isJwtExpired } from "@/utils/jwtUtils";+import { consumeReturnUrl, getReturnUrl, isValidReturnUrl } from "@/utils/returnUrlUtils";import { InfoCircleOutlined } from "@ant-design/icons";- import { QueryClient, QueryClientProvider } from "@tanstack/react-query";import { Alert, Button, Card, Form, Input, Popover, Space, Typography } from "antd";import { useRouter } from "next/navigation";import { useEffect, useState } from "react";diff --cc ui/litellm-dashboard/src/components/organisms/create_key_button.test.tsxindex e92437a3d7c,c72cb56ffa5..3ed4c80aea5--- a/ui/litellm-dashboard/src/components/organisms/create_key_button.test.tsx+++ b/ui/litellm-dashboard/src/components/organisms/create_key_button.test.tsx@@@ -204,25 -42,20 +204,39 @@@ vi.mock("../molecules/notifications_man},}));+vi.mock("../agent_management/AgentSelector", () => ({ default: () => null }));+vi.mock("../common_components/budget_duration_dropdown", () => ({ default: () => null }));+vi.mock("../common_components/check_openapi_schema", () => ({ default: () => null }));+vi.mock("../common_components/KeyLifecycleSettings", () => ({ default: () => null }));+vi.mock("../common_components/ModelAliasManager", () => ({ default: () => null }));+vi.mock("../common_components/PassThroughRoutesSelector", () => ({ default: () => null }));+vi.mock("../common_components/PremiumLoggingSettings", () => ({ default: () => null }));+vi.mock("../common_components/RateLimitTypeFormItem", () => ({ default: () => null }));+vi.mock("../common_components/RouterSettingsAccordion", () => ({ default: () => null }));+vi.mock("../common_components/team_dropdown", () => ({ default: () => null }));+vi.mock("../CreateUserButton", () => ({ CreateUserButton: () => null }));+vi.mock("../mcp_server_management/MCPServerSelector", () => ({ default: () => null }));+vi.mock("../mcp_server_management/MCPToolPermissions", () => ({ default: () => null }));+vi.mock("../shared/numerical_input", () => ({ default: () => null }));+vi.mock("../vector_store_management/VectorStoreSelector", () => ({ default: () => null }));+vi.mock("../key_team_helpers/fetch_available_models_team_key", () => ({+ getModelDisplayName: (model: string) => model,+}));++ vi.mock("@/app/(dashboard)/hooks/projects/useProjects", () => ({+ useProjects: vi.fn().mockReturnValue({ data: [], isLoading: false }),+ }));++ vi.mock("../common_components/ProjectDropdown", () => ({+ default: ({ value, onChange }: { value?: string; onChange?: (v: string) => void }) => (+ <input+ data-testid="project-dropdown"+ value={value || ""}+ onChange={(e) => onChange?.(e.target.value)}+ />+ ),+ }));+vi.mock("../common_components/AccessGroupSelector", () => ({default: ({ value = [], onChange }: { value?: string[]; onChange?: (v: string[]) => void }) => (<inputdiff --cc ui/litellm-dashboard/src/components/organisms/create_key_button.tsxindex d071c4a4a3b,c54725bd5a5..78ff01d6419--- a/ui/litellm-dashboard/src/components/organisms/create_key_button.tsx+++ b/ui/litellm-dashboard/src/components/organisms/create_key_button.tsx@@@ -154,8 -144,12 +157,12 @@@ export const fetchUserModels = async* Please contribute to the new refactor.* ─────────────────────────────────────────────────────────────────────────*/-const CreateKey: React.FC<CreateKeyProps> = ({ team, teams, data, addKey }) => {+const CreateKey: React.FC<CreateKeyProps> = ({ team, teams, data, addKey, autoOpenCreate, prefillData }) => {const { accessToken, userId: userID, userRole, premiumUser } = useAuthorized();+ const canEditGuardrails = premiumUser || (userRole != null && rolesWithWriteAccess.includes(userRole));+ const { data: projects, isLoading: isProjectsLoading } = useProjects();+ const { data: uiSettingsData } = useUISettings();+ const enableProjectsUI = Boolean(uiSettingsData?.values?.enable_projects_ui);const queryClient = useQueryClient();const [form] = Form.useForm();const [isModalVisible, setIsModalVisible] = useState(false);@@@ -531,39 -477,39 +541,61 @@@NotificationsManager.success("Virtual Key copied to clipboard");};+ // Fetch available models when team or auth changes.+ // Note: Model prefill from URL params is handled by the useEffect below, which+ // watches for pendingPrefillModels + modelsToPick to both be populated.useEffect(() => {+ if (selectedProjectId) {+ // When a project is selected, use the project's models+ const project = projects?.find((p) => p.project_id === selectedProjectId);+ const projectModels = project?.models ?? [];+ setModelsToPick(projectModels);+ form.setFieldValue("models", []);+ return;+ }if (userID && userRole && accessToken) {fetchTeamModels(userID, userRole, accessToken, selectedCreateKeyTeam?.team_id ?? null).then((models) => {let allModels = Array.from(new Set([...(selectedCreateKeyTeam?.models ?? []), ...models]));setModelsToPick(allModels);});}- form.setFieldValue("models", []);- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [selectedCreateKeyTeam, selectedProjectId, accessToken, userID, userRole]);+ // Only clear models if we don't have pending prefill models+ if (!pendingPrefillModels) {+ form.setFieldValue("models", []);+ }- }, [selectedCreateKeyTeam, accessToken, userID, userRole, form]);++ }, [selectedCreateKeyTeam, selectedProjectId, accessToken, userID, userRole, form]);++ // Apply deferred model prefill once the available model list arrives.+ // This handles timing where prefill data arrives before or after models are fetched.+ useEffect(() => {+ if (!pendingPrefillModels || pendingPrefillModels.length === 0) {+ return;+ }+ if (!modelsToPick || modelsToPick.length === 0) {+ return;+ }++ const validModels = pendingPrefillModels.filter((model) => modelsToPick.includes(model));+ if (validModels.length > 0) {+ form.setFieldsValue({ models: validModels });+ }+ setPendingPrefillModels(null);+ }, [pendingPrefillModels, modelsToPick, form]);+ // Sync team when project is selected but teams loaded later (race condition)+ useEffect(() => {+ if (!selectedProjectId || !teams) return;+ const project = projects?.find((p) => p.project_id === selectedProjectId);+ if (!project?.team_id) return;+ // If team is already set correctly, skip+ if (selectedCreateKeyTeam?.team_id === project.team_id) return;+ const projectTeam = teams.find((t) => t.team_id === project.team_id) || null;+ if (projectTeam) {+ setSelectedCreateKeyTeam(projectTeam);+ form.setFieldValue("team_id", projectTeam.team_id);+ }+ }, [teams, selectedProjectId, projects]);+// Add a callback function to handle user creationconst handleUserCreated = (userId: string) => {setNewlyCreatedUserId(userId);