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:
Muness Castle
2026-03-10 19:59:09 -04:00
committed by GitHub
parent 486fd4c753
commit d8a4b6ba10
+1 -1
View File
@@ -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);