Skip to content

Commit a58bf45

Browse files
fix: Add GOOGLE_API_KEY to google provider environment variables
1 parent fa18cfd commit a58bf45

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

packages/core/lib/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ export const providerEnvVarMap: Partial<
399399
> = {
400400
openai: "OPENAI_API_KEY",
401401
anthropic: "ANTHROPIC_API_KEY",
402-
google: ["GEMINI_API_KEY", "GOOGLE_GENERATIVE_AI_API_KEY"],
402+
google: ["GEMINI_API_KEY", "GOOGLE_GENERATIVE_AI_API_KEY", "GOOGLE_API_KEY"],
403403
groq: "GROQ_API_KEY",
404404
cerebras: "CEREBRAS_API_KEY",
405405
togetherai: "TOGETHER_AI_API_KEY",
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { describe, it, expect, beforeEach, afterEach } from "vitest";
2+
import { loadApiKeyFromEnv } from "../lib/utils";
3+
4+
describe("Google API Key Enviroment Variable", () => {
5+
const originalEnv = process.env;
6+
7+
beforeEach(() => {
8+
process.env = { ...originalEnv };
9+
});
10+
11+
afterEach(() => {
12+
process.env = originalEnv;
13+
});
14+
15+
it("should read GOOGLE_API_KEY for google provider", () => {
16+
process.env.GOOGLE_API_KEY = "test-google-key";
17+
18+
const apiKey = loadApiKeyFromEnv("google", () => {});
19+
20+
expect(apiKey).toBe("test-google-key");
21+
});
22+
23+
it("should read GEMINI_API_KEY for google provider", () => {
24+
process.env.GEMINI_API_KEY = "test-gemini-key";
25+
26+
const apiKey = loadApiKeyFromEnv("google", () => {});
27+
28+
expect(apiKey).toBe("test-gemini-key");
29+
});
30+
31+
it("should read GOOGLE_GENERATIVE_AI_API_KEY for google provider", () => {
32+
process.env.GOOGLE_GENERATIVE_AI_API_KEY = "test-gen-ai-key";
33+
34+
const apiKey = loadApiKeyFromEnv("google", () => {});
35+
36+
expect(apiKey).toBe("test-gen-ai-key");
37+
});
38+
39+
it("should prioritize GEMINI_API_KEY over GOOGLE_API_KEY", () => {
40+
process.env.GEMINI_API_KEY = "gemini-key";
41+
process.env.GOOGLE_API_KEY = "google-key";
42+
43+
const apiKey = loadApiKeyFromEnv("google", () => {});
44+
45+
expect(apiKey).toBe("gemini-key")
46+
});
47+
});

0 commit comments

Comments
 (0)