gitbutlerapp/gitbutler · error · anyhow::Error
No AI credentials found. Configure in GitButler settings or
Error message
No AI credentials found. Configure in GitButler settings or set OPENAI_API_KEY environment variable.
What it means
generate_branch_summary builds an LLM prompt from a branch's commits; LLMProvider::from_git_config returns None when AI is unusable — per but-llm, that happens when the gitbutler.aiModelProvider setting is absent, the configured provider is unsupported, or provider init fails (e.g. bring-your-own-key chosen but no key resolvable, including the OPENAI_API_KEY env fallback). This anyhow error turns that Option into an explicit failure with setup guidance.
Source
Thrown at crates/but/src/command/legacy/branch/show.rs:420
author_email: String,
timestamp: i64,
files_changed: usize,
insertions: usize,
deletions: usize,
files: Vec<FileChange>,
}
#[instrument(skip(commits, git_config))]
fn generate_branch_summary(
branch_name: &str,
commits: &[CommitInfo],
git_config: &gix::config::File,
) -> anyhow::Result<String> {
use but_llm::LLMProvider;
// Get OpenAI provider (tries GitButler proxied, own key, then env var)
let llm = LLMProvider::from_git_config(git_config).ok_or_else(|| {
anyhow::anyhow!(
"No AI credentials found. Configure in GitButler settings or set OPENAI_API_KEY environment variable."
)
})?;
// Build the prompt with commit information
let mut prompt = format!(
"Please provide a concise summary (2-3 sentences) of what this branch '{branch_name}' accomplishes based on the following commits:\n\n"
);
for commit in commits {
prompt.push_str(&format!("- {}: {}\n", commit.short_sha, commit.message));
if !commit.files.is_empty() {
prompt.push_str(" Files changed:\n");
for file in &commit.files {
prompt.push_str(&format!(
" {} ({}, +{}, -{})\n",
file.path, file.status, file.insertions, file.deletions
));View on GitHub (pinned to caf1f223d3)
Solutions
- Run the AI configuration flow (`but config` → Select an AI provider) and provide credentials or pick GitButler API.
- Or export OPENAI_API_KEY (the documented env-var fallback named in the message) and retry.
- For local LLMs pick Ollama/LM Studio and ensure the server is reachable at its default port.
- If you don't want AI summaries, run the command without the summary flag instead of fixing credentials.
Example fix
# before $ but branch show feat --summary Error: No AI credentials found. Configure in GitButler settings or set OPENAI_API_KEY environment variable. # after $ export OPENAI_API_KEY=sk-... $ but branch show feat --summary
Defensive patterns
Strategy: validation
Validate before calling
// Check AI availability before requesting a summary
use but_llm::LLMProvider;
if LLMProvider::from_git_config(&git_config).is_none() {
// skip the --summary flag or guide the user to `but config` AI setup
return print_plain_summary(commits);
} Try / catch
match LLMProvider::from_git_config(git_config) {
Some(llm) => generate_summary(llm, commits).await,
None => print_plain_summary(commits), // degrade gracefully without AI
} Prevention
- Run `but config` AI setup once per machine (or export OPENAI_API_KEY).
- Make AI summaries optional in scripts so the command works without credentials.
When it happens
Trigger: Running `but branch show --summary` (summary generation) on a machine that never ran `but config` AI setup: no gitbutler.aiModelProvider in git config, no stored API key, and OPENAI_API_KEY unset. Also when the provider is set to a kind whose credentials expired/were removed.
Common situations: Fresh clone/CI machine expecting AI features without configuration; user configured Ollama but the local server isn't running so init fails; key removed from keychain/secret store after configuration.
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
- No GitButler token available. Log-in to use the GitButler Op
- No OpenAI own key configured. Add this through the GitButler
- Environment variable OPENAI_API_KEY is not set
- No GitButler token available. Log-in to use the GitButler An
- No Anthropic own key configured. Add this through the GitBut
AI-assisted analysis of gitbutlerapp/gitbutler@caf1f223d3 (2026-08-20).
Data as JSON: /api/errors/db09aca9f63d2a00.
Report an issue: GitHub.