wavetermdev/waveterm · error

ai:endpoint is required

Error message

ai:endpoint is required

What it means

buildGeminiHTTPRequest requires a non-empty endpoint to know where to POST the Gemini request. 'ai:endpoint is required' is thrown when chatOpts.Config.Endpoint is empty; unlike some clients, this library does not fall back to the default Gemini base URL for you.

Source

Thrown at pkg/aiusechat/gemini/gemini-backend.go:68

				Text: text,
			})
			break
		}
	}
}

// buildGeminiHTTPRequest creates an HTTP request for the Gemini API
func buildGeminiHTTPRequest(ctx context.Context, contents []GeminiContent, chatOpts uctypes.WaveChatOpts) (*http.Request, error) {
	opts := chatOpts.Config

	if opts.Model == "" {
		return nil, errors.New("ai:model is required")
	}
	if opts.APIToken == "" {
		return nil, errors.New("ai:apitoken is required")
	}
	if opts.Endpoint == "" {
		return nil, errors.New("ai:endpoint is required")
	}

	maxTokens := opts.MaxTokens
	if maxTokens <= 0 {
		maxTokens = GeminiDefaultMaxTokens
	}

	// Build request body
	reqBody := &GeminiRequest{
		Contents: contents,
		GenerationConfig: &GeminiGenerationConfig{
			MaxOutputTokens: int32(maxTokens),
			Temperature:     0.7, // Default temperature
		},
	}

	// Map thinking level for Gemini 3+ models
	if opts.ThinkingLevel != "" && strings.Contains(opts.Model, "gemini-3") {

View on GitHub (pinned to a4447c1563)

Solutions

  1. Set the ai:endpoint setting for the Gemini backend to the Gemini API base URL (or your proxy/gateway URL)
  2. If your code constructs WaveChatOpts programmatically, assign opts.Endpoint explicitly
  3. Check for config that sets endpoint under a different provider key and move/duplicate it for Gemini
  4. If a default is desired, set it at the call site before invoking RunGeminiChatStep rather than relying on the library

Example fix

// before
opts := uctypes.WaveChatOpts{Config: uctypes.WaveChatOptsConfig{Model: "gemini-2.0-flash", APIToken: key}}
// after
opts := uctypes.WaveChatOpts{Config: uctypes.WaveChatOptsConfig{Model: "gemini-2.0-flash", APIToken: key, Endpoint: "https://generativelanguage.googleapis.com"}}
Defensive patterns

Strategy: validation

Validate before calling

if chatOpts.Config.Endpoint == "" {
    chatOpts.Config.Endpoint = "https://generativelanguage.googleapis.com"
}

Try / catch

if _, _, _, err := RunGeminiChatStep(ctx, handler, chatOpts, cont); err != nil {
    if err.Error() == "ai:endpoint is required" {
        chatOpts.Config.Endpoint = "https://generativelanguage.googleapis.com"
        return retry()
    }
    return err
}

Prevention

When it happens

Trigger: RunGeminiChatStep is called with chatOpts.Config.Endpoint == "": the endpoint was never configured for the Gemini backend, was cleared, or provider-specific endpoint setup was skipped when constructing WaveChatOpts.

Common situations: Custom endpoint configured for another provider but not Gemini; a config reset wiped the endpoint; users behind a proxy/gateway forgot to set the Gemini endpoint; code paths that build opts manually and omit Endpoint.

Understand the failure class

Background: "missing required config value" errors: why libraries refuse to start when a configuration key is empty, unset, or blank — this error's family across 48 libraries.

Related errors


AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01). Data as JSON: /api/errors/2d9dcd3e3293fc02. Report an issue: GitHub.