Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions LiveEditFronten/services/gemini.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@

import { GoogleGenAI } from "@google/genai";
import { VideoConfig } from "../types";
import { BACKEND_URL } from './api';

// Note: process.env.API_KEY is pre-configured
export const getAiClient = () => new GoogleGenAI({ apiKey: import.meta.env.VITE_GEMINI_API_KEY });
// Note: API key is now handled server-side via backend proxy
export const getAiClient = () => new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });

export async function generateAiVideo(config: VideoConfig, onProgress?: (msg: string) => void) {
const ai = getAiClient();
Expand Down Expand Up @@ -32,7 +31,11 @@ export async function generateAiVideo(config: VideoConfig, onProgress?: (msg: st
const downloadLink = operation.response?.generatedVideos?.[0]?.video?.uri;
if (!downloadLink) throw new Error("Video generation failed - no URI returned");

const response = await fetch(`${downloadLink}&key=${import.meta.env.VITE_GEMINI_API_KEY}`);
const response = await fetch(`${BACKEND_URL}/api/download-video`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ downloadLink })
});
const blob = await response.blob();
return URL.createObjectURL(blob);
}
Expand Down
Loading