gitbutlerapp/gitbutler · error

No Anthropic own key configured. Add this through the…

Error message

No Anthropic own key configured. Add this through the GitButler settings

What it means

anthropic_own_key_creds retrieves the user's personal Anthropic API key from the secret store (handle AI_ANTHROPIC_SECRET_HANDLE, global namespace). When none is stored, it throws "No Anthropic own key configured. Add this through the GitButler settings". Using your own Anthropic key requires saving it in GitButler settings first.

Solutions

  1. Open GitButler settings and add your Anthropic API key
  2. Verify the key was persisted in the OS keychain after saving
  3. Unlock the OS keychain if secret retrieval fails silently
  4. Or switch the provider to the GitButler-proxied one after logging in
Defensive patterns

Strategy: fallback

Validate before calling

let has_key = secret::retrieve(AI_ANTHROPIC_SECRET_HANDLE, secret::Namespace::Global)
    .map(|k| k.is_some()).unwrap_or(false);
if !has_key { eprintln!("add an Anthropic key in GitButler settings or use the proxied provider"); }

Try / catch

// fall back to the GitButler-proxied provider when no own key exists
match anthropic_own_key_creds() {
    Err(e) if e.to_string().contains("No Anthropic own key configured") => gitbutler_proxied_creds(),
    other => other,
}

Prevention

When it happens

Trigger: Selecting the OwnAnthropicKey credentials kind while secret::retrieve returns None because the key was never saved via GitButler settings or was deleted from the keyring.

Common situations: User switched provider to 'own key' without entering a key in settings, keyring cleared on reinstall/OS upgrade, or settings sync failed to persist the secret.

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.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/fcb5fbe89aba7985. Report an issue: GitHub.

Appendix: source

Thrown at crates/but-llm/src/anthropic.rs:146

        let credentials = &self.credentials.1;
        let kind = self.credentials.0.clone();
        AnthropicClient::new(kind, credentials)
    }

    pub fn credentials_kind(&self) -> CredentialsKind {
        self.credentials.0.clone()
    }
    fn gitbutler_proxied_creds() -> Result<(CredentialsKind, Sensitive<String>)> {
        let creds = secret::retrieve(GITBUTLER_ACCESS_TOKEN_HANDLE, secret::Namespace::BuildKind)?
            .ok_or(anyhow::anyhow!(
                "No GitButler token available. Log-in to use the GitButler Anthropic provider"
            ))?;
        Ok((CredentialsKind::GitButlerProxied, creds))
    }

    fn anthropic_own_key_creds() -> Result<(CredentialsKind, Sensitive<String>)> {
        let creds = secret::retrieve(AI_ANTHROPIC_SECRET_HANDLE, secret::Namespace::Global)?
            .ok_or(anyhow::anyhow!(
                "No Anthropic own key configured. Add this through the GitButler settings"
            ))?;
        Ok((CredentialsKind::OwnAnthropicKey, creds))
    }

    fn anthropic_env_var_creds() -> Result<(CredentialsKind, Sensitive<String>)> {
        let creds = Sensitive(
            std::env::var_os("ANTHROPIC_API_KEY")
                .ok_or(anyhow::anyhow!(
                    "Environment variable ANTHROPIC_API_KEY is not set"
                ))?
                .into_string()
                .map_err(|_| anyhow::anyhow!("Invalid UTF-8 in ANTHROPIC_API_KEY"))?,
        );
        Ok((CredentialsKind::EnvVarAnthropicKey, creds))
    }
}

View on GitHub (pinned to 58e5313667)