Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

feat: show actionable errors when api keys are missing (#523)

Naveen Kumar Battulafcd1d4bdf9b7
diff --git a/codex-cli/src/cli.tsx b/codex-cli/src/cli.tsx
index 6220128f8d..2872cf0cf9 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);
}