From e4277bab19c8d951e97a39fbdfdb9cac993b7bcf Mon Sep 17 00:00:00 2001 From: theBucky <16464422+theBucky@users.noreply.github.com> Date: Thu, 18 Dec 2025 22:03:43 +0800 Subject: [PATCH] fix(ai): pass baseUrl to Google GenAI SDK via httpOptions Previously, when using 'google-generative-ai' API with a custom baseUrl in models.json, the baseUrl was ignored and requests always went to the default Google endpoint. Now the provider correctly passes model.baseUrl to the SDK's httpOptions.baseUrl, enabling use of custom endpoints or API proxies. Fixes #216 --- packages/ai/src/providers/google.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/ai/src/providers/google.ts b/packages/ai/src/providers/google.ts index 8fcd9ef34..42c3bbe0d 100644 --- a/packages/ai/src/providers/google.ts +++ b/packages/ai/src/providers/google.ts @@ -258,9 +258,18 @@ function createClient(model: Model<"google-generative-ai">, apiKey?: string): Go } apiKey = process.env.GEMINI_API_KEY; } + + const httpOptions: { baseUrl?: string; headers?: Record } = {}; + if (model.baseUrl) { + httpOptions.baseUrl = model.baseUrl; + } + if (model.headers) { + httpOptions.headers = model.headers; + } + return new GoogleGenAI({ apiKey, - httpOptions: model.headers ? { headers: model.headers } : undefined, + httpOptions: Object.keys(httpOptions).length > 0 ? httpOptions : undefined, }); }