From fcd1d4bdf9b793eda003aa3675ec64db4de8cd27 Mon Sep 17 00:00:00 2001 From: Naveen Kumar Battula Date: Tue, 22 Apr 2025 22:25:08 +0530 Subject: [PATCH] feat: show actionable errors when api keys are missing (#523) Change errors on missing api key of other providers from image (missing deepseek key but still throws error for openai) to image This should help new users figure out the issue easier and go to the right place to get api keys OpenAI key missing would popup with the right link image --- codex-cli/src/cli.tsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/codex-cli/src/cli.tsx b/codex-cli/src/cli.tsx index 6220128f..2872cf0c 100644 --- a/codex-cli/src/cli.tsx +++ b/codex-cli/src/cli.tsx @@ -258,11 +258,19 @@ if (!apiKey) { // eslint-disable-next-line no-console console.error( `\n${chalk.red(`Missing ${provider} API key.`)}\n\n` + - `Set the environment variable ${chalk.bold("OPENAI_API_KEY")} ` + + `Set the environment variable ${chalk.bold( + `${provider.toUpperCase()}_API_KEY`, + )} ` + `and re-run this command.\n` + - `You can create a key here: ${chalk.bold( - chalk.underline("https://platform.openai.com/account/api-keys"), - )}\n`, + `${ + provider.toLowerCase() === "openai" + ? `You can create a key here: ${chalk.bold( + chalk.underline("https://platform.openai.com/account/api-keys"), + )}\n` + : `You can create a ${chalk.bold( + `${provider.toUpperCase()}_API_KEY`, + )} ` + `in the ${chalk.bold(`${provider}`)} dashboard.\n` + }`, ); process.exit(1); }