fix(ai): don't pass empty string apiKey to Google GenAI SDK (#362)
When no GEMINI_API_KEY is set, the fallback `|| ""` passes an empty
string to `new GoogleGenAI({ apiKey: "" })`. The SDK treats this as a
user-provided API key and warns that it will take precedence over
Vertex AI project/location auth, breaking Vertex users.
Pass `undefined` instead so the SDK falls through to Vertex auth.
Co-authored-by: Muness Castle <munesscastle@artium.ai>
This commit is contained in:
@@ -80,7 +80,7 @@ export const streamGoogle: StreamFunction<"google-generative-ai"> = (
|
||||
let rawRequestDump: RawHttpRequestDump | undefined;
|
||||
|
||||
try {
|
||||
const apiKey = options?.apiKey || getEnvApiKey(model.provider) || "";
|
||||
const apiKey = options?.apiKey || getEnvApiKey(model.provider);
|
||||
const client = createClient(model, apiKey);
|
||||
const params = buildParams(model, context, options);
|
||||
options?.onPayload?.(params);
|
||||
|
||||
Reference in New Issue
Block a user