Token导航 LogoToken导航

Agent Skill · AI 工具

video-generation(视频生成)

用于辅助视频生成、动画合成、脚本化剪辑或 Remotion 等视频项目开发。它适合让 Agent 组织镜头、生成素材说明、维护合成代码或排查渲染问题。使用时需要确认分辨率、时长、素材路径和导出格式;涉及外部素材、人物肖像或商业发布时,应先核对版权授权和内容审核要求。

video-generation 是AI 工具类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为执行命令;许可证为 MIT,第三方扫描有提醒项,按安装量在AI 工具类的 2,536 个 Skill 里排第 108。

总安装 21,661周安装 820GitHub Stars 26下载 9,911核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
MIT

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:video-generation(视频生成)
来源仓库:https://github.com/answerzhao/agent-skills
仓库路径:skills/video-generation
安装命令:
npx skills add https://github.com/answerzhao/agent-skills --skill 'Video Generation'
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/answerzhao/agent-skills --skill 'Video Generation'

这个 Skill 是做什么的

AI 工具类 Skill 用来扩展助手本身的能力,例如接模型、接检索、接外部服务。

用于辅助视频生成、动画合成、脚本化剪辑或 Remotion 等视频项目开发。适合让 Agent 组织镜头、生成素材说明、维护合成代码或排查渲染问题。使用时需要确认分辨率、时长、素材路径和导出格式,涉及外部素材或商业发布时应核对版权授权。安装前建议确认权限范围和维护状态,以及是否会触发联网、命令执行或文件读写。

可通过 GitHub 仓库获取具体用法,建议结合原始 README 和示例脚本进一步验证功能。

来源仓库内路径:skills/video-generation

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/answerzhao/agent-skills --skill 'Video Generat…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要执行命令,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

video-generation 怎么安装?

在终端执行 npx skills add https://github.com/answerzhao/agent-skills --skill 'Video Generation'。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

video-generation 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

video-generation 需要什么权限?

权限级别是执行命令。安装流程涉及命令执行,可能通过 npx skills add https://github.com/answerzhao/agent-skills --skill 'Video Generation';npx skills add answerzhao/agent-skills --skill "video-generation" 联网下载 Skill 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

video-generation 是免费的吗?

来源标注的许可证是 MIT。本站不代收任何费用,也不托管安装包;能否商用、要不要署名,以许可证原文为准。

video-generation 用的人多吗?

公开数据是累计安装 21,661 次,近一周安装 820 次,下载 9,911 次,GitHub 26 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

video-generation 安全吗?

第三方扫描有提醒项,说明存在需要人工确认的行为。安装前请打开源码看清它读了什么、联网到哪里。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 3 个目录同时收录,说明这个 Skill 流传比较广。
  • 许可证明确为 MIT,商用和分发边界好判断。

先想清楚的地方

  • 需要执行命令,装到常用环境前要先评估影响面。
  • 第三方扫描存在提醒项或未通过项,需要人工逐条确认。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理AI 工具类任务、又不想每次都手写提示词的人。

不太适合

  • 不能接受 Skill 在你机器上执行命令的人。
  • 需要厂商级技术支持和 SLA 的生产系统。

AI 工具类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
executing-plans

执行计划 · Codex、Claude

1,515,336173,110只读MIT通过
verification-before-completion

完成前的验证 · Codex、Claude

1,319,472173,121权限未标注MIT通过
subagent-driven-development

子 Agent 驱动开发 · Codex、Claude

1,312,416173,138只读MIT通过
copy-editing

复制编辑 · Codex、Claude

1,209,57625,632只读MIT通过
paywall-upgrade-cro

付费专区升级 cro · Codex、Claude

1,030,17625,617只读MIT通过
video-generation

视频生成 · 本页

21,66126执行命令MIT有提醒

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Video Generation Skill

This skill guides the implementation of video generation functionality using the z-ai-web-dev-sdk package, enabling AI models to create videos from text descriptions or images through asynchronous task processing.

Skills Path

Skill Location: {project_path}/skills/video-generation

This skill is located at the above path in your project.

Reference Scripts: Example test scripts are available in the {Skill Location}/scripts/ directory for quick testing and reference. See {Skill Location}/scripts/video.ts for a working example.

Overview

Video Generation allows you to build applications that can create video content from text prompts or images, with customizable parameters like resolution, frame rate, duration, and quality settings. The API uses an asynchronous task model where you create a task and poll for results.

