{"record":{"id":"56a6680ace525c47","repo":"gitbutlerapp/gitbutler","slug":"no-gitbutler-token-available-log-in-to-use-the-gi-56a668","errorCode":null,"errorMessage":"No GitButler token available. Log-in to use the GitButler OpenAI provider","messagePattern":"No GitButler token available\\. Log-in to use the GitButler OpenAI provider","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-llm/src/openai.rs","lineNumber":84,"sourceCode":"        }\n    }\n\n    /// Configure a custom endpoint if set in the provider, if any.\n    fn configure_custom_endpoint(&self, config: OpenAIConfig) -> OpenAIConfig {\n        if let Some(custom_endpont) = &self.custom_endpoint {\n            config.with_api_base(custom_endpont)\n        } else {\n            config\n        }\n    }\n\n    pub fn credentials_kind(&self) -> CredentialsKind {\n        self.credentials.0.clone()\n    }\n\n    fn gitbutler_proxied_creds() -> Result<(CredentialsKind, Sensitive<String>)> {\n        let creds = secret::retrieve(GITBUTLER_ACCESS_TOKEN_HANDLE, secret::Namespace::BuildKind)?\n            .ok_or(anyhow::anyhow!(\n                \"No GitButler token available. Log-in to use the GitButler OpenAI provider\"\n            ))?;\n        Ok((CredentialsKind::GitButlerProxied, creds))\n    }\n\n    fn openai_own_key_creds() -> Result<(CredentialsKind, Sensitive<String>)> {\n        let creds = secret::retrieve(AI_OPENAI_SECRET_HANDLE, secret::Namespace::Global)?.ok_or(\n            anyhow::anyhow!(\n                \"No OpenAI own key configured. Add this through the GitButler settings\"\n            ),\n        )?;\n        Ok((CredentialsKind::OwnOpenAiKey, creds))\n    }\n\n    fn openai_env_var_creds() -> Result<(CredentialsKind, Sensitive<String>)> {\n        let creds = Sensitive(\n            std::env::var_os(\"OPENAI_API_KEY\")\n                .ok_or(anyhow::anyhow!(","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-llm/src/openai.rs#L66-L102","documentation":"Thrown by `gitbutler_proxied_creds` in the OpenAI provider when the GitButler access token cannot be retrieved from the OS secret store (`secret::retrieve(GITBUTLER_ACCESS_TOKEN_HANDLE, ...)` returns Ok(None)). Without a logged-in GitButler account token, the proxied OpenAI endpoint cannot authenticate the user, so the provider raises this error before making any request.","triggerScenarios":"Selecting the GitButler-proxied OpenAI provider while the secret store has no entry for the GitButler access token handle — i.e. the user never logged in, logged out, or the token was deleted from the keychain.","commonSituations":"Fresh install with no GitButler login; using the CLI without `but login`; logging out or clearing keychain entries; secret-store access denied causing a None-style result after migration to a new machine.","solutions":["Log in to GitButler (via the app or `but login`) so the access token is stored in the OS secret store","If already logged in on another machine, sign in on this one to provision the local token","Fall back to a different credential kind: set OPENAI_API_KEY or configure an own OpenAI key in settings","Verify the OS keychain is accessible/unlocked (e.g. after headless/SSH sessions)"],"exampleFix":"// before\n$ but ai ...\nError: No GitButler token available. Log-in to use the GitButler OpenAI provider\n\n// after\n$ but login\n$ but ai ...","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match provider_result {\n    Err(e) if e.to_string().contains(\"No GitButler token\") => {\n        prompt_login(); // run `but login` or open the app's sign-in\n    }\n    other => other?,\n}","preventionTips":["Log in once per machine after installing GitButler","After OS migration or keychain reset, re-authenticate","On headless hosts, ensure the keyring service is available or fall back to API keys","Check login state (whoami/account command) before invoking AI features"],"tags":["authentication","credentials","llm","openai"],"backgroundTag":"authentication-required","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}