Use Vite env key for Gemini

This commit is contained in:
Anthony
2025-11-27 21:19:46 +08:00
parent 7f75b44af1
commit 1cdcc08eae
5 changed files with 12 additions and 17 deletions

View File

@@ -2,10 +2,14 @@ import { GoogleGenAI, Modality } from '@google/genai';
import { VoiceName } from '../types';
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 });
};