IMPORTANT: z-ai-web-dev-sdk MUST be used in backend code only. Never use it in client-side code.

Prerequisites

The z-ai-web-dev-sdk package is already installed. Import it as shown in the examples below.

CLI Usage (For Simple Tasks)

For simple video generation tasks, you can use the z-ai CLI instead of writing code. The CLI handles task creation and polling automatically, making it ideal for quick tests and simple automation.

Basic Text-to-Video

# Generate video with automatic polling
z-ai video --prompt "A cat playing with a ball" --poll

# Using short options
z-ai video -p "Beautiful landscape with mountains" --poll

Custom Quality and Settings

# Quality mode (speed or quality)
z-ai video -p "Ocean waves at sunset" --quality quality --poll

# Custom resolution and FPS
z-ai video \
  -p "City timelapse" \
  --size "1920x1080" \
  --fps 60 \
  --poll

# Custom duration (5 or 10 seconds)
z-ai video -p "Fireworks display" --duration 10 --poll

Image-to-Video

# Generate video from single image
z-ai video \
  --image-url "https://example.com/image.png" \
  --prompt "Make the scene come alive" \
  --poll

# Using short option
z-ai video \
  -i "https://example.com/photo.jpg" \
  -p "Add motion to this scene" \
  --poll

First-Last Frame Mode

# Generate video between two frames
z-ai video \
  --image-url "https://example.com/start.png,https://example.com/end.png" \
  --prompt "Smooth transition between frames" \
  --poll

With Audio Generation

# Generate video with AI-generated audio effects
z-ai video \
  -p "Thunder storm approaching" \
  --with-audio \
  --poll

Save Output

# Save task result to JSON file
z-ai video \
  -p "Sunrise over mountains" \
  --poll \
  -o video_result.json

Custom Polling Parameters

# Customize polling behavior
z-ai video \
  -p "Dancing robot" \
  --poll \
  --poll-interval 10 \
  --max-polls 30

# Create task without polling (get task ID)
z-ai video -p "Abstract art animation" -o task.json

CLI Parameters

  • --prompt, -p <text>: Optional - Text description of the video
  • --image-url, -i <URL>: Optional - Image URL (single or comma-separated pair)
  • --quality, -q <mode>: Optional - Output mode: speed or quality (default: speed)
  • --with-audio: Optional - Generate AI audio effects (default: false)
  • --size, -s <resolution>: Optional - Video resolution (e.g., "1920x1080")
  • --fps <rate>: Optional - Frame rate: 30 or 60 (default: 30)
  • --duration, -d <seconds>: Optional - Duration: 5 or 10 seconds (default: 5)
  • --model, -m <model>: Optional - Model name to use
  • --poll: Optional - Auto-poll until task completes
  • --poll-interval <seconds>: Optional - Polling interval (default: 5)
  • --max-polls <count>: Optional - Maximum poll attempts (default: 60)
  • --output, -o <path>: Optional - Output file path (JSON format)

Supported Resolutions

  • 1024x1024
  • 768x1344
  • 864x1152
  • 1344x768
  • 1152x864
  • 1440x720
  • 720x1440
  • 1920x1080 (and other standard resolutions)

Checking Task Status Later

If you create a task without --poll, you can check its status later:

# Get the task ID from the initial response
z-ai async-result --id "task-id-here" --poll

When to Use CLI vs SDK

Use CLI for:

  • Quick video generation tests
  • Simple one-off video creation
  • Command-line automation scripts
  • Testing different prompts and settings

Use SDK for:

  • Batch video generation with custom logic
  • Integration with web applications
  • Custom task queue management
  • Production applications with complex workflows

Video Generation Workflow

Video generation follows a two-step asynchronous pattern:

  1. Create Task: Submit video generation request and receive a task ID
  2. Poll Results: Query the task status until completion and retrieve the video URL

Basic Video Generation Implementation

Simple Text-to-Video Generation

import ZAI from 'z-ai-web-dev-sdk';

