gitbutlerapp/gitbutler · error
When using GitButler's API to summarize code, you must be…
Error message
When using GitButler's API to summarize code, you must be logged in
What it means
AIService.buildClient() requires an authenticated GitButler token when the model kind is set to use GitButler's cloud API. If no token is stored in the token memory service, this error is thrown instead of constructing a ButlerAIClient.
Solutions
- Log in to GitButler so a token is available.
- Switch the AI model setting to a local provider (Ollama/LM Studio) or BYO-key provider if you don't want to log in.
- Re-authenticate if the token was cleared or expired.
Example fix
// before (app state) modelKind: GitButlerAPI, token: null // after sign in via the GitButler UI, then keep modelKind: GitButlerAPI // token now present
Defensive patterns
Strategy: validation
Validate before calling
const token = get(tokenMemoryService.token);
if (!token && modelKind === ModelKind.GitButlerAPI) {
// prompt user to log in or switch to a local/BYO-key model before calling
} Try / catch
try {
await aiService.summarize(...);
} catch (e) {
if (e.message.includes('you must be logged in')) {
// trigger the login flow or offer provider switch in the UI
} else {
throw e;
}
} Prevention
- Check login state before enabling GitButler-API AI features in the UI.
- Re-authenticate after token expiry instead of retrying blindly.
- Default to a local model when the user is not logged in.
When it happens
Trigger: AI model setting is GitButler API while the user is not logged in to GitButler (token absent) at the time aiClient is requested.
Common situations: User enabled AI summarization but never signed in; token expired/cleared after a restart; account logout while AI settings still point at the cloud model.
Related errors
- configured storage path
- configured storage path
- DefaultTargetNotFound
- Enter an Anthropic API key
- Enter an OpenAI API key
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/e8e382c049ac1b8a.
Report an issue: GitHub.
Appendix: source
Thrown at apps/desktop/src/lib/ai/service.ts:314
async validateGitButlerAPIConfiguration(): Promise<boolean> {
if (!(await this.usingGitButlerAPI())) {
return false;
}
return !!get(this.tokenMemoryService.token);
}
// This optionally returns a summarizer. There are a few conditions for how this may occur
// Firstly, if the user has opted to use the GB API and isn't logged in, it will return undefined
// Secondly, if the user has opted to bring their own key but hasn't provided one, it will return undefined
async buildClient(): Promise<AIClient | undefined> {
const modelKind = await this.getModelKind();
if (await this.usingGitButlerAPI()) {
// TODO(CTO): Once @estib has landed the new auth, it would be good to
// about a good way of checking whether the user is authenticated.
if (!get(this.tokenMemoryService.token)) {
throw new Error("When using GitButler's API to summarize code, you must be logged in");
}
return new ButlerAIClient(this.cloud, modelKind);
}
if (modelKind === ModelKind.Ollama) {
const ollamaEndpoint = await this.getOllamaEndpoint();
const ollamaModelName = await this.getOllamaModelName();
return new OllamaClient(ollamaEndpoint, ollamaModelName);
}
if (modelKind === ModelKind.LMStudio) {
const lmStudioEndpoint = await this.getLMStudioEndpoint();
const lmStudioModelName = await this.getLMStudioModelName();
if (!lmStudioEndpoint) {
throw new Error("When using LM Studio, you must provide a valid endpoint");
}View on GitHub (pinned to 58e5313667)