Generate video with vidu via bundled scripts. Use when the user wants 文生视频, 图生视频, 首尾帧生视频, 参考生视频, 创建主体 (material element), or to submit or check vidu tasks. 创建主体: upload 1–3 images, name and description, call material/elements API. Execution is script-based; run scripts in scripts/ with VIDU_TOKEN set.
Generate video with vidu via bundled scripts. Use when the user wants 文生视频, 图生视频, 首尾帧生视频, 参考生视频, 创建主体 (material element), or to submit or check vidu tasks. 创建主体: upload 1–3 images, name and description, call material/elements API. Execution is script-based; run scripts in scripts/ with VIDU_TOKEN set.
Vidu Video Generation Skill
Execution model: use scripts
All execution for this skill is done by running the bundled scripts in scripts/. Do not implement the API calls yourself; run the appropriate script and use its output.
Submit task: Run scripts/run_vidu_generation.py with the user’s prompt and optional image path(s). It handles upload (if needed) → submit → returns task_id. No wait mode; use task_id to query status/result when needed.
Query task status/result: Use scripts/get_task_result.py <task_id> (or GET /vidu/v1/tasks/{task_id}) to get current state and, when success, video URL(s).
Task state SSE (流式): GET https://service.vidu.cn/vidu/v1/tasks/state?id={task_id} is an SSE stream. When using this endpoint, return the SSE output directly to the model — do not wait for a terminal state. Each event includes state, estimated_time_left, err_code, and queue_wait_time (排队预测时间, unit: minutes).
主体预处理 (script): Run scripts/pre_process_element.py with --name and 1–3 --image-uri (ssupload:?id=...); calls POST material/elements/pre-process only, outputs full response including recaption (style, description). Use when you need recaption alone or as a step before create_element.
创建主体 (script): Run scripts/create_element.py with --name, 1–3 --image paths, and optional --description/--style; uploads images → runs pre_process_element.py (required every time) → POSTs to material/elements (uses pre-process recaption when --description is omitted), outputs element id and version.
Step-by-step: If you need to run individual steps, use scripts/upload_image.py, scripts/pre_process_element.py, scripts/create_element.py, scripts/list_elements.py, scripts/submit_task.py, scripts/get_task_result.py, and scripts/get_upload_url.py as needed. See scripts/README.md for usage and examples.
Ensure the environment has VIDU_TOKEN set. VIDU_BASE_URL configures the service domain: 中国大陆 使用 https://service.vidu.cn(默认),海外/非中国地区 使用 https://service.vidu.com。Scripts require Python 3 and requests; see scripts/README.md for details.
Overview
Vidu video generation is asynchronous: submit a task → get task_id → use task_id to query task status/result (e.g. get_task_result.py or GET API) when needed. The scripts do not wait; they return task_id after submit.
Before choosing script arguments, ensure the user’s request matches one of the supported task types and constraints below. references/parameters.md has the same list for quick lookup.
前置条件: 每张图片先按「Upload images」三步(CreateUpload → PUT to put_url → FinishUpload)得到 ssupload:?id={id};共 1–3 张图。同一张图可复用同一 id 填 content 与 src_img,或按 API 要求使用不同 id。
scripts/ — Use these for all execution. See scripts/README.md for dependency (Python 3, requests), environment (VIDU_TOKEN, VIDU_BASE_URL), and example commands for each script.
references/api_reference.md — Full API contracts (for understanding or when debugging).
references/parameters.md — 任务支持列表与参数约束 (supported task list and parameter constraints).
references/errors_and_retry.md — Error handling (read when interpreting failures).
Workflow (script-based)
Get token and domain: Ensure VIDU_TOKEN is set. Set VIDU_BASE_URL by region: mainland China → https://service.vidu.cn (default); outside China → https://service.vidu.com.
Script exits 0 and prints task_id. Caller uses this task_id to query status/result later (e.g. get_task_result.py <task_id> or GET /vidu/v1/tasks/{task_id}).
Script exits non-zero or prints error JSON to stderr: report failure to the user and, if present, err_code / err_msg.
If you cannot use run_vidu_generation.py (e.g. custom body or step-by-step control), run the steps manually in order:
Upload images: python scripts/upload_image.py <image_path> for each image; capture the output ssupload:?id=.... The same upload flow is used for img2video/headtailimg2video/character2video and for 创建主体 (1–3 images).
Get upload resource URL (optional): To obtain a public download URL for an uploaded file, run python scripts/get_upload_url.py <ssupload_uri_or_id>. The returned URL is valid for 1 hour only; after expiry, run the script again to get a new URL.
Query status/result: python scripts/get_task_result.py <task_id>. Call when needed; response includes state and, when success, nomark_uri line(s).
Output to the user
After submit: Return the task_id to the user; mention that video generation is in progress and they can query status/result later with that task_id (e.g. get_task_result.py or GET /vidu/v1/tasks/{task_id}).
After query (get_task_result.py): If state is success, return the nomark_uri link(s) to the user; if failed, report err_code / err_msg.
Failure (submit or script error): Clearly state that the task failed and, if available, the reason (err_code / err_msg from script or references).
Fallback (no Python)
If the environment cannot run Python scripts, you cannot execute this skill as intended. Tell the user that this skill requires script execution (Python 3, requests, VIDU_TOKEN) and point them to scripts/README.md and references/api_reference.md for manual API usage elsewhere.