Skip to content

Commit 8d1ce6e

Browse files
authored
fix: support custom base URL for Gemini provider (#520)
* fix: support custom base URL for Gemini provider Fixes #512 The Gemini provider was throwing an error when a custom base URL was set, causing the chat interface to crash. The @google/genai SDK actually supports custom base URLs via the httpOptions.baseUrl configuration. This change removes the error and passes the custom base URL to the SDK, enabling users to use custom Gemini-compatible endpoints (like proxies or self-hosted alternatives). * fix: Fix lint
1 parent de0a7c4 commit 8d1ce6e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/core/llm/gemini.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,13 @@ export class GeminiProvider extends BaseLLMProvider<
4949

5050
constructor(provider: Extract<LLMProvider, { type: 'gemini' }>) {
5151
super(provider)
52-
if (provider.baseUrl) {
53-
throw new Error('Gemini does not support custom base URL')
54-
}
5552

56-
this.client = new GoogleGenAI({ apiKey: provider.apiKey ?? '' })
53+
this.client = new GoogleGenAI({
54+
apiKey: provider.apiKey ?? '',
55+
httpOptions: provider.baseUrl
56+
? { baseUrl: provider.baseUrl.replace(/\/+$/, '') }
57+
: undefined,
58+
})
5759
this.apiKey = provider.apiKey ?? ''
5860
}
5961

0 commit comments

Comments
 (0)