gitbutlerapp/gitbutler · error

When using LM Studio, you must provide a valid endpoint

Error message

When using LM Studio, you must provide a valid endpoint

What it means

buildClient() throws this when the configured model kind is LM Studio but no endpoint URL is configured (getLMStudioEndpoint() returned an empty/falsy value). A LMStudioClient cannot be constructed without a server URL.

Solutions

  1. Set the LM Studio endpoint in AI settings (e.g. http://localhost:1234/v1).
  2. Start LM Studio's local server and copy the advertised endpoint URL.
  3. Re-save AI settings if a migration/reset cleared them.

Example fix

// before
lMStudioEndpoint: ''
// after
lMStudioEndpoint: 'http://localhost:1234/v1'
Defensive patterns

Strategy: validation

Validate before calling

const endpoint = await aiService.getLMStudioEndpoint();
if (!endpoint) {
  // show settings UI asking for the LM Studio endpoint before invoking AI
}

Try / catch

try {
  await aiService.summarize(...);
} catch (e) {
  if (e.message.includes('must provide a valid endpoint')) {
    // open AI settings to let the user enter the endpoint
  } else {
    throw e;
  }
}

Prevention

When it happens

Trigger: User selects LM Studio as AI provider but the endpoint setting is empty or unset.

Common situations: Fresh install with LM Studio chosen but endpoint never filled in; settings cleared after reset/migration; endpoint stored in a settings key that was renamed in an update.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/18373c13c4aa2845. Report an issue: GitHub.

Appendix: source

Thrown at apps/desktop/src/lib/ai/service.ts:331

			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");
			}

			return new LMStudioClient(lmStudioEndpoint, lmStudioModelName);
		}

		if (modelKind === ModelKind.OpenAI) {
			const openAIModelName = await this.getOpenAIModelName();
			const openAIKey = await this.getOpenAIKey();
			const openAICustomEndpoint = await this.getOpenAICustomEndpoint();

			if (!openAIKey) {
				throw new Error(
					"When using OpenAI in a bring your own key configuration, you must provide a valid token",
				);
			}

			return new OpenAIClient(openAIKey, openAIModelName, openAICustomEndpoint);
		}

View on GitHub (pinned to 58e5313667)