Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion apps/web/next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const nextConfig: NextConfig = {
},
reactStrictMode: true,
productionBrowserSourceMaps: true,
output: "standalone",
images: {
remotePatterns: [
{
Expand Down
1 change: 1 addition & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@hookform/resolvers": "^3.9.1",
"@opencut/auth": "workspace:*",
"@opencut/db": "workspace:*",
"@radix-ui/react-dialog": "^1.1.7",
"@radix-ui/react-separator": "^1.1.7",
"@t3-oss/env-core": "^0.13.8",
"@t3-oss/env-nextjs": "^0.13.8",
Expand Down
59 changes: 59 additions & 0 deletions apps/web/src/app/api/ai/generate-video/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { NextResponse } from "next/server";
import { fal } from "@fal-ai/client";

// Configure fal with server-side credentials
fal.config({
credentials: process.env.FAL_KEY,
});

export async function POST(request: Request) {
try {
const { prompt, image_url, aspect_ratio, duration, generate_audio, resolution } = await request.json();

if (!prompt) {
return NextResponse.json(
{ error: "Prompt is required" },
{ status: 400 }
);
}

if (!image_url) {
return NextResponse.json(
{ error: "Image URL is required" },
{ status: 400 }
);
}

// Build input params for Veo 3.1 Fast
const input = {
prompt,
image_url,
aspect_ratio: aspect_ratio || "16:9",
duration: duration || "8s",
generate_audio: generate_audio !== undefined ? generate_audio : true,
resolution: resolution || "720p",
};

console.log("Using fal-ai/veo3.1/fast/image-to-video with input:", input);

// Call fal API directly from server
const result = await fal.subscribe("fal-ai/veo3.1/fast/image-to-video", {
input,
logs: true,
onQueueUpdate: (update) => {
if (update.status === "IN_PROGRESS") {
update.logs.map((log) => log.message).forEach(console.log);
}
},
});

return NextResponse.json(result.data);
} catch (error) {
console.error("Video generation error:", error);
return NextResponse.json(
{ error: error instanceof Error ? error.message : "Video generation failed" },
{ status: 500 }
);
}
}

Loading
Loading