Update src/components/AIChat.tsx
Browse files
src/components/AIChat.tsx
CHANGED
|
@@ -34,7 +34,8 @@ export function AIChat({
|
|
| 34 |
const [keyInput, setKeyInput] = useState('');
|
| 35 |
|
| 36 |
const ai = useMemo(() => {
|
| 37 |
-
|
|
|
|
| 38 |
if (!key) return null;
|
| 39 |
return new GoogleGenAI({ apiKey: key });
|
| 40 |
}, [geminiApiKey]);
|
|
|
|
| 34 |
const [keyInput, setKeyInput] = useState('');
|
| 35 |
|
| 36 |
const ai = useMemo(() => {
|
| 37 |
+
// Priority: 1. User provided key, 2. Vite environment variable
|
| 38 |
+
const key = geminiApiKey || (import.meta as any).env?.VITE_GEMINI_API_KEY;
|
| 39 |
if (!key) return null;
|
| 40 |
return new GoogleGenAI({ apiKey: key });
|
| 41 |
}, [geminiApiKey]);
|