route.ts 705 B

12345678910111213141516171819202122232425
  1. import { streamText } from "ai";
  2. import { getVideoPrompt } from "@/lib/catalog";
  3. export const maxDuration = 30;
  4. // Generate prompt from catalog - uses Remotion schema's prompt template with custom rules
  5. const SYSTEM_PROMPT = getVideoPrompt();
  6. const MAX_PROMPT_LENGTH = 500;
  7. const DEFAULT_MODEL = "anthropic/claude-haiku-4.5";
  8. export async function POST(req: Request) {
  9. const { prompt } = await req.json();
  10. const sanitizedPrompt = String(prompt || "").slice(0, MAX_PROMPT_LENGTH);
  11. const result = streamText({
  12. model: process.env.AI_GATEWAY_MODEL || DEFAULT_MODEL,
  13. system: SYSTEM_PROMPT,
  14. prompt: sanitizedPrompt,
  15. temperature: 0.7,
  16. });
  17. return result.toTextStreamResponse();
  18. }