diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/CurlPreview.tsx b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/CurlPreview.tsx index 4ceaa26652d..2e01ebb0ea8 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/CurlPreview.tsx +++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/CurlPreview.tsx @@ -1,15 +1,28 @@ import CopyButton from "@/components/shared/CopyButton"; import { buildCurlCommand, type CurlCommandInput } from "./lib/curlCommand"; -export default function CurlPreview(input: CurlCommandInput) { +interface CurlPreviewProps extends CurlCommandInput { + errorCount?: number; +} + +export default function CurlPreview({ errorCount = 0, ...input }: CurlPreviewProps) { const command = buildCurlCommand(input); + const invalid = errorCount > 0; return (
cURL request
- Replace $LITELLM_API_KEY with a virtual key - + {invalid ? ( + + Fix {errorCount} {errorCount === 1 ? "issue" : "issues"} on the Form tab before copying + + ) : ( + <> + Replace $LITELLM_API_KEY with a virtual key + + + )}
 issue.severity === "error").length}
               />
             
           
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/lib/curlCommand.ts b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/lib/curlCommand.ts
index 27d44bb0b04..22ede5ab6f3 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/lib/curlCommand.ts
+++ b/ui/litellm-dashboard/src/app/(dashboard)/playground/components/systemOneUI/lib/curlCommand.ts
@@ -21,7 +21,7 @@ const prettyPayload = (payload: string): string => {
 
 export const buildCurlCommand = ({ baseUrl, endpoint, payload, authHeaderName }: CurlCommandInput): string =>
   [
-    `curl -X POST ${shellSingleQuote(`${baseUrl.replace(/\/+$/, "")}${endpoint}`)}`,
+    `curl -X POST ${shellSingleQuote(`${baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl}${endpoint}`)}`,
     `  -H "${shellDoubleQuoteLiteral(authHeaderName)}: Bearer ${CURL_KEY_PLACEHOLDER}"`,
     `  -H "Content-Type: application/json"`,
     `  -d ${shellSingleQuote(prettyPayload(payload))}`,