gitbutlerapp/gitbutler · warning · anyhow::Error
Could not determine OpenAI credential source
Error message
Could not determine OpenAI credential source
What it means
After choosing OpenAI as AI provider, the CLI asks for a credential source ('Use GitButler API' vs 'Bring your own key') via prompt_select; this error fires when that picker is cancelled and returns None. It guards the next step (model/endpoint/secret prompts) from running without a credential decision.
Source
Thrown at crates/but/src/command/config.rs:1593
("Ollama", LLMProviderKind::Ollama),
("LM Studio", LLMProviderKind::LMStudio),
("OpenRouter", LLMProviderKind::OpenRouter)
];
let provider = inout
.prompt_select("Select an AI provider", &providers)?
.cloned()
.ok_or_else(|| anyhow::anyhow!("Could not determine selected AI provider"))?;
match provider {
LLMProviderKind::OpenAi => {
let key_options = nonempty::nonempty![
("Use GitButler API", AiKeyOption::ButlerApi),
("Bring your own key", AiKeyOption::BringYourOwn)
];
let key_option = inout
.prompt_select("Select OpenAI credential source", &key_options)?
.copied()
.ok_or_else(|| anyhow::anyhow!("Could not determine OpenAI credential source"))?;
let model = inout.prompt("Preferred OpenAI model (leave empty for default):")?;
let endpoint = inout.prompt("Custom endpoint URL (optional):")?;
let secret = if matches!(key_option, AiKeyOption::BringYourOwn) {
Some(
inout
.prompt_secret("Enter OpenAI API key:")?
.context("No API key provided. Aborting configuration.")?,
)
} else {
None
};
apply_openai_config(repo, scope, key_option, model, endpoint, secret)?;
}
LLMProviderKind::Anthropic => {
let key_options = nonempty::nonempty![View on GitHub (pinned to caf1f223d3)
Solutions
- Pick 'Use GitButler API' if you authenticate through GitButler — no key entry needed.
- Pick 'Bring your own key' after creating the key at platform.openai.com; the following prompt asks for it.
- Re-run the config command to restart the flow.
Defensive patterns
Strategy: try-catch
Try / catch
match configure_ai(out).await {
Err(e) if e.to_string().contains("OpenAI credential source") => { Ok(()) }
other => other,
} Prevention
- Decide GitButler API vs own key before the prompt.
- Create the OpenAI key first if bringing your own.
When it happens
Trigger: Selecting OpenAI in AI config, then pressing Esc at the 'Select OpenAI credential source' picker.
Common situations: User undecided between the proxied GitButler key and a personal key; aborting to go create an OpenAI key first.
Related errors
- Could not determine Anthropic credential source
- 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
- Could not determine which forge provider to authenticate wit
AI-assisted analysis of gitbutlerapp/gitbutler@caf1f223d3 (2026-08-20).
Data as JSON: /api/errors/e75498b0f1f0f582.
Report an issue: GitHub.