const API_URL = "https://router.huggingface.co/v1/chat/completions"; async function generateScript(prompt) { const response = await fetch(API_URL, { method: "POST", headers: { "Content-Type": "application/json", "Authorization": "Bearer " + HF_TOKEN }, body: JSON.stringify({ model: "Qwen/Qwen2.5-7B-Instruct", messages: [ { role: "user", content: prompt } ], max_tokens: 500 }) }); if (!response.ok) { throw new Error("AI generation failed: " + response.status); } const data = await response.json(); return data.choices[0].message.content; }