Hmbown/CodeWhale · error
Codewhale API key not found, so no request was sent. The…
Error message
Codewhale API key not found, so no request was sent.
The Codewhale API authenticates every model with one account API key carrying the `models:infer` scope.
1. Create one and save it on this machine:
codewhale account api-keys create --name <name> --scope models:infer --use
2. Or export it for this shell:
export CODEWHALE_API_KEY=cwc_key_...
You can also create a key at {} and put it in [providers.codewhale] api_key (or api_key_env). What it means
The Codewhale provider requires one account-level API key with the models:infer scope to authenticate every model request. When no key can be found via override, env var, config, or the secret store, the library bails before sending anything, with instructions to create and register a key.
Solutions
- Run: codewhale account api-keys create --name <name> --scope models:infer --use
- Or export CODEWHALE_API_KEY=cwc_key_... for the current shell/CI job.
- Or create a key at the app.codewhale.net settings URL and put api_key (or api_key_env) under [providers.codewhale] in ~/.codewhale/config.toml.
Example fix
// before # no codewhale credentials configured // after export CODEWHALE_API_KEY=cwc_key_... # or in ~/.codewhale/config.toml: # [providers.codewhale] # api_key = "cwc_key_..."
Defensive patterns
Strategy: validation
Validate before calling
std::env::var("CODEWHALE_API_KEY")
.ok()
.filter(|k| k.starts_with("cwc_key_") && !k.trim().is_empty())
.ok_or_else(|| "CODEWHALE_API_KEY missing; run codewhale account api-keys create --scope models:infer --use".to_string())?; Type guard
fn codewhale_key_ready(env_val: Option<&str>) -> bool {
env_val.map(|k| k.starts_with("cwc_key_") && k.len() > 10).unwrap_or(false)
} Try / catch
match result {
Err(e) if e.to_string().contains("Codewhale API key not found") => {
eprintln!("run: codewhale account api-keys create --name ci --scope models:infer --use");
}
other => other?,
} Prevention
- Run the create --use command once during onboarding so a durable key exists.
- In CI, always export CODEWHALE_API_KEY as a secret before launching codewhale.
- Prefer ~/.zshenv (not ~/.zshrc) for exports so non-interactive shells see them.
When it happens
Trigger: Provider resolves to ApiProvider::Codewhale and CODEWHALE_API_KEY is unset, no [providers.codewhale] api_key/api_key_env exists, and no key is stored via 'codewhale account api-keys create --use' or 'codewhale auth set'.
Common situations: Fresh install without onboarding; a new shell/CI environment where CODEWHALE_API_KEY was never exported; switching machines without migrating the stored key.
Understand the failure class
Background: "API key is required" / "API key not found" / "No API key was set": the missing-api-key error family across 16 libraries — this error's family across 16 libraries.
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- DeepSeek API key not found. 1. Get a key: …
- empty API key provided
- No API key provided. Pass --api-key or pipe one via stdin.
- No API key provided via stdin.
- Antigravity cloud-code HTTP
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/b5de256563de85bd.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/config.rs:7320
&& (provider_route_is_keyless_self_hosted(provider, &self.active_route_base_url())
|| base_url_uses_local_host(&self.active_route_base_url()))
{
return Ok(String::new());
}
if custom_endpoint {
let route_name = self
.provider
.as_deref()
.unwrap_or_else(|| provider.as_str());
anyhow::bail!(
"Custom endpoint credentials for {route_name} must be bound explicitly. Ambient provider credentials are not sent to {}. Add api_key or api_key_env to this provider route, or pass --api-key with --base-url.",
self.active_route_base_url()
);
}
match provider {
ApiProvider::Codewhale => anyhow::bail!(
"Codewhale API key not found, so no request was sent.\n\
\n\
The Codewhale API authenticates every model with one account \
API key carrying the `models:infer` scope.\n\
\n\
1. Create one and save it on this machine:\n\
codewhale account api-keys create --name <name> --scope models:infer --use\n\
2. Or export it for this shell:\n\
export CODEWHALE_API_KEY=cwc_key_...\n\
\n\
You can also create a key at {} and put it in \
[providers.codewhale] api_key (or api_key_env).",
provider
.credential_url()
.unwrap_or("https://app.codewhale.net/settings?section=api")
),
ApiProvider::Deepseek | ApiProvider::DeepseekCN => anyhow::bail!(
"DeepSeek API key not found.\n\View on GitHub (pinned to 73e0f67d83)