Text to Video Skill
Create a video generation task from text. The job is submitted immediately; Polling to obtain task status and video URL.
When to Use
✅ USE this skill when:
- "把这段文字生成视频"
- "帮我把这段文案做成视频"
- "用这段文字生成一个视频"
- User provides a script or paragraph and asks to turn it into video
When NOT to Use
❌ DON'T use this skill when:
- User asks for video editing, trimming, or effects → use video-editing tools
- User asks for screen recording or capture → use recording tools
- User asks only for video status of an existing job → explain where to find files instead
Prerequisites
export MAGIC_API_KEY="your-key"
MAGIC_API_KEY is required by the remote video service client.
Overall Flow (Agent Guidance)
- Extract the full text from the user's message, denoted as
TEXT (i.e., the script to be used for video generation).
- Use the
video-create subcommand to create a task, read the JSON from stdout, and extract the task_id.
- Explicitly inform the user of the
task_id in the chat (optionally include the original JSON output for debugging).
- Use the
video-wait subcommand with the task_id as --task-id, polling until successful.
- 从
video-wait 的 stdout 中提取 video_url.
- Explicitly inform the user of the final
video_url in the chat (you may also include the original output).
Python Client (Step-by-step with Chat Output)
Step 1: Create a video task and print the task_id to the chat
Extract the text the user wants to generate a video from and assign it to TEXT.
- If the text contains double quotes
", properly escape them before constructing the command (for example, by replacing " with \") to avoid shell parsing errors.
Run the following command (executed by the agent/tool; {baseDir} will be replaced with the Skill directory):
python3 {baseDir}/scripts/media_gen_client.py video-create \
--text "TEXT"
- Read the stdout from this command. The expected output will be JSON, for example:
{
"biz_code": 10000,
"msg": "Success",
"data": {
"task_id": "2032443088023777280"
},
"trace_id": "664c6e22-1edd-11f1-bf4c-8262dce7d13f"
}
- Parse the task_id from stdout (e.g., "abc-123"), and inform the user in the chat: "A text-to-video task has been created, task_id: abc-123. I will keep polling for the task status, and send you the video URL once it is ready."
Step 2: Poll the task until success and output video_url in the chat
Use the task_id obtained in the previous step and refer to it as task_id.
Run the following command to poll the task status (check every 10 seconds and wait up to 600 seconds); if it times out, wait a while and retry:
python3 {baseDir}/scripts/media_gen_client.py video-wait --task-id YOUR_TASK_ID --poll 10 --timeout 600
- Read the stdout from this command. When the task succeeds, the script should output information including the video_url, for example:
{
"biz_code": 10000,
"msg": "Success",
"data": {
"task_id": "1234567890",
"task_status": 2,
"video_url": "https://www.magiclight.com/examplevideo.mp4"
},
"trace_id": "c89aeca8-1edd-11f1-bf4c-8262dce7d13f"
}
- Parse the key fields from stdout:
- In the chat, respond to the user as follows:
- Optionally (but recommended for debugging), first display the full JSON output inside a code block.
- Then summarize the key information in natural language, for example:
"Task completed ✅
task_id: abc-123
Video URL: https://example.com/path/to/video.mp4"
- If the stdout indicates that the task failed or timed out (for example, if the status is "failed" or there is no video_url):
- Explain the reason for failure in the chat (include any error message, if available).
- Inform the user that they can retry later, or check their input, quota, etc.
Expected Script Output Contract
- The agent must always:
- Parse the stdout JSON.
- Clearly communicate the task_id and video_url to the user in the chat.
- If necessary, optionally display the raw JSON output in a code block.
1---2name: magic-text2video3description: Create a text-to-video job from user-provided copy. Submits to the remote video service via one API key.4---56# Text to Video Skill78Create a video generation task from text. The job is submitted immediately; Polling to obtain task status and video URL.910## When to Use1112✅ **USE this skill when:**1314- "把这段文字生成视频"15- "帮我把这段文案做成视频"16- "用这段文字生成一个视频"17- User provides a script or paragraph and asks to turn it into video1819## When NOT to Use2021❌ **DON'T use this skill when:**2223- User asks for video editing, trimming, or effects → use video-editing tools24- User asks for screen recording or capture → use recording tools25- User asks only for video status of an existing job → explain where to find files instead2627## Prerequisites2829```bash30export MAGIC_API_KEY="your-key"31```323334`MAGIC_API_KEY` is required by the remote video service client.3536---3738## Overall Flow (Agent Guidance)39401. Extract the **full text** from the user's message, denoted as `TEXT` (i.e., the script to be used for video generation).412. Use the `video-create` subcommand to create a task, read the JSON from stdout, and extract the `task_id`.423. **Explicitly inform the user of the `task_id` in the chat** (optionally include the original JSON output for debugging).434. Use the `video-wait` subcommand with the `task_id` as `--task-id`, polling until successful.445. 从 `video-wait` 的 stdout 中提取 `video_url`.456. **Explicitly inform the user of the final `video_url` in the chat** (you may also include the original output).4647---4849## Python Client (Step-by-step with Chat Output)5051### Step 1: Create a video task and print the task_id to the chat52531. Extract the text the user wants to generate a video from and assign it to `TEXT`.54 - If the text contains double quotes `"`, properly escape them before constructing the command (for example, by replacing `"` with `\"`) to avoid shell parsing errors.55562. Run the following command (executed by the agent/tool; `{baseDir}` will be replaced with the Skill directory):5758```bash59python3 {baseDir}/scripts/media_gen_client.py video-create \60 --text "TEXT"61```62633. Read the stdout from this command. The expected output will be JSON, for example:64```json65 {66 "biz_code": 10000,67 "msg": "Success",68 "data": {69 "task_id": "2032443088023777280"70 },71 "trace_id": "664c6e22-1edd-11f1-bf4c-8262dce7d13f"72 }73```74754. Parse the task_id from stdout (e.g., "abc-123"), and inform the user in the chat: "A text-to-video task has been created, task_id: abc-123. I will keep polling for the task status, and send you the video URL once it is ready."7677### Step 2: Poll the task until success and output `video_url` in the chat78791. Use the task_id obtained in the previous step and refer to it as task_id.80812. Run the following command to poll the task status (check every 10 seconds and wait up to 600 seconds); if it times out, wait a while and retry:82```bash83python3 {baseDir}/scripts/media_gen_client.py video-wait --task-id YOUR_TASK_ID --poll 10 --timeout 60084```85863. Read the stdout from this command. When the task succeeds, the script should output information including the video_url, for example:87```json88 {89 "biz_code": 10000,90 "msg": "Success",91 "data": {92 "task_id": "1234567890",93 "task_status": 2,94 "video_url": "https://www.magiclight.com/examplevideo.mp4"95 },96 "trace_id": "c89aeca8-1edd-11f1-bf4c-8262dce7d13f"97}98```991004. Parse the key fields from stdout:101- status (e.g., 2)102- video_url (e.g., "https://example.com/path/to/video.mp4")1031045. In the chat, respond to the user as follows:105- Optionally (but recommended for debugging), first display the full JSON output inside a code block.106- Then summarize the key information in natural language, for example:107 > "Task completed ✅108 > task_id: abc-123109 > Video URL: https://example.com/path/to/video.mp4"1101116. If the stdout indicates that the task failed or timed out (for example, if the status is "failed" or there is no video_url):112- Explain the reason for failure in the chat (include any error message, if available).113- Inform the user that they can retry later, or check their input, quota, etc.114115## Expected Script Output Contract116- The agent must always:117 - Parse the stdout JSON.118 - Clearly communicate the task_id and video_url to the user in the chat.119 - If necessary, optionally display the raw JSON output in a code block.