gitbutlerapp/gitbutler · error
Please provide a valid API key for your selected AI service
Error message
Please provide a valid API key for your selected AI service
What it means
Validation branch of the AI credential test: configuration is invalid for an OpenAI/Anthropic model kind and the app is not using the hosted GitButler API (or the user is already signed in), i.e. a bring-your-own-key setup. It fires when the stored API key for the selected provider is missing, malformed, or rejected, pointing the user to the API key setting rather than to sign-in.
Solutions
- Enter a valid OpenAI or Anthropic API key in AI settings and rerun the check
- Verify the key is active and has remaining quota/credit on the provider's dashboard
- Switch to GitButler's hosted AI API (requires signing in) if you do not have your own key
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at apps/desktop/src/components/settings/AiCredentialCheck.svelte:79 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/bf79dd3fb6ff7724.
Report an issue: GitHub.
Appendix: source
Thrown at apps/desktop/src/components/settings/AiCredentialCheck.svelte:79
try {
// Get current model kind
modelKind = await aiService.getModelKind();
debugInfo = `Model kind: ${modelKind}`;
// Check if using GitButler API
isUsingButlerAPI = await aiService.usingGitButlerAPI();
debugInfo += `, Using GB API: ${isUsingButlerAPI}`;
// Check if configuration is valid
const isConfigValid = await aiService.validateConfiguration();
debugInfo += `, Config valid: ${isConfigValid}`;
if (!isConfigValid) {
if (modelKind === ModelKind.OpenAI || modelKind === ModelKind.Anthropic) {
if (isUsingButlerAPI && !userService.user) {
throw new Error("Please sign in to use GitButler's AI API");
} else {
throw new Error("Please provide a valid API key for your selected AI service");
}
} else if (modelKind === ModelKind.Ollama) {
// Get Ollama configuration for more detailed error
const endpoint = await aiService.getOllamaEndpoint();
const model = await aiService.getOllamaModelName();
throw new Error(
`Please check Ollama configuration: endpoint=${endpoint}, model=${model}`,
);
} else if (modelKind === ModelKind.LMStudio) {
// Get LM Studio configuration for more detailed error
const endpoint = await aiService.getLMStudioEndpoint();
throw new Error(`Please check LM Studio configuration: endpoint=${endpoint}`);
}
}
debugInfo += `, Testing commit message generation`;
// Set a timeout to fail if the streaming doesn't start or completeView on GitHub (pinned to 58e5313667)