async function generateVideo(prompt) {
  try {
    const zai = await ZAI.create();

    // Create video generation task
    const task = await zai.video.generations.create({
      prompt: prompt,
      quality: 'speed', // 'speed' or 'quality'
      with_audio: false,
      size: '1920x1080',
      fps: 30,
      duration: 5
    });

    console.log('Task ID:', task.id);
    console.log('Task Status:', task.task_status);

    // Poll for results
    let result = await zai.async.result.query(task.id);
    let pollCount = 0;
    const maxPolls = 60;
    const pollInterval = 5000; // 5 seconds

    while (result.task_status === 'PROCESSING' && pollCount < maxPolls) {
      pollCount++;
      console.log(`Polling ${pollCount}/${maxPolls}: Status is ${result.task_status}`);
      await new Promise(resolve => setTimeout(resolve, pollInterval));
      result = await zai.async.result.query(task.id);
    }

    if (result.task_status === 'SUCCESS') {
      // Get video URL from multiple possible fields
      const videoUrl = result.video_result?.[0]?.url ||
                      result.video_url ||
                      result.url ||
                      result.video;
      console.log('Video URL:', videoUrl);
      return videoUrl;
    } else {
      console.log('Task failed or still processing');
      return null;
    }
  } catch (error) {
    console.error('Video generation failed:', error.message);
    throw error;
  }
}

// Usage
const videoUrl = await generateVideo('A cat is playing with a ball.');
console.log('Generated video:', videoUrl);

Image-to-Video Generation

import ZAI from 'z-ai-web-dev-sdk';

async function generateVideoFromImage(imageUrl, prompt) {
  const zai = await ZAI.create();

  // Single image as starting frame
  const task = await zai.video.generations.create({
    image_url: imageUrl,
    prompt: prompt,
    quality: 'quality',
    duration: 5,
    fps: 30
  });

  return task;
}

// Usage
const task = await generateVideoFromImage(
  'https://example.com/image.jpg',
  'Animate this scene with gentle motion'
);

Image-to-Video with Start and End Frames

import ZAI from 'z-ai-web-dev-sdk';

async function generateVideoWithKeyframes(startImageUrl, endImageUrl, prompt) {
  const zai = await ZAI.create();

  // Two images for start and end frames
  const task = await zai.video.generations.create({
    image_url: [startImageUrl, endImageUrl],
    prompt: prompt,
    quality: 'quality',
    duration: 10,
    fps: 30
  });

  console.log('Task created with keyframes:', task.id);
  return task;
}

// Usage
const task = await generateVideoWithKeyframes(
  'https://example.com/start.jpg',
  'https://example.com/end.jpg',
  'Smooth transition between these scenes'
);

Asynchronous Result Management

Query Task Status

import ZAI from 'z-ai-web-dev-sdk';

async function checkTaskStatus(taskId) {
  try {
    const zai = await ZAI.create();
    const result = await zai.async.result.query(taskId);

    console.log('Task Status:', result.task_status);

    if (result.task_status === 'SUCCESS') {
      // Extract video URL from result
      const videoUrl = result.video_result?.[0]?.url ||
                      result.video_url ||
                      result.url ||
                      result.video;
      if (videoUrl) {
        console.log('Video URL:', videoUrl);
        return { success: true, url: videoUrl };
      }
    } else if (result.task_status === 'PROCESSING') {
      console.log('Task is still processing');
      return { success: false, status: 'processing' };
    } else if (result.task_status === 'FAIL') {
      console.log('Task failed');
      return { success: false, status: 'failed' };
    }
  } catch (error) {
    console.error('Query failed:', error.message);
    throw error;
  }
}

// Usage
const status = await checkTaskStatus('your-task-id-here');

Polling with Exponential Backoff

import ZAI from 'z-ai-web-dev-sdk';

async function pollWithBackoff(taskId) {
  const zai = await ZAI.create();

  let pollInterval = 5000; // Start with 5 seconds
  const maxInterval = 30000; // Max 30 seconds
  const maxPolls = 40;
  let pollCount = 0;

  while (pollCount < maxPolls) {
    const result = await zai.async.result.query(taskId);
    pollCount++;

    if (result.task_status === 'SUCCESS') {
      const videoUrl = result.video_result?.[0]?.url ||
                      result.video_url ||
                      result.url ||
                      result.video;
      return { success: true, url: videoUrl };
    }

    if (result.task_status === 'FAIL') {
      return { success: false, error: 'Task failed' };
    }

    // Exponential backoff
    console.log(`Poll ${pollCount}: Waiting ${pollInterval / 1000}s...`);
    await new Promise(resolve => setTimeout(resolve, pollInterval));
    pollInterval = Math.min(pollInterval * 1.5, maxInterval);
  }

  return { success: false, error: 'Timeout' };
}

Advanced Use Cases

Video Generation Queue Manager

import ZAI from 'z-ai-web-dev-sdk';

class VideoGenerationQueue {
  constructor() {
    this.tasks = new Map();
  }

