mirror of
https://github.com/Tony0410/News-reader-pro.git
synced 2026-05-24 21:31:44 +08:00
Use Vite env key for Gemini
This commit is contained in:
@@ -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 });
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user