From aa0d7563ffd6076540aaafd0ed797ff079e1dd1b Mon Sep 17 00:00:00 2001 From: Charles-Henri ROBICHE Date: Thu, 29 Jan 2026 10:32:10 +0100 Subject: [PATCH] fix(litellm): ensure API key retry prompts for new key - Clear CLI-provided API key and token options when retrying - Forces fresh prompt instead of reusing old credentials - Consistent behavior with base URL retry Co-Authored-By: Claude --- src/commands/auth-choice.apply.api-providers.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/commands/auth-choice.apply.api-providers.ts b/src/commands/auth-choice.apply.api-providers.ts index ef3965915..cfdaa6475 100644 --- a/src/commands/auth-choice.apply.api-providers.ts +++ b/src/commands/auth-choice.apply.api-providers.ts @@ -804,11 +804,18 @@ export async function applyAuthChoiceApiProviders( } if (action === "retry-apikey") { - // Re-prompt for API key and retry - apiKey = await promptForApiKey(); - await setLitellmApiKey(apiKey, params.agentDir); - // Retry fetch by recursively calling this function - return await applyAuthChoiceApiProviders({ ...params, authChoice: "litellm-api-key" }); + // Re-prompt for API key and retry the entire flow + // Clear the CLI-provided options to force prompting + const newParams = { + ...params, + authChoice: "litellm-api-key" as const, + opts: { + ...params.opts, + litellmApiKey: undefined, // Clear the CLI-provided API key so we can prompt + token: undefined, // Also clear token if it was used + }, + }; + return await applyAuthChoiceApiProviders(newParams); } if (action === "retry-baseurl") {