  async initialize() {
    this.zai = await ZAI.create();
  }

  async createVideo(params) {
    const task = await this.zai.video.generations.create(params);

    this.tasks.set(task.id, {
      taskId: task.id,
      status: task.task_status,
      params: params,
      createdAt: new Date()
    });

    return task.id;
  }

  async checkTask(taskId) {
    const result = await this.zai.async.result.query(taskId);

    const taskInfo = this.tasks.get(taskId);
    if (taskInfo) {
      taskInfo.status = result.task_status;
      taskInfo.lastChecked = new Date();

      if (result.task_status === 'SUCCESS') {
        taskInfo.videoUrl = result.video_result?.[0]?.url ||
                          result.video_url ||
                          result.url ||
                          result.video;
      }
    }

    return result;
  }

  async pollTask(taskId, options = {}) {
    const maxPolls = options.maxPolls || 60;
    const pollInterval = options.pollInterval || 5000;

    let pollCount = 0;

    while (pollCount < maxPolls) {
      const result = await this.checkTask(taskId);

      if (result.task_status === 'SUCCESS' || result.task_status === 'FAIL') {
        return result;
      }

      pollCount++;
      await new Promise(resolve => setTimeout(resolve, pollInterval));
    }

    throw new Error('Task polling timeout');
  }

  getTask(taskId) {
    return this.tasks.get(taskId);
  }

  getAllTasks() {
    return Array.from(this.tasks.values());
  }
}

// Usage
const queue = new VideoGenerationQueue();
await queue.initialize();

const taskId = await queue.createVideo({
  prompt: 'A sunset over the ocean',
  quality: 'quality',
  duration: 5
});

const result = await queue.pollTask(taskId);
console.log('Video ready:', result.video_result?.[0]?.url);

Batch Video Generation

import ZAI from 'z-ai-web-dev-sdk';

async function generateMultipleVideos(prompts) {
  const zai = await ZAI.create();
  const tasks = [];

  // Create all tasks
  for (const prompt of prompts) {
    const task = await zai.video.generations.create({
      prompt: prompt,
      quality: 'speed',
      duration: 5
    });
    tasks.push({ taskId: task.id, prompt: prompt });
  }

  console.log(`Created ${tasks.length} video generation tasks`);

  // Poll all tasks
  const results = [];
  for (const task of tasks) {
    const result = await pollTaskUntilComplete(zai, task.taskId);
    results.push({
      prompt: task.prompt,
      taskId: task.taskId,
      ...result
    });
  }

  return results;
}

async function pollTaskUntilComplete(zai, taskId) {
  let pollCount = 0;
  const maxPolls = 60;

  while (pollCount < maxPolls) {
    const result = await zai.async.result.query(taskId);

    if (result.task_status === 'SUCCESS') {
      return {
        success: true,
        url: result.video_result?.[0]?.url ||
             result.video_url ||
             result.url ||
             result.video
      };
    }

    if (result.task_status === 'FAIL') {
      return { success: false, error: 'Generation failed' };
    }

    pollCount++;
    await new Promise(resolve => setTimeout(resolve, 5000));
  }

  return { success: false, error: 'Timeout' };
}

// Usage
const prompts = [
  'A cat playing with yarn',
  'A dog running in a park',
  'A bird flying in the sky'
];

const videos = await generateMultipleVideos(prompts);
videos.forEach(video => {
  console.log(`${video.prompt}: ${video.success ? video.url : video.error}`);
});

Configuration Parameters

Video Generation Parameters

ParameterTypeRequiredDescriptionDefault
promptstringOptional*Text description of the video-
image_urlstring \string[]Optional*Image URL(s) for generation-
qualitystringOptionalOutput mode: 'speed' or 'quality''speed'
with_audiobooleanOptionalGenerate AI audio effectsfalse
sizestringOptionalVideo resolution (e.g., '1920x1080')-
fpsnumberOptionalFrame rate: 30 or 6030
durationnumberOptionalDuration in seconds: 5 or 105
modelstringOptionalModel name-

*Note: At least one of prompt or image_url must be provided.

Image URL Formats

// Single image (starting frame)
image_url: 'https://example.com/image.jpg'

// Multiple images (start and end frames)
image_url: [
  'https://example.com/start.jpg',
  'https://example.com/end.jpg'
]

Task Status Values

  • PROCESSING: Task is being processed
  • SUCCESS: Task completed successfully
  • FAIL: Task failed

Response Formats

