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
fix(ui): keep litellm_credential_name from LiteLLM Params JSON when no credential is selected (#39005)
devin-ai-integration[bot]33cc9c1c48d7
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/panels/AddModelPanel.integration.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/panels/AddModelPanel.integration.test.tsxindex 19e1e3aa8bd..efba26734ff 100644--- a/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/panels/AddModelPanel.integration.test.tsx+++ b/ui/litellm-dashboard/src/app/(dashboard)/models-and-endpoints/panels/AddModelPanel.integration.test.tsx@@ -87,7 +87,6 @@ const alwaysMounted = {api_key: undefined,api_base: undefined,custom_llm_provider: "openai",- litellm_credential_name: null,model: "gpt-4o",};diff --git a/ui/litellm-dashboard/src/components/add_model/handle_add_model_submit.test.tsx b/ui/litellm-dashboard/src/components/add_model/handle_add_model_submit.test.tsxindex 7ef09d34924..2aa8f93b72b 100644--- a/ui/litellm-dashboard/src/components/add_model/handle_add_model_submit.test.tsx+++ b/ui/litellm-dashboard/src/components/add_model/handle_add_model_submit.test.tsx@@ -73,4 +73,28 @@ describe("prepareModelAddRequest", () => {expect(deployment.litellmParamsObj.litellm_credential_name).toBe("selected-credential");expect(deployment.litellmParamsObj.timeout).toBe(5);});++ it("keeps litellm_credential_name from LiteLLM Params JSON when no credential is selected", async () => {+ const formValues = {+ model_mappings: [+ {+ public_name: "Public Model",+ litellm_model: "litellm/public",+ },+ ],+ model_name: "custom-model-name",+ litellm_extra_params: JSON.stringify({+ litellm_credential_name: "from-json",+ timeout: 5,+ }),+ litellm_credential_name: null,+ };++ const deployments = await prepareModelAddRequest({ ...formValues }, "token", null);++ expect(deployments).toHaveLength(1);+ const [deployment] = deployments!;+ expect(deployment.litellmParamsObj.litellm_credential_name).toBe("from-json");+ expect(deployment.litellmParamsObj.timeout).toBe(5);+ });});diff --git a/ui/litellm-dashboard/src/components/add_model/handle_add_model_submit.tsx b/ui/litellm-dashboard/src/components/add_model/handle_add_model_submit.tsxindex bb2f78fa84e..b4ae51d5423 100644--- a/ui/litellm-dashboard/src/components/add_model/handle_add_model_submit.tsx+++ b/ui/litellm-dashboard/src/components/add_model/handle_add_model_submit.tsx@@ -91,6 +91,9 @@ export const prepareModelAddRequest = async (formValues: Record<string, any>, acif (value === "") {continue;}+ if (key === "litellm_credential_name" && value == null) {+ continue;+ }// Skip the custom_pricing and pricing_model fields as they're only used for UI controlif (key === "custom_pricing" || key === "pricing_model" || key === "cache_control") {continue;@@ -124,7 +127,7 @@ export const prepareModelAddRequest = async (formValues: Record<string, any>, acif (value && value != undefined) {try {litellmExtraParams = JSON.parse(value);- if ("litellm_credential_name" in litellmExtraParams) {+ if ("litellm_credential_name" in litellmExtraParams && formValues.litellm_credential_name) {delete litellmExtraParams.litellm_credential_name;}} catch (error) {