ai-director
Original:🇨🇳 Chinese
Translated
6 scripts
Full workflow of AI short drama generation: account management, scriptwriting, video production. Integrated with X2C billing system, suitable for commercial deployment. It includes three core modules: ad-account-manager (account management), ad-writer (scriptwriting prompts), ad-producer (video production).
2installs
Sourcegiggle-official/skills
Added on
NPX Install
npx skill4agent add giggle-official/skills ai-directorTags
Translated version includes tags in frontmatterSKILL.md Content (Chinese)
View Translation Comparison →AI Director - Full Workflow of AI Short Drama Generation
A complete AI short drama generation solution, from idea to finished video, integrated with X2C platform account management and billing.
👥 Multi-user Support
This Skill supports multi-user device sharing, each user has independent X2C account and configuration.
User credential storage path:
credentials/{USER_ID}.jsonYou need to set the or environment variable when calling the script:
USER_IDTELEGRAM_USER_IDbash
USER_ID=5470522468 node scripts/ad-account-manager.js check-bindingOpenClaw will automatically pass the user ID when calling from chat.
🎯 Module Overview
1. Ad Account Manager
- Function: X2C platform account binding, verification
- Script:
scripts/ad-account-manager.js - Independent use: ✅ Can be called separately
2. Ad Writer
- Function: Generate complete short drama scripts from creative ideas
- Type: Prompt engineering (generated after Agent reads the guide)
- Document:
references/AD-WRITER-GUIDE.md - Dependency: ⚠️ X2C account binding required first
3. Ad Producer
- Function: Generate complete video from script
- Script:
scripts/ad-producer.js - Dependency: ⚠️ X2C account binding required first
🚀 Quick Start
Step 1: Get X2C API Key
Users must complete the following steps by themselves:
- Open https://www.x2creel.ai to register/login
- Go to Personal Center → API Management → Create/Copy API Key
- Send the API Key to the assistant
Sample conversation:
User: I want to generate a video
Assistant: Okay, you need to bind your X2C account first. Please open https://www.x2creel.ai to log in, then get the API Key in the personal center and send it to me.
User: x2c_sk_xxx...
Assistant: Verification passed! Your account has been bound, you can start generating videos now~Step 2: Verify API Key (automatically executed by Agent)
After the Agent receives the API Key, it calls to verify validity:
ad-account-manager.js verify-keybash
node scripts/ad-account-manager.js verify-key x2c_sk_xxxAfter successful verification, the key is saved to
credentials/{USER_ID}.jsonStep 3: View configuration and pricing
bash
node scripts/ad-producer.js configStep 4: Generate short drama
Option A - Scriptwriting only (Agent mode):
Agent reads and generates scripts based on user ideas.
references/AD-WRITER-GUIDE.mdOption B - Full workflow (script + video):
bash
node scripts/ad-producer.js full-workflow "A programmer travels back to ancient times to be the prime minister" --duration 120 --wait⚠️ Important Rules
Before the user provides a valid X2C API Key, it is forbidden to perform any video generation or script generation operations!
If the user requests to generate a video but has not bound an account:
- Guide the user to visit https://www.x2creel.ai
- Inform the steps to get the API Key
- Only enter the production process after receiving a valid key
📦 Ad Account Manager
Command List
bash
# Send verification code
node scripts/ad-account-manager.js send-code user@example.com
# Verify and get API Key
node scripts/ad-account-manager.js verify user@example.com 123456
# Check binding status
node scripts/ad-account-manager.js check-binding
# View configuration options
node scripts/ad-account-manager.js config
# Unbind account
node scripts/ad-account-manager.js unbind
# Help
node scripts/ad-account-manager.js helpDirect binding (if you already have an API Key)
bash
node scripts/ad-account-manager.js bind --key "x2c_sk_<REDACTED>xxx"🎭 Ad Character Manager
Manage custom characters that can be used as protagonists in video production. During production, the system will automatically match characters with the characters in the script according to gender.
Note: Each user can have up to 5 characters.
Command List
bash
# Query character list
node scripts/ad-character-manager.js list
# Create character
node scripts/ad-character-manager.js create <name> <gender> <image_url>
# Delete character
node scripts/ad-character-manager.js delete <character_id>
# Help
node scripts/ad-character-manager.js helpParameter Description
| Parameter | Description | Required | Options |
|---|---|---|---|
| name | Character display name | ✅ | - |
| gender | Gender | ✅ | male, female, other |
| image_url | Public URL of character image (max 10MB) | ✅ | - |
Usage Example
bash
# View current characters
node scripts/ad-character-manager.js list
# Create female character
node scripts/ad-character-manager.js create Alice female https://example.com/alice.png
# Create male character
node scripts/ad-character-manager.js create Bob male https://example.com/bob.png
# Delete character
node scripts/ad-character-manager.js delete <uuid>API Interface
| Action | Description |
|---|---|
| character/list | Query character list |
| character/create | Create character |
| character/delete | Delete character |
✍️ Ad Writer
This is a prompt engineering module, the AI Agent generates the script by itself after reading the guide.
Features
- Spielberg style: Warm humanity, visual poetry, emotional resonance
- Three parallel storylines: current storyline, pre-history line, villain/external factor line
- Industrial process: Strictly follow the physical production limits of the short drama market
- **Complete script structure: drama name, synopsis, character biography, outline, episode breakdown, full script
Usage
Agent workflow:
- Read (complete scriptwriting guide)
references/AD-WRITER-GUIDE.md - Generate the script according to the user's idea and the guide
- Output the complete script in six parts
Sample user instruction:
Write me a short drama script: a programmer accidentally saves the CEO, but doesn't know the other person's real identityOutput Content
- Drama name
- One-sentence synopsis
- Character biography
- Story outline
- Episode overview (1-30 episodes)
- Full script (complete lines and shot descriptions)
🎬 Ad Producer
Command List
bash
# View configuration and pricing
node scripts/ad-producer.js config
# Generate script
node scripts/ad-producer.js generate-script "your idea" --wait
# Query script status
node scripts/ad-producer.js script-status <project_id>
# Produce video
node scripts/ad-producer.js produce-video <project_id> 1 --wait
# Query video progress
node scripts/ad-producer.js video-status <project_id> 1
# Full workflow (recommended)
node scripts/ad-producer.js full-workflow "idea description" --duration 120Generation Options
| Parameter | Description | Default Value |
|---|---|---|
| --mode | short_video / short_drama | short_video |
| --duration | 60 / 120 / 180 / 300 | 120 |
| --ratio | 9:16 / 16:9 | 9:16 |
| --style | Style name | - |
| --episodes | Number of episodes (fixed value, cannot be customized by users) | short_video=1, short_drama=10 |
| --language | zh / en | zh |
| --character-ids | Array of character UUIDs (comma separated), used as protagonists | - |
| --wait | Wait for completion | false |
Cost
| Item | Credits | USD |
|---|---|---|
| Script (short_video) | 10 | $0.1 |
| Script (short_drama) | 100 | $1 |
| Video 60s | 299 | $2.99 |
| Video 120s | 599 | $5.99 |
| Video 180s | 799 | $7.99 |
| Video 300s | 999 | $9.99 |
🔄 Complete Workflow
Option A: Step-by-step execution
bash
# 1. Bind account (first use)
node scripts/ad-account-manager.js send-code your@email.com
node scripts/ad-account-manager.js verify your@email.com 123456
# 2. View pricing
node scripts/ad-producer.js config
# 3. Generate script
node scripts/ad-producer.js generate-script "A programmer travels back to ancient times" --wait
# → Get project_id
# 4. Produce video
node scripts/ad-producer.js produce-video <project_id> 1 --waitOption B: One-click automation
bash
node scripts/ad-producer.js full-workflow "A programmer travels back to ancient times to be the prime minister" \
--mode short_video \
--duration 120 \
--ratio 9:16⚙️ Configuration File
config.jsonjson
{
"x2cApiKey": "x2c_sk_<REDACTED>your_api_key_here",
"x2cEmail": "your@email.com",
"x2cUserId": "user-uuid"
}🛡️ Security & Privacy
- API keys are stored locally in
config.json - Automatic desensitization when displayed
- All API calls use HTTPS
🔧 Troubleshooting
Account not bound
❌ X2C Account Not BoundSolution:
bash
node scripts/ad-account-manager.js send-code your@email.com
node scripts/ad-account-manager.js verify your@email.com <code>Insufficient credits
❌ Error: Insufficient creditsSolution:
Visit https://x2creel.ai to recharge
Invalid API Key
❌ Error: Invalid or missing API keySolution:
bash
node scripts/ad-account-manager.js unbind
node scripts/ad-account-manager.js send-code your@email.com📊 X2C Open API
Base URL:
https://eumfmgwxwjyagsvqloac.supabase.co/functions/v1/open-apiInterface List
| Action | Description |
|---|---|
| auth/send-code | Send verification code |
| auth/verify | Verify to get API Key |
| config/get-options | Get configuration options |
| character/list | Query character list |
| character/create | Create character |
| character/delete | Delete character |
| script/generate | Generate script |
| script/query | Query script status |
| video/produce | Produce video |
| video/query | Query video progress |
For detailed API documentation, see
references/X2C-OPEN-API.md📚 Document Reference
- Scriptwriting Guide:
references/AD-WRITER-GUIDE.md - Script Example:
references/example.md - X2C API:
references/X2C-OPEN-API.md
🎓 Best Practices
Cost Optimization
-
Test with short_video first
- 60s video cost is low (299 credits)
- Confirm the style is satisfactory before making long videos
-
Choose the appropriate duration
- 60s: Short promotional video
- 120s: Standard short drama (recommended)
- 180s-300s: Complete plot
Improve Success Rate
-
Clear and specific ideas
- Clear protagonist, background, conflict
- Avoid too abstract descriptions
-
Choose the right style
- Use the command to view available styles
config - 3D ancient style, modern urban, etc.
- Use the
Applicable scenarios: Commercial deployment, paid short drama generation service, B-side creation tools
🔍 Quality Evaluator
Use Gemini 2.0 Flash to analyze video quality and score according to standards.
Evaluation Dimensions
Dimension 1: Single clip quality (100 points)
| Indicator | Weight | Description |
|---|---|---|
| Spatio-temporal consistency | 35% | Subject characteristics remain stable in the shot |
| Dynamic dynamics | 30% | Motion conforms to physical laws, no frame skipping |
| Visual purity | 20% | Clear texture, no AI noise |
| Light and shadow interaction | 15% | Shadows change synchronously with object movement |
Dimension 2: Composite video quality (100 points)
| Indicator | Weight | Description |
|---|---|---|
| Visual flow consistency | 30% | Color tone matching between shots |
| Editing rhythm | 25% | Natural transitions, matching BGM |
| Narrative matching degree | 25% | Accurately convey the script plot |
| Audio and video synchronization rate | 20% | Sound effects fit the vision |
Usage
bash
# Evaluate a single video
node scripts/quality-evaluator.js <video_url> --prompt "original prompt"
# JSON output
node scripts/quality-evaluator.js <video_url> --jsonOutput Example
json
{
"total_score": 75,
"pass": false,
"issues": ["Inconsistent character faces", "Unnatural light and shadow"],
"suggestions": ["Simplify character description", "Clarify light source direction"],
"prompt_improvements": "Improved prompt..."
}🔄 Auto-Iterate
Automatic evaluation + prompt improvement + re-generation until the quality meets the standard.
Rules
- Pass line: 80 points
- Maximum iterations: 5 times
- Each iteration: generate → evaluate → if failed, improve the prompt and try again
Usage
bash
node scripts/auto-iterate.js "your idea" \
--duration 60 \
--style "Ghibli" \
--threshold 80 \
--max-iterations 5Configuration Requirements
config.jsonjson
{
"x2cApiKey": "x2c_sk_<REDACTED>xxx",
"geminiApiKey": "your_gemini_api_key"
}Applicable scenarios: Commercial deployment, paid short drama generation service, B-side creation tools
📋 User Parameter Confirmation Format (Mandatory)
When a user requests to create a video, you must use text to let the user directly reply to the option to confirm the parameters. You must wait for the user to confirm all parameters before starting generation:
📋 Parameter Confirmation
Please reply with your choice:
🎬 Mode: Short drama (10 episodes) or Short video (1 episode)
⏱️ Duration/Price: 60s/299, 120s/599, 180s/799, 300s/999
📐 Ratio: Vertical (9:16) or Horizontal (16:9)
🎨 Style: 3D ancient style / 2D comic drama / Ghibli / Pixar / Realistic / Anime / Chinese ink wash
📂 Category: Fantasy / Suspense / Sci-fi / Urban / Popular / CEO romance / Xianxia
Example: "Short drama, 180s, vertical, 3D ancient style, Xianxia"
**Language**: Chinese / English
## ⚡ Asynchronous Task Processing (Important!)
When a user requests to generate a video, you must use **asynchronous mode**, do not wait for completion!
### Process:
1. **Start the task, do not wait**
```bash
# Start video generation, return project_id
USER_ID=$USER_ID node scripts/ad-producer.js full-workflow "theme" --mode short_video --duration 60 --style "style" --language zh- Add task to tracking list (Mandatory!)
bash
# Immediately call after the video starts generating:
/opt/storyclaw/add-video-task.sh "$USER_ID" "$project_id" "$CHAT_ID"
# Parameters: user_id, project_id, chat_id (Telegram user ID)- Automatic notification after completion
- Cron job checks /tmp/active-video-tasks.json every 2 minutes
- Automatically send a message to notify the user after completion
Key points:
- Do not use --wait parameter, it will block
- Return "Generating, please wait" immediately after starting the task
- Must call add-video-task.sh to add the task to the tracking list
- Create a cron job to monitor progress
- Notify users through the corresponding channel after completion
When a user creates a short drama, the following 5 parameters can only be selected from the configuration options, custom values are not allowed:
- Mode: or
short_videoshort_drama - Duration: /
60/120/180300 - Ratio: or
9:1616:9 - Style: /
3D ancient style/2D comic drama/Ghibli/Pixar/Realistic/AnimeChinese ink wash - Category:
- Chinese: /
Fantasy power/Suspense thriller/Sci-fi apocalypse/Urban revenge/Popular comprehensive/CEO romanceXianxia ancient costume - English: /
Werewolf & Shifter/Suspense & Horror/Power & Revenge/Sweet & CEO/Magic & FantasyAI Drama Lab
- Chinese:
If any item provided by the user is not in the configuration list, you must prompt the user to reselect from the list, and you are not allowed to replace or ignore it yourself.
Episode rule (Mandatory):
- → Fixed 1 episode, do not ask the user
short_video - → Fixed 10 episodes, do not ask the user
short_drama - Users are not allowed to customize the number of episodes, and the episode option is not displayed in the guidance process
🎬 Video Production Process (Mandatory)
Important rule: Only one production can be initiated for the same episode
Only one command can be submitted per episode!
produce-video- ✅ Can query multiple times
video-status - ❌ Cannot submit repeatedly
produce-video
If the task fails, wait for the third-party system to fix it, do not submit repeatedly.
short_video (1 episode)
1. Generate script
2. Video generation → Notify user after completionshort_drama (10 episodes) - Must be produced episode by episode
1. Generate script (10 episodes)
2. Wait for script completion
3. EP1 video generation → Wait for completion
4. EP2 video generation → Wait for completion
5. EP3 video generation → Wait for completion
...
10. EP10 video generation → Wait for completion
11. All completed → Notify userKey points:
- Must wait for the previous episode to complete before starting the next one, cannot be parallel
- Record status after each episode is generated
- Notify the user uniformly after all 10 episodes are completed
Call the API to get the latest configuration list (styles and categories may be updated).
config/get-options⚠️ Agent Output Specification
- Links must be output completely, not truncated (video URLs with signatures are very long, but must be complete)
- Use code blocks ``` to wrap long links to avoid being truncated by chat software
- Key information (Project ID, Video URL) must be clearly displayed
📢 Video Completion Notification Rule
In short drama (10 episodes) mode, you must ask the user whether to continue producing the next episode after the current episode is completed!
When an episode video is generated:
- Display the video link
- Display the credit consumption of this episode
- Ask the user whether to continue producing the next episode
Sample reply:
🎉 Video generation completed!
📊 Credit consumption: 599 credits
Continue to produce the next episode?
- Yes, continue EP3
- Pause for nowNote:
- No need to ask for short_video (1 episode)
- Must ask for short drama mode
- After the user selects "Yes", initiate the production of the next episode
⚠️ Video Failure Handling Rule
After video generation fails, automatic retry generation is prohibited!
Reason: Each generation will deduct user credits, automatic retry will lead to additional deductions.
Handling process:
- Query the failure reason (view status and progress through the command)
video-status - Inform the user of the failure reason
- Wait for the user's instruction to retry or adjust parameters
Sample reply:
❌ Video generation failed
Reason: Character generation failed (character step failed at 14%)
Current balance: 20,013 credits
Please choose:
- Retry generation (corresponding credits will be deducted from the balance)
- Retry after changing style/parameters
- Cancel task🔄 Multi-episode Short Drama Production Rule (short_drama)
Videos must be produced episode by episode, multiple episodes cannot be started at the same time. Process:
- Must pass the parameter when generating the script (e.g.
total_episodes), otherwise only 1 episode will be generated"total_episodes": 10 - Call to start the production of the first episode video
video/produce - Poll the status of the first episode, wait for completion
- After the first episode is completed, call to start the second episode
video/produce - Repeat until all episodes are completed
- Notify the user of the progress after each episode is completed (e.g. "EP3/10 completed")
- Send a total credit report after all are completed
🎬 Video Playback Optimization
The video URL returned by CDN has at the end, which will cause the browser to force download instead of playing.
&response-content-disposition=attachmentRule: After getting the video URL, you must remove the parameter, then it can be played directly in the browser without downloading to the local.
&response-content-disposition=attachmentProcess:
- Get the video URL (from the command)
video-status - Remove
&response-content-disposition=attachment - Directly to the cleaned URL → can be played
browser navigate - Ask the user if they need to download the video (no download by default, only play)
- If the user wants to download/send to Telegram: download + compress to below 16MB (480p, crf 32) before sending
📱 WebChat Message Push
WebChat is the web chat channel of StoryClaw devices, which pushes messages through the script.
webchat-stream-ws.shScript Location
/opt/storyclaw/webchat-stream-ws.shUsage
bash
# Send new message (INSERT mode)
webchat-stream-ws.sh <user_id> --file <message_file> <agent_id>
# Update existing message (UPDATE mode)
webchat-stream-ws.sh <user_id> --update <message_id> --file <message_file> <agent_id>Parameter Description
| Parameter | Description |
|---|---|
| user_id | WebChat user ID (32-bit hex) |
| message_id | Existing message ID, used for update |
| message_file | File path containing message content (must be passed with --file to avoid loss of $ symbol) |
| agent_id | Target agent ID (e.g. |
Example
bash
# 1. Send confirmation message and get message_id
echo "Generating video..." > /tmp/msg.txt
MSG_ID=$(webchat-stream-ws.sh "180d08e23cdac976b4" --file /tmp/msg.txt "director")
echo "Message ID: $MSG_ID"
# 2. Update message after task completion
echo "✅ Video generation completed!" > /tmp/result.txt
webchat-stream-ws.sh "180d08e23cdac976b4" --update "$MSG_ID" --file /tmp/result.txt "director"Notes
- Must use --file mode — passing text directly will cause loss of symbol
$ - message_id is used for in-place update — avoid generating multiple messages
- Cooperate with asynchronous tasks — for long tasks such as video generation, send a "processing" message first, then update after the task is completed
Video Task Progress Push
When using to add a task, the chat_id format determines the notification channel:
add-video-task.shbash
# WebChat push (chat_id format: webchat:<user_id>:<agent_id>)
add-video-task.sh "180d08e23cdac976b4" "project-id" "webchat:180d08e23cdac976b4:director"
# Telegram push (chat_id is pure number)
add-video-task.sh "5470522468" "project-id" "5470522468"check-video-tasks.shVersion: 2.1.2 (X2C Open API + WebChat push support)