Task Creation Response

{
  "id": "task-12345",
  "task_status": "PROCESSING",
  "model": "video-model-v1"
}

Task Query Response (Success)

{
  "task_status": "SUCCESS",
  "model": "video-model-v1",
  "request_id": "req-67890",
  "video_result": [
    {
      "url": "https://cdn.example.com/generated-video.mp4"
    }
  ]
}

Task Query Response (Processing)

{
  "task_status": "PROCESSING",
  "id": "task-12345",
  "model": "video-model-v1"
}

Best Practices

1. Polling Strategy

// Recommended polling implementation
async function smartPoll(zai, taskId) {
  // Check immediately (some tasks complete fast)
  let result = await zai.async.result.query(taskId);

  if (result.task_status !== 'PROCESSING') {
    return result;
  }

  // Start polling with reasonable intervals
  let interval = 5000; // 5 seconds
  let maxPolls = 60; // 5 minutes total

  for (let i = 0; i < maxPolls; i++) {
    await new Promise(resolve => setTimeout(resolve, interval));
    result = await zai.async.result.query(taskId);

    if (result.task_status !== 'PROCESSING') {
      return result;
    }
  }

  throw new Error('Task timeout');
}

2. Error Handling

async function safeVideoGeneration(params) {
  try {
    const zai = await ZAI.create();

    // Validate parameters
    if (!params.prompt && !params.image_url) {
      throw new Error('Either prompt or image_url is required');
    }

    const task = await zai.video.generations.create(params);
    const result = await smartPoll(zai, task.id);

    if (result.task_status === 'SUCCESS') {
      const videoUrl = result.video_result?.[0]?.url ||
                      result.video_url ||
                      result.url ||
                      result.video;

      if (!videoUrl) {
        throw new Error('Video URL not found in response');
      }

      return {
        success: true,
        url: videoUrl,
        taskId: task.id
      };
    } else {
      return {
        success: false,
        error: 'Video generation failed',
        taskId: task.id
      };
    }
  } catch (error) {
    console.error('Video generation error:', error);
    return {
      success: false,
      error: error.message
    };
  }
}

3. Resource Management

  • Cache the ZAI instance for multiple video generations
  • Implement task ID storage for long-running operations
  • Clean up completed tasks from your tracking system
  • Implement timeout mechanisms to prevent infinite polling

4. Quality vs Speed Trade-offs

// Fast generation for previews or high volume
const quickVideo = await zai.video.generations.create({
  prompt: 'A cat playing',
  quality: 'speed',
  duration: 5,
  fps: 30
});

// High quality for final production
const qualityVideo = await zai.video.generations.create({
  prompt: 'A cat playing',
  quality: 'quality',
  duration: 10,
  fps: 60,
  size: '1920x1080'
});

5. Security Considerations

  • Validate all user inputs before creating tasks
  • Implement rate limiting for video generation endpoints
  • Store and validate task IDs securely
  • Never expose SDK credentials in client-side code
  • Set reasonable timeouts for polling operations

Common Use Cases

  1. Social Media Content: Generate short video clips for posts and stories
  2. Marketing Materials: Create product demonstration videos
  3. Education: Generate visual explanations and tutorials
  4. Entertainment: Create animated content from descriptions
  5. Prototyping: Quick video mockups for presentations
  6. Game Development: Generate cutscene or background videos
  7. Content Automation: Bulk video generation for various purposes

Integration Examples

Express.js API Endpoint

import express from 'express';
import ZAI from 'z-ai-web-dev-sdk';

const app = express();
app.use(express.json());

let zaiInstance;

async function initZAI() {
  zaiInstance = await ZAI.create();
}

// Create video generation task
app.post('/api/video/create', async (req, res) => {
  try {
    const { prompt, image_url, quality, duration } = req.body;

    if (!prompt && !image_url) {
      return res.status(400).json({
        error: 'Either prompt or image_url is required'
      });
    }

    const task = await zaiInstance.video.generations.create({
      prompt,
      image_url,
      quality: quality || 'speed',
      duration: duration || 5,
      fps: 30
    });

    res.json({
      success: true,
      taskId: task.id,
      status: task.task_status
    });
  } catch (error) {
    res.status(500).json({
      success: false,
      error: error.message
    });
  }
});

// Query task status
app.get('/api/video/status/:taskId', async (req, res) => {
  try {
    const { taskId } = req.params;
    const result = await zaiInstance.async.result.query(taskId);

    const response = {
      taskId: taskId,
      status: result.task_status
    };

    if (result.task_status === 'SUCCESS') {
      response.videoUrl = result.video_result?.[0]?.url ||
                         result.video_url ||
                         result.url ||
                         result.video;
    }

    res.json(response);
  } catch (error) {
    res.status(500).json({
      success: false,
      error: error.message
    });
  }
});

initZAI().then(() => {
  app.listen(3000, () => {
    console.log('Video generation API running on port 3000');
  });
});

WebSocket Real-time Updates

import WebSocket from 'ws';
import ZAI from 'z-ai-web-dev-sdk';

const wss = new WebSocket.Server({ port: 8080 });
let zaiInstance;

async function initZAI() {
  zaiInstance = await ZAI.create();
}

wss.on('connection', (ws) => {
  ws.on('message', async (message) => {
    try {
      const data = JSON.parse(message);

      if (data.action === 'generate') {
        // Create task
        const task = await zaiInstance.video.generations.create(data.params);

        ws.send(JSON.stringify({
          type: 'task_created',
          taskId: task.id
        }));

        // Poll for results and send updates
        pollAndNotify(ws, task.id);
      }
    } catch (error) {
      ws.send(JSON.stringify({
        type: 'error',
        message: error.message
      }));
    }
  });
});

async function pollAndNotify(ws, taskId) {
  let pollCount = 0;
  const maxPolls = 60;

  while (pollCount < maxPolls) {
    const result = await zaiInstance.async.result.query(taskId);

    ws.send(JSON.stringify({
      type: 'status_update',
      taskId: taskId,
      status: result.task_status
    }));

    if (result.task_status === 'SUCCESS') {
      ws.send(JSON.stringify({
        type: 'complete',
        taskId: taskId,
        videoUrl: result.video_result?.[0]?.url ||
                 result.video_url ||
                 result.url ||
                 result.video
      }));
      break;
    }

    if (result.task_status === 'FAIL') {
      ws.send(JSON.stringify({
        type: 'failed',
        taskId: taskId
      }));
      break;
    }

    pollCount++;
    await new Promise(resolve => setTimeout(resolve, 5000));
  }
}

initZAI();

Troubleshooting

Issue: "SDK must be used in backend"

  • Solution: Ensure z-ai-web-dev-sdk is only imported and used in server-side code

Issue: Task stays in PROCESSING status indefinitely

  • Solution: Implement proper timeout mechanisms and consider the video complexity and duration

Issue: Video URL not found in response

  • Solution: Check multiple possible response fields (video_result, video_url, url, video) as shown in examples

Issue: Task fails immediately

  • Solution: Verify that parameters meet requirements (valid prompt/image_url, supported values for quality/fps/duration)

Issue: Slow video generation

  • Solution: Use 'speed' quality mode, reduce duration/fps, or consider simpler prompts

Issue: Polling timeout

  • Solution: Increase maxPolls value or pollInterval based on video duration and quality settings

Performance Tips

  1. Use appropriate quality settings: Choose 'speed' for quick results, 'quality' for final production
  2. Start with shorter durations: Test with 5-second videos before generating longer content
  3. Implement intelligent polling: Use exponential backoff to reduce API calls
  4. Cache ZAI instance: Reuse the same instance for multiple video generations
  5. Parallel processing: Create multiple tasks simultaneously and poll them independently
  6. Monitor and log: Track task completion times to optimize your polling strategy

Remember

  • Always use z-ai-web-dev-sdk in backend code only
  • Video generation is asynchronous - always implement proper polling
  • Check multiple response fields for video URL to ensure compatibility
  • Implement timeouts to prevent infinite polling loops
  • Handle all three task statuses: PROCESSING, SUCCESS, and FAIL
  • Consider rate limits and implement appropriate delays between requests
  • The SDK is already installed - import as shown in examples

平台分布

Claude Code

27.81%
按下载量换算2,756

OpenCode

21.97%
按下载量换算2,177

Antigravity

15.37%
按下载量换算1,523

Gemini CLI

13.15%
按下载量换算1,303

windsurf

7.13%
按下载量换算707

Cursor

3.16%
按下载量换算313

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

执行命令

安装流程涉及命令执行,可能通过 npx skills add https://github.com/answerzhao/agent-skills --skill 'Video Generation';npx skills add answerzhao/agent-skills --skill "video-generation" 联网下载 Skill 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在提醒或未通过项,安装前请自行复核。

继续浏览同类 Skills