Merge pull request #221 from theBucky/fix/google-provider-baseurl

fix(ai): pass baseUrl to Google GenAI SDK via httpOptions
This commit is contained in:
Mario Zechner 2025-12-18 15:40:05 +01:00 committed by GitHub
commit 98e5b4dce9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -265,9 +265,18 @@ function createClient(model: Model<"google-generative-ai">, apiKey?: string): Go
}
apiKey = process.env.GEMINI_API_KEY;
}
const httpOptions: { baseUrl?: string; headers?: Record<string, string> } = {};
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,
});
}