mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 21:03:19 +00:00
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
This commit is contained in:
parent
de2de851c8
commit
aac68ba35c
1 changed files with 10 additions and 1 deletions
|
|
@ -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<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,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue