{"record":{"id":"fd3659670ba4ced1","repo":"Hmbown/CodeWhale","slug":"ollama-cloud-api-key-not-found-get-a-key-run","errorCode":null,"errorMessage":"Ollama Cloud API key not found. Get a key: {}. Run 'codewhale auth set --provider ollama', set OLLAMA_API_KEY, or add [providers.ollama] api_key in ~/.codewhale/config.toml.","messagePattern":"Ollama Cloud API key not found\\. Get a key: (.+?)\\. Run 'codewhale auth set --provider ollama', set OLLAMA_API_KEY, or add \\[providers\\.ollama\\] api_key in ~/\\.codewhale/config\\.toml\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/config.rs","lineNumber":7410,"sourceCode":"            }\n            ApiProvider::OpenaiCodex => anyhow::bail!(\n                \"{}\",\n                crate::oauth::missing_auth_message(crate::oauth::OAuthProvider::Chatgpt)\n            ),\n            ApiProvider::Xai => {\n                // Prefer OAuth guidance when auth_mode requests it or Grok CLI\n                // tokens already exist; otherwise show both API-key and OAuth.\n                if self\n                    .provider_config_for(provider)\n                    .is_some_and(provider_config_uses_xai_oauth)\n                    || crate::oauth::credentials_present(crate::oauth::OAuthProvider::Xai, self)\n                {\n                    anyhow::bail!(\n                        \"{}\",\n                        crate::oauth::missing_auth_message(crate::oauth::OAuthProvider::Xai)\n                    );\n                }\n                anyhow::bail!(\n                    \"xAI API key not found. Get a key: https://console.x.ai/\\n\\\n                     Run 'codewhale auth set --provider xai', set XAI_API_KEY, or add \\\n                     [providers.xai] api_key.\\n\\\n                     OAuth alternative: run `codewhale auth xai-device` for \\\n                     Codewhale-owned storage and set [providers.xai] auth_mode = \\\"oauth\\\".\"\n                );\n            }\n            // Self-hosted deployments commonly run without auth on localhost.\n            // Return an empty key and let the client omit the Authorization header.\n            ApiProvider::Sglang | ApiProvider::Vllm => Ok(String::new()),\n            ApiProvider::Ollama\n                if provider_route_is_keyless_self_hosted(\n                    provider,\n                    &self.active_route_base_url(),\n                ) =>\n            {\n                Ok(String::new())\n            }","sourceCodeStart":7392,"sourceCodeEnd":7428,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/config.rs#L7392-L7428","documentation":"Thrown when the Ollama provider is selected but no Ollama Cloud API key is configured. The config layer builds the error using credential_help_for_provider_route so the displayed key URL matches the active route's base URL, defaulting to OLLAMA_CLOUD_API_KEY_URL. It fails loud because an Ollama Cloud request without a key would be rejected upstream.","triggerScenarios":"Using provider `ollama` (Ollama Cloud route) when OLLAMA_API_KEY is unset and [providers.ollama] has no api_key in ~/.codewhale/config.toml.","commonSituations":"Local Ollama users pointing at Ollama Cloud models without realizing the cloud route needs a key; CI environments lacking the env var; typos in the env var name in config.","solutions":["Set the OLLAMA_API_KEY environment variable","Run `codewhale auth set --provider ollama`","Add `api_key = \"...\"` under [providers.ollama] in ~/.codewhale/config.toml","Get a key from the URL shown in the error (OLLAMA_CLOUD_API_KEY_URL or route-specific)"],"exampleFix":"// before\n[providers.ollama]\n// after\n[providers.ollama]\napi_key = \"your-ollama-cloud-key\"","handlingStrategy":"validation","validationCode":"let ok = std::env::var(\"OLLAMA_API_KEY\").map(|v| !v.trim().is_empty()).unwrap_or(false);\nif !ok { eprintln!(\"Ollama Cloud key missing: set OLLAMA_API_KEY or [providers.ollama] api_key\"); }\nelse { /* proceed */ }","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"Ollama Cloud API key not found\") => configure_ollama_key_and_retry(),\n    other => other?,\n}","preventionTips":["Remember Ollama Cloud routes require a key even if local Ollama does not","Set OLLAMA_API_KEY in your environment before launching sessions","Check the route-specific key URL shown in the error"],"tags":["authentication","api-key","ollama","config"],"backgroundTag":"missing-api-key","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}