Merge pull request #3 from Tony0410/codex/update-geminiservice-to-use-vite_api_key

Use Vite env variable for Gemini key
This commit is contained in:
Anthony
2025-11-27 21:19:58 +08:00
committed by GitHub
5 changed files with 12 additions and 17 deletions

View File

@@ -3,10 +3,14 @@ import { VoiceName } from '../types';
import { normalizeUrl } from '../utils/url';
const getAiClient = () => {
const apiKey = process.env.API_KEY;
const apiKey = import.meta.env.VITE_API_KEY;
if (!apiKey) {
throw new Error("API Key is missing");
throw new Error(
"Gemini API key is missing. Set VITE_API_KEY in your .env.local file (e.g., VITE_API_KEY=your_key_here)."
);
}
return new GoogleGenAI({ apiKey });
};