const API_BASE_URL = ""; export type InputType = "text" | "url" | "pdf"; export type Category = "tech_system" | "product_startup" | "mathematical"; export type Quality = "low" | "medium" | "high" | "ultra"; export interface JobStatus { job_id: string; status: "pending" | "generating_code" | "rendering" | "completed" | "failed"; progress: { percentage: number; message: string; }; error?: string; output_url?: string; created_at: string; } export const api = { async createVideo( input_data: string, input_type: InputType, category: Category, quality: Quality = "high" ) { const response = await fetch(`/api/generate`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ input_data, input_type, category, quality, }), }); if (!response.ok) { const error = await response.json(); throw new Error(error.detail || "Failed to create video job"); } return response.json(); }, async getJobStatus(jobId: string): Promise { // Calls /api/jobs/[id] const response = await fetch(`${API_BASE_URL}/api/jobs/${jobId}`); if (!response.ok) { throw new Error("Failed to get job status"); } return response.json(); }, getVideoUrl(jobId: string) { // Calls /api/videos/[id] (we might need to proxy this too or return direct URL) // For demo, we return direct URL. For real, we might need a proxy if it's not public. // But usually the backend returns a full URL or we proxy. // Let's assume the backend returns a full URL in the status, so this helper might be less used // or we point it to the proxy. return `${API_BASE_URL}/api/videos/${jobId}`; } };