{"record":{"id":"bf79dd3fb6ff7724","repo":"gitbutlerapp/gitbutler","slug":"please-provide-a-valid-api-key-for-your-selected-a","errorCode":null,"errorMessage":"Please provide a valid API key for your selected AI service","messagePattern":"Please provide a valid API key for your selected AI service","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/desktop/src/components/settings/AiCredentialCheck.svelte","lineNumber":79,"sourceCode":"\t\ttry {\n\t\t\t// Get current model kind\n\t\t\tmodelKind = await aiService.getModelKind();\n\t\t\tdebugInfo = `Model kind: ${modelKind}`;\n\n\t\t\t// Check if using GitButler API\n\t\t\tisUsingButlerAPI = await aiService.usingGitButlerAPI();\n\t\t\tdebugInfo += `, Using GB API: ${isUsingButlerAPI}`;\n\n\t\t\t// Check if configuration is valid\n\t\t\tconst isConfigValid = await aiService.validateConfiguration();\n\t\t\tdebugInfo += `, Config valid: ${isConfigValid}`;\n\n\t\t\tif (!isConfigValid) {\n\t\t\t\tif (modelKind === ModelKind.OpenAI || modelKind === ModelKind.Anthropic) {\n\t\t\t\t\tif (isUsingButlerAPI && !userService.user) {\n\t\t\t\t\t\tthrow new Error(\"Please sign in to use GitButler's AI API\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new Error(\"Please provide a valid API key for your selected AI service\");\n\t\t\t\t\t}\n\t\t\t\t} else if (modelKind === ModelKind.Ollama) {\n\t\t\t\t\t// Get Ollama configuration for more detailed error\n\t\t\t\t\tconst endpoint = await aiService.getOllamaEndpoint();\n\t\t\t\t\tconst model = await aiService.getOllamaModelName();\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Please check Ollama configuration: endpoint=${endpoint}, model=${model}`,\n\t\t\t\t\t);\n\t\t\t\t} else if (modelKind === ModelKind.LMStudio) {\n\t\t\t\t\t// Get LM Studio configuration for more detailed error\n\t\t\t\t\tconst endpoint = await aiService.getLMStudioEndpoint();\n\t\t\t\t\tthrow new Error(`Please check LM Studio configuration: endpoint=${endpoint}`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tdebugInfo += `, Testing commit message generation`;\n\n\t\t\t// Set a timeout to fail if the streaming doesn't start or complete","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/apps/desktop/src/components/settings/AiCredentialCheck.svelte#L61-L97","documentation":"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.","triggerScenarios":"Thrown at apps/desktop/src/components/settings/AiCredentialCheck.svelte:79 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}