AI short drama & micro-drama video generator — turns any idea into a complete short-form drama using multi-agent AI pipeline (screenwriter → storyboard → frames → video). Seedance 2 VIP, Kling 3.0 Pro, Veo 3.1, Sora 2.
Python agentic-aiai-dramaai-filmmakingai-short-dramaai-video-generationdrama-generatorfastapigenerative-aiimage-to-videokling-aimicro-dramamulti-agentnextjsseedanceseedance2short-dramashort-filmshort-form-videotext-to-videoveo3
feat: upgrade to premium models for micro-drama quality
Anil Matchab9d9c12b0fa4
diff --git a/server/pipelines/script2video.py b/server/pipelines/script2video.pyindex 86ca5f9..f0bd8c6 100644--- a/server/pipelines/script2video.py+++ b/server/pipelines/script2video.py@@ -133,7 +133,7 @@ class Script2VideoPipeline:"High quality, detailed face, neutral background, studio lighting, ""character reference sheet, full face visible.")- return await self.image_gen.generate_image(prompt, width=512, height=768)+ return await self.image_gen.generate_image(prompt, aspect_ratio="2:3")async def _generate_first_frame(self,@@ -177,7 +177,7 @@ class Script2VideoPipeline:print(f"Warning: reference image generation failed, falling back to T2I: {e}")# Fallback to regular T2I- return await self.image_gen.generate_image(full_prompt, width=1920, height=1080)+ return await self.image_gen.generate_image(full_prompt, aspect_ratio="16:9")async def _generate_shot_video(self, shot: ShotDescription, shot_idx: int, working_dir: strdiff --git a/server/tools/muapi_image_generator.py b/server/tools/muapi_image_generator.pyindex 8e68588..bd1adeb 100644--- a/server/tools/muapi_image_generator.py+++ b/server/tools/muapi_image_generator.py@@ -14,15 +14,23 @@ class MuAPIImageGenerator:self.api_key = api_key or os.environ["MUAPI_KEY"]self.headers = {"x-api-key": self.api_key, "Content-Type": "application/json"}- async def generate_image(- self, prompt: str, width: int = 1024, height: int = 1024- ) -> str:- """Generate an image from a text prompt. Returns URL of generated image."""+ async def generate_image(self, prompt: str, aspect_ratio: str = "1:1") -> str:+ """Generate a photorealistic character portrait.++ Uses Seedream v4.5 (high quality) — purpose-built for photorealistic+ human portraits with accurate skin tones, facial detail, and dramatic+ lighting. Superior to flux-dev for micro-drama character sheets.+ Returns URL of generated image.+ """async with httpx.AsyncClient(timeout=60) as client:resp = await client.post(- f"{MUAPI_BASE}/flux-dev-image",+ f"{MUAPI_BASE}/bytedance-seedream-v4.5",headers=self.headers,- json={"prompt": prompt, "width": width, "height": height},+ json={+ "prompt": prompt,+ "aspect_ratio": aspect_ratio,+ "quality": "high",+ },)resp.raise_for_status()data = resp.json()@@ -32,14 +40,7 @@ class MuAPIImageGenerator:raise ValueError(f"No request_id in response: {data}")result = await self._poll_until_done(request_id, timeout=300)- outputs = result.get("outputs", [])- if not outputs:- raise ValueError(f"No outputs in result: {result}")-- output = outputs[0]- if isinstance(output, dict):- return output.get("url") or output.get("image_url") or str(output)- return str(output)+ return self._extract_url(result)async def generate_image_with_reference(self,@@ -47,15 +48,22 @@ class MuAPIImageGenerator:reference_url: str,aspect_ratio: str = "16:9",) -> str:- """Generate an image using a reference image for character consistency. Returns URL."""+ """Generate a scene frame using a character reference image.++ Uses Nano Banana 2 Edit (Google Imagen 4) — excellent at preserving+ character appearance from a reference while composing a new scene,+ giving strong visual consistency across shots.+ Returns URL of generated image.+ """async with httpx.AsyncClient(timeout=60) as client:resp = await client.post(- f"{MUAPI_BASE}/flux-kontext-dev-i2i",+ f"{MUAPI_BASE}/nano-banana-2-edit",headers=self.headers,json={"prompt": prompt,"images_list": [reference_url],"aspect_ratio": aspect_ratio,+ "resolution": "2k",},)resp.raise_for_status()@@ -66,17 +74,18 @@ class MuAPIImageGenerator:raise ValueError(f"No request_id in response: {data}")result = await self._poll_until_done(request_id, timeout=300)+ return self._extract_url(result)++ def _extract_url(self, result: dict) -> str:outputs = result.get("outputs", [])if not outputs:raise ValueError(f"No outputs in result: {result}")-output = outputs[0]if isinstance(output, dict):return output.get("url") or output.get("image_url") or str(output)return str(output)async def _poll_until_done(self, request_id: str, timeout: int = 300) -> dict:- """Poll MuAPI until the job completes or timeout is reached."""elapsed = 0async with httpx.AsyncClient(timeout=30) as client:while elapsed < timeout:@@ -99,7 +108,6 @@ class MuAPIImageGenerator:)elif status == "cancelled":raise RuntimeError(f"MuAPI image job {request_id} was cancelled")- # queued / pending / processing — keep pollingraise TimeoutError(f"MuAPI image job {request_id} did not complete within {timeout}s"diff --git a/server/tools/muapi_video_generator.py b/server/tools/muapi_video_generator.pyindex df5696d..42032eb 100644--- a/server/tools/muapi_video_generator.py+++ b/server/tools/muapi_video_generator.py@@ -21,16 +21,64 @@ class MuAPIVideoGenerator:duration: int = 5,aspect_ratio: str = "16:9",) -> str:- """Generate a video clip from an image + motion prompt. Returns URL of generated video."""+ """Generate a cinematic video clip from an image + motion prompt.++ Primary: Seedance 2 VIP I2V — the highest quality Seedance model,+ with cinematic motion, strong temporal consistency, and excellent+ dramatic scene handling. Supports 4–15 second clips at 16:9.++ Fallback: Kling v2.1 Master I2V — master-tier Kling with superior+ motion quality vs Standard, used if Seedance 2 VIP fails.++ Returns URL of generated video.+ """+ # Seedance 2 VIP supports 4-15s; clamp to valid range+ sd2_duration = max(4, min(15, duration))++ try:+ return await self._seedance2_vip(prompt, image_url, sd2_duration, aspect_ratio)+ except Exception as e:+ print(f"Seedance 2 VIP failed ({e}), falling back to Kling Master...")+ # Kling supports 5 or 10s+ kling_duration = 5 if duration <= 7 else 10+ return await self._kling_master(prompt, image_url, kling_duration, aspect_ratio)++ async def _seedance2_vip(+ self, prompt: str, image_url: str, duration: int, aspect_ratio: str+ ) -> str:async with httpx.AsyncClient(timeout=60) as client:resp = await client.post(- f"{MUAPI_BASE}/kling-v2.1-standard-i2v",+ f"{MUAPI_BASE}/seedance-2-vip-image-to-video",headers=self.headers,json={"prompt": prompt,- "image_url": image_url,+ "images_list": [image_url],+ "duration": duration,"aspect_ratio": aspect_ratio,+ },+ )+ resp.raise_for_status()+ data = resp.json()++ request_id = data.get("request_id") or data.get("id")+ if not request_id:+ raise ValueError(f"No request_id in Seedance 2 VIP response: {data}")++ result = await self._poll_until_done(request_id, timeout=600)+ return self._extract_url(result)++ async def _kling_master(+ self, prompt: str, image_url: str, duration: int, aspect_ratio: str+ ) -> str:+ async with httpx.AsyncClient(timeout=60) as client:+ resp = await client.post(+ f"{MUAPI_BASE}/kling-v2.1-master-i2v",+ headers=self.headers,+ json={+ "prompt": prompt,+ "image_url": image_url,"duration": duration,+ "aspect_ratio": aspect_ratio,},)resp.raise_for_status()@@ -38,20 +86,21 @@ class MuAPIVideoGenerator:request_id = data.get("request_id") or data.get("id")if not request_id:- raise ValueError(f"No request_id in response: {data}")+ raise ValueError(f"No request_id in Kling Master response: {data}")result = await self._poll_until_done(request_id, timeout=600)+ return self._extract_url(result)++ def _extract_url(self, result: dict) -> str:outputs = result.get("outputs", [])if not outputs:raise ValueError(f"No outputs in result: {result}")-output = outputs[0]if isinstance(output, dict):return output.get("url") or output.get("video_url") or str(output)return str(output)async def _poll_until_done(self, request_id: str, timeout: int = 600) -> dict:- """Poll MuAPI until the video job completes or timeout is reached."""elapsed = 0async with httpx.AsyncClient(timeout=30) as client:while elapsed < timeout:@@ -74,7 +123,6 @@ class MuAPIVideoGenerator:)elif status == "cancelled":raise RuntimeError(f"MuAPI video job {request_id} was cancelled")- # queued / pending / processing — keep pollingraise TimeoutError(f"MuAPI video job {request_id} did not complete within {timeout}s"