From 549fc650c312b52960311dea1dd85f84ae06584e Mon Sep 17 00:00:00 2001 From: moppywhip <48742547+moppywhip@users.noreply.github.com> Date: Tue, 22 Apr 2025 13:59:31 -0400 Subject: [PATCH] fix: remove requirement for api key for ollama (#546) Fixes #540 # Skip API key validation for Ollama provider ## Description This PR modifies the CLI to not require an API key when using Ollama as the provider ## Changes - Modified the validation logic to skip API key checks for these providers - Updated the README to clarify that Ollama doesn't require an API key --- codex-cli/src/cli.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/codex-cli/src/cli.tsx b/codex-cli/src/cli.tsx index 2872cf0c..d4982fb1 100644 --- a/codex-cli/src/cli.tsx +++ b/codex-cli/src/cli.tsx @@ -254,7 +254,11 @@ const imagePaths = cli.flags.image; const provider = cli.flags.provider ?? config.provider ?? "openai"; const apiKey = getApiKey(provider); -if (!apiKey) { +// Set of providers that don't require API keys +const NO_API_KEY_REQUIRED = new Set(["ollama"]); + +// Skip API key validation for providers that don't require an API key +if (!apiKey && !NO_API_KEY_REQUIRED.has(provider.toLowerCase())) { // eslint-disable-next-line no-console console.error( `\n${chalk.red(`Missing ${provider} API key.`)}\n\n` +