From 381260059a680bfd8de7c45d7740a567c1d6c238 Mon Sep 17 00:00:00 2001 From: Achim Rohn Date: Thu, 12 Feb 2026 22:10:10 +0100 Subject: [PATCH] Add option to set BaseURL in NewMistralClient --- llm/mistral.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/llm/mistral.go b/llm/mistral.go index b30bbb9..f05d77c 100644 --- a/llm/mistral.go +++ b/llm/mistral.go @@ -127,13 +127,24 @@ type MistralClientImpl struct { HTTPClient *http.Client } -// NewClient creates a new Mistral API client -func NewMistralClient(apiKey string) *MistralClientImpl { - return &MistralClientImpl{ +type MistralClientOption = func(*MistralClientImpl) + +func BaseUrlOption(url string) MistralClientOption { + return func(c *MistralClientImpl) { + c.BaseURL = url + } +} + +func NewMistralClient(apiKey string, options ...MistralClientOption) *MistralClientImpl { + client := &MistralClientImpl{ APIKey: apiKey, BaseURL: "https://api.mistral.ai", HTTPClient: &http.Client{}, } + for _, option := range options { + option(client) + } + return client } // CreateChatCompletion sends a chat completion request to the API @@ -150,6 +161,8 @@ func (c *MistralClientImpl) CreateChatCompletion(req *ChatCompletionRequest) (*C request.Header.Set("Content-Type", "application/json") request.Header.Set("Authorization", "Bearer "+c.APIKey) + ersteller.Debug("authorization", "Bearer ", c.APIKey) + ersteller.Debug("base url", c.BaseURL) response, err := c.HTTPClient.Do(request) if err != nil {