From d8a4b6ba10493a4062ba3f8b329188abfa2158c2 Mon Sep 17 00:00:00 2001 From: Muness Castle <931+muness@users.noreply.github.com> Date: Tue, 10 Mar 2026 19:59:09 -0400 Subject: [PATCH] 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 --- packages/ai/src/providers/google.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ai/src/providers/google.ts b/packages/ai/src/providers/google.ts index cb25c71d4..9386315e5 100644 --- a/packages/ai/src/providers/google.ts +++ b/packages/ai/src/providers/google.ts @@ -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);