{"record":{"id":"370e6041e48083ee","repo":"gitbutlerapp/gitbutler","slug":"please-sign-in-to-use-gitbutler-s-ai-api","errorCode":null,"errorMessage":"Please sign in to use GitButler's AI API","messagePattern":"Please sign in to use GitButler's AI API","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"apps/desktop/src/components/settings/AiCredentialCheck.svelte","lineNumber":77,"sourceCode":"\t\tabortController = new AbortController();\n\n\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`;","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/apps/desktop/src/components/settings/AiCredentialCheck.svelte#L59-L95","documentation":"Thrown by the AI settings credential check when validateConfiguration() reports the AI config invalid, usingGitButlerAPI() is true (requests would route through GitButler's hosted AI), and userService.user is null. It distinguishes 'not signed in' from a bad key so the UI can point at account state rather than the key field.","triggerScenarios":"Pressing the test/check button in Settings with the GitButler-hosted OpenAI/Anthropic option selected while the app has no signed-in user (session expired or never started).","commonSituations":"Session token expired after leaving the app open; user signed out in Account settings but AI provider still set to the hosted API; fresh install where sign-in was skipped during onboarding.","solutions":["Sign in via Account settings and run the check again.","If you did not intend to use the hosted API, switch the AI provider to your own key and save."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const usingButlerAPI = await aiService.usingGitButlerAPI();\nif (usingButlerAPI && !userService.user) {\n  error = \"Sign in to GitButler to use the hosted AI API\";\n  return;\n}\n// run the credential check","typeGuard":"const isSignedIn = (u: { id: string } | null | undefined): u is { id: string } => u != null;","tryCatchPattern":"try {\n  await runCheck();\n} catch (e) {\n  if (e instanceof Error && e.message.includes(\"sign in\")) {\n    error = \"Sign in from Account settings, then test again.\";\n  } else {\n    error = e instanceof Error ? e.message : \"Unknown error\";\n  }\n}","preventionTips":["Check userService.user before enabling the hosted-API option in AI settings.","Sign out should also reset the AI provider away from the hosted API.","Treat session-expiry events as a trigger to re-validate AI configuration."],"tags":["gitbutler","ai","authentication","settings","svelte"],"backgroundTag":"sign-in-required","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","schemaVersion":2},"datasetVersion":"2026-08-23T13:39:53.451Z"}