Text to video

Text to Video Tool (Runway)

Text to Video Tool (Runway)

--- 🔁 Backend Code (Node.js + Express) // server.js const express = require('express'); const fetch = require('node-fetch'); const cors = require('cors'); const app = express(); const PORT = process.env.PORT || 3000; const RUNWAY_API_KEY = "آ. key_887e23bef70912782fd44aac0ee676a9d7a7e2c6fa32c2bb00d35867462b8b3a69cc7ff41fb4c02648e0381df5415f9236af9cbe74639578d47dcfce35dc5d5b; app.use(cors()); app.use(express.json()); app.post('/api/video', async (req, res) => { const { prompt } = req.body; try { const response = await fetch('https://api.runwayml.com/v1/generate', { method: 'POST', headers: { 'Authorization': `Bearer ${RUNWAY_API_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ model: "stable-video-diffusion", // یا "gen-2" اگر available ہو input: { prompt: prompt, num_frames: 24, output_format: "mp4" } }) }); const result = await response.json(); // فرض کریں API آپ کو video_url واپس دیتی ہے res.json({ video_url: result.output.video }); } catch (error) { console.error(error); res.status(500).json({ error: "Video generation failed" }); } }); app.listen(PORT, () => { console.log(`Server running on port ${PORT}`); });

No comments:

Post a Comment