README.md
July 18, 2026 Β· View on GitHub
MicroDrama AI
Agentic AI Micro-Drama Video Generator
π¨ The problem with AI video today:
- β Manual, fragmented workflow β Separate tools needed for scripting, image gen, and video gen
- β No narrative structure β Raw T2V models don't understand story arcs or scene continuity
- β Character inconsistency β Characters look different in every shot
- β Visual-only β Missing scripts, narrative depth, and cinematic storytelling
π‘ MicroDrama AI Solution:
π¬ Screenwriter, Storyboard Artist, Frame Generator, and Video Producer β all in one automated pipeline.
Type an idea. MicroDrama AI autonomously handles everything: story development, character design, shot-by-shot storyboarding, frame generation, and video clip production β then stitches it all into a complete cinematic micro-drama. Powered entirely by a single MuAPI key.
Related Projects
- AI-Youtube-Shorts-Generator β Auto-clip and crop your AI dramas into viral YouTube Shorts
- Clip-Anything β Clip any moment from your AI drama with text prompts
- AI-Faceless-Video-Generator β Generate faceless AI videos for your drama channel
- awesome-ai-video-models β compare AI video models by API, price & speed
π₯ Demo Video
https://github.com/user-attachments/assets/f8b5d09c-8c58-40c1-b171-e3f42b0d71a8
Watch MicroDrama AI transform ideas into fully cinematic micro-drama videos using autonomous AI agents, character-consistent image generation, storyboarding, and MuAPI-powered video creation.
π Table of Contents
- π‘ Key Features
- ποΈ Architecture
- π Pipeline Stages
- π Quick Start
- π οΈ Project Structure
- π API Reference
- βοΈ Configuration
- π₯οΈ UI Overview
π‘ Key Features
π Idea to VideoFrom Spark to Screen Transform a raw idea into a complete micro-drama. The AI develops the story, writes scene scripts, designs the storyboard, and generates the full video β zero manual steps. |
π Script to VideoBring Your Script to Life Already have a scene script? Skip the writing phase and let MicroDrama AI handle storyboarding, character portraits, frame generation, and video production. |
π¨ Character ConsistencyCoherent Visual Identity Characters are extracted with detailed static and dynamic features. Reference portraits are generated and used to keep characters visually consistent across every shot. |
π‘ Real-time ProgressLive Pipeline Visibility Watch every stage of the pipeline in real time via SSE streaming β from story development through to the final concatenated video, with a live animated stage timeline. |
ποΈ Architecture
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β MicroDrama AI Server β
Idea / Script ββΊ β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Screenwriter Agent β β
β β develop_story() β write_script_based_on_story() β β
β ββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββ β
β β story + scene scripts β
β ββββββββββββββββββββββββββββΌββββββββββββββββββββββββββ β
β β Character Extractor Agent β β
β β extract_characters(script) β List[char] β β
β ββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββ β
β β characters[] β
β ββββββββββββββββββββββββββββΌββββββββββββββββββββββββββ β
β β Storyboard Artist Agent β β
β β design_storyboard() β List[ShotBriefDescription] β β
β ββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββ β
β β shots[] β
β ββββββββββββββββββββββββββββΌββββββββββββββββββββββββββ β
β β MuAPI Tools β β
β β β Portrait Gen β flux-dev-image (T2I) β β
β β β‘ Frame Gen β flux-kontext-dev-i2i (I2I) β β
β β β’ Video Gen β kling-v2.1-standard-i2v (I2V) β β
β ββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββ β
β β video clips β
β ββββββββββββββββββββββββββββΌββββββββββββββββββββββββββ β
β β moviepy Concat β β
β ββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββ-βΌββββββββββββββββββββββββββ--β
β
final_video.mp4
All LLM calls (story, characters, storyboard) go through MuAPI's /claude-sonnet-4-6 endpoint.
Only one API key is required for the entire pipeline.
π Pipeline Stages
Idea to Video β Full Pipeline
| # | Stage | Agent / Tool | Output |
|---|---|---|---|
| 1 | Story Development | Screenwriter (MuAPI LLM) | Story outline in prose |
| 2 | Character Extraction | CharacterExtractor (MuAPI LLM) | Characters with static + dynamic visual features |
| 3 | Scene Scripting | Screenwriter (MuAPI LLM) | 2β4 individual scene scripts |
| 4 | Character Portraits | MuAPI flux-dev-image (T2I) | Reference portrait per character β runs in parallel |
| 5 | Storyboard Design | StoryboardArtist (MuAPI LLM) | 3β5 shots per scene: visual + motion + audio desc |
| 6 | Frame Generation | MuAPI flux-kontext-dev-i2i (I2I) | First frame per shot using character reference images |
| 7 | Video Generation | MuAPI kling-v2.1-standard-i2v (I2V) | 5-second video clip per shot β runs in parallel |
| 8 | Concatenation | moviepy | All clips joined into final_video.mp4 |
Script to Video β Short Pipeline
Skips stages 1β3. Starts directly from your provided script.
| # | Stage | Agent / Tool | Output |
|---|---|---|---|
| 1 | Character Extraction | CharacterExtractor (MuAPI LLM) | Characters with visual descriptions |
| 2 | Character Portraits | MuAPI flux-dev-image (T2I) | Reference portrait per character |
| 3 | Storyboard Design | StoryboardArtist (MuAPI LLM) | Shots from your script |
| 4 | Frame Generation | MuAPI flux-kontext-dev-i2i (I2I) | First frame per shot |
| 5 | Video Generation | MuAPI kling-v2.1-standard-i2v (I2V) | 5-second video per shot |
| 6 | Concatenation | moviepy | Final scene video |
π Quick Start
Prerequisites
- Python 3.10+
- Node.js 18+
- A MuAPI API key
1. Clone the repo
git clone https://github.com/Anil-matcha/Open-AI-Micro-Drama-Generator.git
cd Open-AI-Micro-Drama-Generator
2. Set up the server
cd server
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env
# Open .env and set MUAPI_KEY=your_key_here
3. Start the server
uvicorn api:app --reload --port 8000
API available at http://localhost:8000. Health check: GET /api/health.
4. Set up and start the client
cd client
npm install
npm run dev
Open http://localhost:3000.
5. Generate your first micro-drama
- Enter an idea β e.g. "A detective chases a shadow through a neon-lit cyberpunk city"
- Optionally add requirements β e.g. "Keep it under 3 scenes, suitable for all ages"
- Pick a visual style: Cinematic, Realistic, Anime, Fantasy, or Documentary
- Click Generate Video and watch the pipeline run in real time
- Download your finished micro-drama when it completes
π οΈ Project Structure
Open-AI-Micro-Drama-Generator/
β
βββ server/ # FastAPI backend
β βββ api.py # App entry point, endpoints, SSE job runner
β βββ requirements.txt
β βββ .env.example
β β
β βββ agents/ # LLM-powered AI agents (all via MuAPI)
β β βββ screenwriter.py # develop_story() + write_script_based_on_story()
β β βββ character_extractor.py # extract_characters() β List[CharacterInScene]
β β βββ storyboard_artist.py # design_storyboard() β List[ShotBriefDescription]
β β
β βββ interfaces/ # Pydantic data models
β β βββ character.py # CharacterInScene (idx, name, static/dynamic features)
β β βββ shot.py # ShotBriefDescription, ShotDescription
β β
β βββ tools/ # MuAPI integration layer
β β βββ muapi_llm.py # MuAPILLM β submit + poll LLM completions
β β βββ muapi_image_generator.py # T2I (flux-dev) + I2I (flux-kontext) image gen
β β βββ muapi_video_generator.py # I2V (kling-v2.1) video gen with polling
β β βββ muapi_uploader.py # Upload local images to MuAPI for URL references
β β
β βββ pipelines/ # Orchestration logic
β β βββ idea2video.py # Full end-to-end pipeline
β β βββ script2video.py # Scene-level pipeline (portraits β storyboard β video)
β β
β βββ utils/
β βββ video.py # moviepy concatenation helper
β
βββ client/ # Next.js 14 frontend
βββ next.config.js # Rewrites /api/* and /outputs/* β FastAPI server
βββ package.json
βββ tailwind.config.js
β
βββ app/
β βββ layout.js # Root layout + metadata
β βββ globals.css # Global styles + gradient utilities
β βββ page.js # Landing page: hero + generation form
β βββ generate/[jobId]/
β βββ page.js # SSE consumer: pipeline progress + result viewer
β
βββ components/
βββ IdeaForm.js # Idea/script input, style picker, mode toggle
βββ PipelineProgress.js # Animated 7-stage timeline + live scrolling log
βββ VideoResult.js # Video player with download + open controls
π API Reference
POST /api/generate β Start a generation job
Request body:
{
"idea": "A lone astronaut discovers alien ruins on Europa",
"user_requirement": "Keep it under 3 scenes, suitable for all ages",
"style": "Cinematic",
"mode": "idea2video"
}
| Field | Type | Default | Description |
|---|---|---|---|
idea | string | required | The creative idea or concept |
user_requirement | string | "" | Optional constraints (audience, length, tone) |
style | string | "Cinematic" | Visual style: Cinematic, Realistic, Anime, Fantasy, Documentary |
mode | string | "idea2video" | "idea2video" or "script2video" |
script | string | "" | Scene script (only used when mode = "script2video") |
Response:
{ "job_id": "550e8400-e29b-41d4-a716-446655440000" }
GET /api/status/{job_id} β Stream progress (SSE)
GET /api/status/550e8400-...
Accept: text/event-stream
SSE event stream. Reconnect-safe β replays all past events on reconnect.
Progress event:
{"type": "progress", "stage": "screenwriter", "message": "Developing story...", "progress": 10}
Completion event:
{"type": "complete", "video_url": "/outputs/job_id/final_video.mp4", "progress": 100}
Error event:
{"type": "error", "message": "MuAPI image job failed: quota exceeded", "progress": -1}
Pipeline stages in order: screenwriter β characters β storyboard β portraits β frames β video β concat
GET /api/result/{job_id} β Get job result
{
"job_id": "550e8400-...",
"status": "completed",
"video_url": "/outputs/550e8400-.../final_video.mp4",
"error": null
}
Status values: running | completed | failed
GET /api/health β Health check
{ "status": "ok", "service": "microdrama-api" }
βοΈ Configuration
Environment variables
| Variable | Required | Description |
|---|---|---|
MUAPI_KEY | β | MuAPI API key β used for LLM, image, and video generation |
One key. That's it.
MuAPI endpoints used internally
| Purpose | Endpoint | Model |
|---|---|---|
| LLM completions | POST /claude-sonnet-4-6 | claude-sonnet-4-6 |
| Character portraits (T2I) | POST /flux-dev-image | FLUX.1-dev |
| Shot frames (I2I + character ref) | POST /flux-kontext-dev-i2i | FLUX.1-Kontext-dev |
| Video clips (I2V) | POST /kling-v2.1-standard-i2v | Kling v2.1 Standard |
| File upload | POST /upload_file | β |
| Job polling | GET /predictions/{id}/result | β |
All jobs follow the same async pattern: submit β get request_id β poll every 3 s β return on "completed".
π₯οΈ UI Overview
Landing page (/)
- Dark cinematic design with animated radial glow background
- Feature pills: Screenwriter Agent Β· Storyboard Artist Β· Frame Generator Β· Video Generator
- Idea textarea, optional requirements field
- Style picker: Cinematic Β· Realistic Β· Anime Β· Fantasy Β· Documentary
- Mode toggle: Idea to Video / Script to Video
Generation page (/generate/[jobId])
- 7-stage animated pipeline timeline with live status indicators
- Progress bar with percentage
- Scrolling live log showing every message emitted by the pipeline
- Video player with autoplay once
completeevent is received - Download button saves
microdrama-{jobId}.mp4 - SSE auto-reconnects if the connection drops mid-generation
π License
MIT β see LICENSE for details.