[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7D4RET86TTD6MWTDHAVKFT3":3,"skill-same:01M7D4RET86TTD6MWTDHAVKFT3":55},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":15,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":13,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":29,"install":30,"resources":43},"01M7D4RET86TTD6MWTDHAVKFT3","video-understand",null,"Implement specialized video understanding capabilities using the z-ai-web-dev-sdk. Use this skill when the user needs to analyze video content, understand motion and temporal sequences, extract information from video frames, describe video scenes, or perform video-based AI analysis. Optimized for MP4, AVI, MOV, and other common video formats.","sy220284\u002F999","sy220284","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F208273231?v=4","01M7D3YATQVSPQN4GC749CJN7E","01M7D3YAVDQZY3V0848F15R94F",0,"MIT","https:\u002F\u002Fgithub.com\u002Fsy220284\u002F999\u002Fblob\u002Fmain\u002Fskills\u002Fvideo-understand\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fsy220284\u002F999\u002Fblob\u002Fmain\u002Fskills\u002Fvideo-understand\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: video-understand\ndescription: Implement specialized video understanding capabilities using the z-ai-web-dev-sdk. Use this skill when the user needs to analyze video content, understand motion and temporal sequences, extract information from video frames, describe video scenes, or perform video-based AI analysis. Optimized for MP4, AVI, MOV, and other common video formats.\nlicense: MIT\n---\n\n# Video Understanding Skill\n\nThis skill provides specialized video understanding functionality using the z-ai-web-dev-sdk package, enabling AI models to analyze, describe, and extract information from video content including motion, temporal sequences, and scene changes.\n\n## Skills Path\n\n**Skill Location**: `{project_path}\u002Fskills\u002Fvideo-understand`\n\nthis skill is located at above path in your project.\n\n**Reference Scripts**: Example test scripts are available in the `{Skill Location}\u002Fscripts\u002F` directory for quick testing and reference. See `{Skill Location}\u002Fscripts\u002Fvideo-understand.ts` for a working example.\n\n## Overview\n\nVideo Understanding focuses specifically on video content analysis, providing capabilities for:\n- Video scene understanding and description\n- Action and motion detection\n- Temporal sequence analysis\n- Event detection in videos\n- Video content summarization\n- Scene change detection\n- People and object tracking across frames\n- Audio-visual content analysis (when applicable)\n\n**IMPORTANT**: z-ai-web-dev-sdk MUST be used in backend code only. Never use it in client-side code.\n\n## Prerequisites\n\nThe z-ai-web-dev-sdk package is already installed. Import it as shown in the examples below.\n\n## CLI Usage (For Simple Tasks)\n\nFor quick video analysis tasks, you can use the z-ai CLI instead of writing code. This is ideal for simple video descriptions, testing, or automation.\n\n### Basic Video Analysis\n\n```bash\n# Analyze a video from URL\nz-ai vision --prompt \"Summarize what happens in this video\" --image \"https:\u002F\u002Fexample.com\u002Fvideo.mp4\"\n\n# Note: Use --image flag for video URLs as well\nz-ai vision -p \"Describe the key events\" -i \"https:\u002F\u002Fexample.com\u002Fpresentation.mp4\"\n```\n\n### Analyze Local Videos\n\n```bash\n# Analyze a local video file\nz-ai vision -p \"What activities are shown in this video?\" -i \".\u002Frecording.mp4\"\n\n# Save response to file\nz-ai vision -p \"Provide a detailed summary\" -i \".\u002Fmeeting.mp4\" -o summary.json\n```\n\n### Advanced Video Analysis\n\n```bash\n# Complex scene understanding with thinking\nz-ai vision \\\n  -p \"Analyze this video and identify: 1) Main events, 2) People and their actions, 3) Timeline of key moments\" \\\n  -i \".\u002Fevent.mp4\" \\\n  --thinking \\\n  -o analysis.json\n\n# Action detection\nz-ai vision \\\n  -p \"Identify all actions performed by people in this video\" \\\n  -i \".\u002Fsports.mp4\" \\\n  --thinking\n```\n\n### Streaming Output\n\n```bash\n# Stream the video analysis\nz-ai vision -p \"Describe this video content\" -i \".\u002Fvideo.mp4\" --stream\n```\n\n### CLI Parameters\n\n- `--prompt, -p \u003Ctext>`: **Required** - Question or instruction about the video\n- `--image, -i \u003CURL or path>`: Optional - Video URL or local file path (despite the name, it works for videos too)\n- `--thinking, -t`: Optional - Enable chain-of-thought reasoning for complex analysis (default: disabled)\n- `--output, -o \u003Cpath>`: Optional - Output file path (JSON format)\n- `--stream`: Optional - Stream the response in real-time\n\n### Supported Video Formats\n\n- MP4 (.mp4) - Most widely supported format\n- AVI (.avi) - Audio Video Interleave\n- MOV (.mov) - QuickTime format\n- WebM (.webm) - Web-optimized format\n- MKV (.mkv) - Matroska format\n- FLV (.flv) - Flash Video format\n\n### When to Use CLI vs SDK\n\n**Use CLI for:**\n- Quick video summaries\n- One-off video analysis\n- Testing video understanding capabilities\n- Simple automation scripts\n- Generating video descriptions\n\n**Use SDK for:**\n- Multi-turn conversations about videos\n- Complex video processing pipelines\n- Production applications with error handling\n- Custom integration with video processing logic\n- Batch video processing with custom workflows\n\n## Recommended Approach\n\nFor better performance and reliability with local videos, consider:\n1. Uploading videos to a CDN and using URLs\n2. For shorter videos, convert key frames to images for faster analysis\n3. For long videos, consider chunking or sampling at intervals\n\n## Basic Video Understanding Implementation\n\n### Single Video Analysis\n\n```javascript\nimport ZAI from 'z-ai-web-dev-sdk';\n\nasync function analyzeVideo(videoUrl, prompt) {\n  const zai = await ZAI.create();\n\n  const response = await zai.chat.completions.createVision({\n    messages: [\n      {\n        role: 'user',\n        content: [\n          {\n            type: 'text',\n            text: prompt\n          },\n          {\n            type: 'video_url',\n            video_url: {\n              url: videoUrl\n            }\n          }\n        ]\n      }\n    ],\n    thinking: { type: 'disabled' }\n  });\n\n  return response.choices[0]?.message?.content;\n}\n\n\u002F\u002F Usage examples\nconst summary = await analyzeVideo(\n  'https:\u002F\u002Fexample.com\u002Fpresentation.mp4',\n  'Summarize the key points presented in this video'\n);\n\nconst actionDetection = await analyzeVideo(\n  'https:\u002F\u002Fexample.com\u002Fsports.mp4',\n  'Identify and describe all athletic actions performed in this video'\n);\n```\n\n### Video Scene Understanding\n\n```javascript\nimport ZAI from 'z-ai-web-dev-sdk';\n\nasync function understandVideoScenes(videoUrl) {\n  const zai = await ZAI.create();\n\n  const prompt = `Analyze this video and provide:\n1. Overall summary of the video content\n2. Main scenes or segments (with approximate timestamps if possible)\n3. Key people or characters and their roles\n4. Important actions or events in chronological order\n5. Setting and environment description\n6. Overall mood or tone`;\n\n  const response = await zai.chat.completions.createVision({\n    messages: [\n      {\n        role: 'user',\n        content: [\n          { type: 'text', text: prompt },\n          { type: 'video_url', video_url: { url: videoUrl } }\n        ]\n      }\n    ],\n    thinking: { type: 'enabled' } \u002F\u002F Enable for detailed analysis\n  });\n\n  return response.choices[0]?.message?.content;\n}\n\n\u002F\u002F Usage\nconst sceneAnalysis = await understandVideoScenes(\n  'https:\u002F\u002Fexample.com\u002Fdocumentary.mp4'\n);\n```\n\n### Motion and Action Detection\n\n```javascript\nimport ZAI from 'z-ai-web-dev-sdk';\n\nasync function detectActions(videoUrl, specificAction = null) {\n  const zai = await ZAI.create();\n\n  const prompt = specificAction\n    ? `Identify all instances of \"${specificAction}\" in this video. For each instance, describe when it occurs and provide details about how it's performed.`\n    : 'Identify and describe all significant actions and movements in this video. Include who is performing them and when they occur.';\n\n  const response = await zai.chat.completions.createVision({\n    messages: [\n      {\n        role: 'user',\n        content: [\n          { type: 'text', text: prompt },\n          { type: 'video_url', video_url: { url: videoUrl } }\n        ]\n      }\n    ],\n    thinking: { type: 'enabled' }\n  });\n\n  return response.choices[0]?.message?.content;\n}\n\n\u002F\u002F Usage\nconst runningActions = await detectActions(\n  'https:\u002F\u002Fexample.com\u002Fsports.mp4',\n  'running'\n);\n\nconst allActions = await detectActions(\n  'https:\u002F\u002Fexample.com\u002Factivity.mp4'\n);\n```\n\n### Event Timeline Extraction\n\n```javascript\nimport ZAI from 'z-ai-web-dev-sdk';\n\nasync function extractTimeline(videoUrl) {\n  const zai = await ZAI.create();\n\n  const prompt = `Create a detailed timeline of events in this video:\n- Identify key moments and transitions\n- Note approximate timing (beginning, middle, end or specific timestamps if visible)\n- Describe what happens at each key point\n- Identify any cause-and-effect relationships between events\n\nFormat as a chronological list.`;\n\n  const response = await zai.chat.completions.createVision({\n    messages: [\n      {\n        role: 'user',\n        content: [\n          { type: 'text', text: prompt },\n          { type: 'video_url', video_url: { url: videoUrl } }\n        ]\n      }\n    ],\n    thinking: { type: 'enabled' }\n  });\n\n  return response.choices[0]?.message?.content;\n}\n```\n\n### Video Content Classification\n\n```javascript\nimport ZAI from 'z-ai-web-dev-sdk';\n\nasync function classifyVideo(videoUrl) {\n  const zai = await ZAI.create();\n\n  const prompt = `Classify this video content:\n1. Primary category (e.g., educational, entertainment, sports, news, tutorial)\n2. Sub-category or genre\n3. Target audience\n4. Content style (professional, casual, documentary, etc.)\n5. Key themes or topics\n6. Suggested tags (10-15 keywords)\n\nFormat your response as structured JSON.`;\n\n  const response = await zai.chat.completions.createVision({\n    messages: [\n      {\n        role: 'user',\n        content: [\n          { type: 'text', text: prompt },\n          { type: 'video_url', video_url: { url: videoUrl } }\n        ]\n      }\n    ],\n    thinking: { type: 'disabled' }\n  });\n\n  const content = response.choices[0]?.message?.content;\n  \n  try {\n    return JSON.parse(content);\n  } catch (e) {\n    return { rawResponse: content };\n  }\n}\n```\n\n## Advanced Use Cases\n\n### Multi-turn Video Conversation\n\n```javascript\nimport ZAI from 'z-ai-web-dev-sdk';\n\nclass VideoConversation {\n  constructor() {\n    this.messages = [];\n  }\n\n  async initialize() {\n    this.zai = await ZAI.create();\n  }\n\n  async loadVideo(videoUrl, initialQuestion) {\n    this.messages.push({\n      role: 'user',\n      content: [\n        { type: 'text', text: initialQuestion },\n        { type: 'video_url', video_url: { url: videoUrl } }\n      ]\n    });\n\n    return this.getResponse();\n  }\n\n  async askFollowUp(question) {\n    this.messages.push({\n      role: 'user',\n      content: [\n        { type: 'text', text: question }\n      ]\n    });\n\n    return this.getResponse();\n  }\n\n  async getResponse() {\n    const response = await this.zai.chat.completions.createVision({\n      messages: this.messages,\n      thinking: { type: 'disabled' }\n    });\n\n    const assistantMessage = response.choices[0]?.message?.content;\n    \n    this.messages.push({\n      role: 'assistant',\n      content: assistantMessage\n    });\n\n    return assistantMessage;\n  }\n}\n\n\u002F\u002F Usage\nconst conversation = new VideoConversation();\nawait conversation.initialize();\n\nconst initial = await conversation.loadVideo(\n  'https:\u002F\u002Fexample.com\u002Flecture.mp4',\n  'What is the main topic of this lecture?'\n);\n\nconst followup1 = await conversation.askFollowUp(\n  'Can you explain the key concepts mentioned?'\n);\n\nconst followup2 = await conversation.askFollowUp(\n  'What examples were used to illustrate these concepts?'\n);\n```\n\n### Video Quality Assessment\n\n```javascript\nimport ZAI from 'z-ai-web-dev-sdk';\n\nasync function assessVideoQuality(videoUrl) {\n  const zai = await ZAI.create();\n\n  const prompt = `Assess the quality of this video:\n1. Visual quality (resolution, clarity, lighting) - Rate 1-10\n2. Audio quality (if audio is present) - Rate 1-10\n3. Camera work (stability, framing, composition) - Rate 1-10\n4. Production value (editing, transitions, effects) - Rate 1-10\n5. Content clarity (is the message clear?) - Rate 1-10\n6. Pacing (too fast, too slow, just right)\n7. Technical issues (artifacts, blur, audio sync, etc.)\n8. Overall rating - 1-10\n9. Specific recommendations for improvement\n\nProvide detailed feedback for each criterion.`;\n\n  const response = await zai.chat.completions.createVision({\n    messages: [\n      {\n        role: 'user',\n        content: [\n          { type: 'text', text: prompt },\n          { type: 'video_url', video_url: { url: videoUrl } }\n        ]\n      }\n    ],\n    thinking: { type: 'enabled' }\n  });\n\n  return response.choices[0]?.message?.content;\n}\n```\n\n### Video Content Moderation\n\n```javascript\nimport ZAI from 'z-ai-web-dev-sdk';\n\nasync function moderateVideo(videoUrl) {\n  const zai = await ZAI.create();\n\n  const prompt = `Review this video for content moderation:\n1. Check for any inappropriate or sensitive content\n2. Identify any potential safety concerns\n3. Note any content that might violate common community guidelines\n4. Assess age-appropriateness\n5. Identify any copyrighted material visible (logos, brands, music)\n6. Overall safety rating: Safe \u002F Caution \u002F Review Required\n\nProvide specific examples for any concerns identified.`;\n\n  const response = await zai.chat.completions.createVision({\n    messages: [\n      {\n        role: 'user',\n        content: [\n          { type: 'text', text: prompt },\n          { type: 'video_url', video_url: { url: videoUrl } }\n        ]\n      }\n    ],\n    thinking: { type: 'enabled' }\n  });\n\n  return response.choices[0]?.message?.content;\n}\n```\n\n### Video Transcript Generation (Visual Description)\n\n```javascript\nimport ZAI from 'z-ai-web-dev-sdk';\n\nasync function generateVisualTranscript(videoUrl) {\n  const zai = await ZAI.create();\n\n  const prompt = `Generate a detailed visual transcript of this video:\n- Describe what's happening in each scene\n- Note any text that appears on screen\n- Describe important visual elements\n- Mention any scene changes or transitions\n- Include descriptions of people's actions and expressions\n\nFormat as a time-based narrative (e.g., \"At the beginning...\", \"Then...\", \"Finally...\").`;\n\n  const response = await zai.chat.completions.createVision({\n    messages: [\n      {\n        role: 'user',\n        content: [\n          { type: 'text', text: prompt },\n          { type: 'video_url', video_url: { url: videoUrl } }\n        ]\n      }\n    ],\n    thinking: { type: 'disabled' }\n  });\n\n  return response.choices[0]?.message?.content;\n}\n```\n\n### Sports Video Analysis\n\n```javascript\nimport ZAI from 'z-ai-web-dev-sdk';\n\nasync function analyzeSportsVideo(videoUrl, sport = null) {\n  const zai = await ZAI.create();\n\n  const prompt = sport\n    ? `Analyze this ${sport} video in detail:\n1. Identify players and their positions\n2. Describe key plays and strategies\n3. Note scoring events or important moments\n4. Assess player performance\n5. Identify any rule violations or fouls\n6. Describe the pace and flow of the game`\n    : `Analyze this sports video:\n1. Identify the sport being played\n2. Describe the key actions and plays\n3. Note any scoring or significant events\n4. Describe player movements and strategies\n5. Overall assessment of the game or match`;\n\n  const response = await zai.chat.completions.createVision({\n    messages: [\n      {\n        role: 'user',\n        content: [\n          { type: 'text', text: prompt },\n          { type: 'video_url', video_url: { url: videoUrl } }\n        ]\n      }\n    ],\n    thinking: { type: 'enabled' }\n  });\n\n  return response.choices[0]?.message?.content;\n}\n```\n\n### Educational Video Summarization\n\n```javascript\nimport ZAI from 'z-ai-web-dev-sdk';\n\nasync function summarizeEducationalVideo(videoUrl) {\n  const zai = await ZAI.create();\n\n  const prompt = `Summarize this educational video for students:\n1. Main topic or learning objective\n2. Key concepts explained (in order)\n3. Important definitions or terminology\n4. Examples used to illustrate concepts\n5. Visual aids or demonstrations shown\n6. Key takeaways or conclusions\n7. Suggested review points\n\nFormat as a study guide.`;\n\n  const response = await zai.chat.completions.createVision({\n    messages: [\n      {\n        role: 'user',\n        content: [\n          { type: 'text', text: prompt },\n          { type: 'video_url', video_url: { url: videoUrl } }\n        ]\n      }\n    ],\n    thinking: { type: 'enabled' }\n  });\n\n  return response.choices[0]?.message?.content;\n}\n```\n\n## Batch Video Processing\n\n### Process Multiple Videos\n\n```javascript\nimport ZAI from 'z-ai-web-dev-sdk';\n\nclass VideoBatchProcessor {\n  constructor() {\n    this.zai = null;\n  }\n\n  async initialize() {\n    this.zai = await ZAI.create();\n  }\n\n  async processVideo(videoUrl, prompt) {\n    const response = await this.zai.chat.completions.createVision({\n      messages: [\n        {\n          role: 'user',\n          content: [\n            { type: 'text', text: prompt },\n            { type: 'video_url', video_url: { url: videoUrl } }\n          ]\n        }\n      ],\n      thinking: { type: 'disabled' }\n    });\n\n    return response.choices[0]?.message?.content;\n  }\n\n  async processBatch(videoUrls, prompt) {\n    const results = [];\n    \n    for (const videoUrl of videoUrls) {\n      try {\n        console.log(`Processing: ${videoUrl}`);\n        const result = await this.processVideo(videoUrl, prompt);\n        results.push({ videoUrl, success: true, result });\n        \n        \u002F\u002F Add delay to avoid rate limiting\n        await new Promise(resolve => setTimeout(resolve, 1000));\n      } catch (error) {\n        results.push({ \n          videoUrl, \n          success: false, \n          error: error.message \n        });\n      }\n    }\n\n    return results;\n  }\n}\n\n\u002F\u002F Usage\nconst processor = new VideoBatchProcessor();\nawait processor.initialize();\n\nconst videos = [\n  'https:\u002F\u002Fexample.com\u002Fvideo1.mp4',\n  'https:\u002F\u002Fexample.com\u002Fvideo2.mp4',\n  'https:\u002F\u002Fexample.com\u002Fvideo3.mp4'\n];\n\nconst results = await processor.processBatch(\n  videos,\n  'Provide a brief summary of this video suitable for a content catalog'\n);\n```\n\n## Best Practices\n\n### 1. Video Preparation\n- Use standard video formats (MP4, MOV, AVI)\n- Ensure videos are accessible via public URLs or properly encoded\n- For long videos, consider creating shorter clips for specific analysis\n- Optimize video size for faster processing\n- Ensure good lighting and audio quality in source videos\n\n### 2. Prompt Engineering for Videos\n- Be specific about temporal aspects (\"beginning\", \"throughout\", \"at the end\")\n- Mention what type of analysis you need (actions, events, scenes, etc.)\n- For long videos, ask for summaries or key moments\n- Use thinking mode for complex temporal reasoning\n- Specify if you need chronological or thematic organization\n\n### 3. Error Handling\n\n```javascript\nasync function safeVideoAnalysis(videoUrl, prompt) {\n  try {\n    const zai = await ZAI.create();\n    \n    const response = await zai.chat.completions.createVision({\n      messages: [\n        {\n          role: 'user',\n          content: [\n            { type: 'text', text: prompt },\n            { type: 'video_url', video_url: { url: videoUrl } }\n          ]\n        }\n      ],\n      thinking: { type: 'disabled' }\n    });\n\n    return {\n      success: true,\n      content: response.choices[0]?.message?.content\n    };\n  } catch (error) {\n    console.error('Video analysis error:', error);\n    return {\n      success: false,\n      error: error.message\n    };\n  }\n}\n```\n\n### 4. Performance Optimization\n- Cache SDK instance for batch processing\n- Implement request throttling (add delays between requests)\n- Process videos asynchronously when possible\n- For very long videos, consider analyzing at specific intervals\n- Use appropriate thinking mode (disabled for simple descriptions, enabled for complex analysis)\n\n### 5. Security Considerations\n- Validate video URLs before processing\n- Implement rate limiting for public APIs\n- Sanitize user-provided video URLs\n- Never expose SDK credentials in client-side code\n- Implement content moderation for user-uploaded videos\n- Consider video file size limits\n\n## Common Use Cases\n\n1. **Content Moderation**: Automatically review video uploads for policy compliance\n2. **Video Cataloging**: Generate descriptions and tags for video libraries\n3. **Sports Analysis**: Analyze games, identify plays, assess performance\n4. **Educational Content**: Summarize lectures, create study guides\n5. **Security & Surveillance**: Detect events, track activities (with appropriate authorization)\n6. **Quality Control**: Assess video production quality\n7. **Social Media**: Generate video captions and descriptions\n8. **Training & Documentation**: Analyze training videos, create documentation\n9. **Event Recording**: Summarize meetings, conferences, presentations\n10. **Entertainment**: Analyze films, shows for content, themes, scenes\n\n## Integration Examples\n\n### Express.js API Endpoint\n\n```javascript\nimport express from 'express';\nimport ZAI from 'z-ai-web-dev-sdk';\n\nconst app = express();\napp.use(express.json());\n\nlet zaiInstance;\n\nasync function initZAI() {\n  zaiInstance = await ZAI.create();\n}\n\n\u002F\u002F Analyze video from URL\napp.post('\u002Fapi\u002Fanalyze-video', async (req, res) => {\n  try {\n    const { videoUrl, prompt } = req.body;\n\n    if (!videoUrl || !prompt) {\n      return res.status(400).json({ \n        error: 'videoUrl and prompt are required' \n      });\n    }\n\n    const response = await zaiInstance.chat.completions.createVision({\n      messages: [\n        {\n          role: 'user',\n          content: [\n            { type: 'text', text: prompt },\n            { type: 'video_url', video_url: { url: videoUrl } }\n          ]\n        }\n      ],\n      thinking: { type: 'disabled' }\n    });\n\n    res.json({\n      success: true,\n      analysis: response.choices[0]?.message?.content\n    });\n  } catch (error) {\n    res.status(500).json({\n      success: false,\n      error: error.message\n    });\n  }\n});\n\n\u002F\u002F Get video summary\napp.post('\u002Fapi\u002Fvideo-summary', async (req, res) => {\n  try {\n    const { videoUrl } = req.body;\n\n    if (!videoUrl) {\n      return res.status(400).json({ error: 'videoUrl is required' });\n    }\n\n    const prompt = 'Provide a comprehensive summary of this video including: 1) Main content\u002Ftopic, 2) Key events in chronological order, 3) Important people or subjects, 4) Overall takeaway.';\n\n    const response = await zaiInstance.chat.completions.createVision({\n      messages: [\n        {\n          role: 'user',\n          content: [\n            { type: 'text', text: prompt },\n            { type: 'video_url', video_url: { url: videoUrl } }\n          ]\n        }\n      ],\n      thinking: { type: 'enabled' }\n    });\n\n    res.json({\n      success: true,\n      summary: response.choices[0]?.message?.content\n    });\n  } catch (error) {\n    res.status(500).json({\n      success: false,\n      error: error.message\n    });\n  }\n});\n\ninitZAI().then(() => {\n  app.listen(3000, () => {\n    console.log('Video understanding API running on port 3000');\n  });\n});\n```\n\n### Next.js API Route\n\n```javascript\n\u002F\u002F pages\u002Fapi\u002Fvideo-understand.js\nimport ZAI from 'z-ai-web-dev-sdk';\n\nlet zaiInstance = null;\n\nasync function getZAI() {\n  if (!zaiInstance) {\n    zaiInstance = await ZAI.create();\n  }\n  return zaiInstance;\n}\n\nexport default async function handler(req, res) {\n  if (req.method !== 'POST') {\n    return res.status(405).json({ error: 'Method not allowed' });\n  }\n\n  try {\n    const { videoUrl, prompt, enableThinking = false } = req.body;\n\n    if (!videoUrl || !prompt) {\n      return res.status(400).json({ \n        error: 'videoUrl and prompt are required' \n      });\n    }\n\n    const zai = await getZAI();\n\n    const response = await zai.chat.completions.createVision({\n      messages: [\n        {\n          role: 'user',\n          content: [\n            { type: 'text', text: prompt },\n            { type: 'video_url', video_url: { url: videoUrl } }\n          ]\n        }\n      ],\n      thinking: { type: enableThinking ? 'enabled' : 'disabled' }\n    });\n\n    res.status(200).json({\n      success: true,\n      analysis: response.choices[0]?.message?.content\n    });\n  } catch (error) {\n    console.error('Error:', error);\n    res.status(500).json({\n      success: false,\n      error: error.message\n    });\n  }\n}\n```\n\n## Troubleshooting\n\n**Issue**: \"SDK must be used in backend\"\n- **Solution**: Ensure z-ai-web-dev-sdk is only imported and used in server-side code, never in client\u002Fbrowser code\n\n**Issue**: Video not loading or being analyzed\n- **Solution**: Verify the video URL is accessible, returns correct MIME type, and is in a supported format\n\n**Issue**: Inaccurate temporal analysis\n- **Solution**: Enable thinking mode for complex temporal reasoning, provide more specific prompts about time\u002Fsequence\n\n**Issue**: Slow response times for videos\n- **Solution**: Videos take longer to process than images; consider shorter clips or sampling for long videos\n\n**Issue**: Missing details from video\n- **Solution**: Be more specific in your prompt, ask about particular time segments or aspects\n\n**Issue**: Video format not supported\n- **Solution**: Convert video to MP4 (most widely supported), check that URL returns proper video MIME type\n\n## Remember\n\n- Always use z-ai-web-dev-sdk in backend code only\n- The SDK is already installed - import as shown in examples\n- Use `video_url` content type for video files\n- Video analysis takes longer than image analysis - be patient\n- Enable thinking mode for complex temporal reasoning and event detection\n- Structure prompts to include temporal information (beginning, middle, end)\n- Handle errors gracefully in production\n- Implement rate limiting and delays for batch processing\n- Validate and sanitize user inputs\n- Consider privacy and security when processing user videos\n- For very long videos, consider analyzing specific segments or key frames\n","# Video Understanding Skill\n\nThis skill provides specialized video understanding functionality using the z-ai-web-dev-sdk package, enabling AI models to analyze, describe, and extract information from video content including motion, temporal sequences, and scene changes.\n\n## Skills Path\n\n**Skill Location**: `{project_path}\u002Fskills\u002Fvideo-understand`\n\nthis skill is located at above path in your project.\n\n**Reference Scripts**: Example test scripts are available in the `{Skill Location}\u002Fscripts\u002F` directory for quick testing and reference. See `{Skill Location}\u002Fscripts\u002Fvideo-understand.ts` for a working example.\n\n## Overview\n\nVideo Understanding focuses specifically on video content analysis, providing capabilities for:\n- Video scene understanding and description\n- Action and motion detection\n- Temporal sequence analysis\n- Event detection in videos\n- Video content summarization\n- Scene change detection\n- People and object tracking across frames\n- Audio-visual content analysis (when applicable)\n\n**IMPORTANT**: z-ai-web-dev-sdk MUST be used in backend code only. Never use it in client-side code.\n\n## Prerequisites\n\nThe z-ai-web-dev-sdk package is already installed. Import it as shown in the examples below.\n\n## CLI Usage (For Simple Tasks)\n\nFor quick video analysis tasks, you can use the z-ai CLI instead of writing code. This is ideal for simple video descriptions, testing, or automation.\n\n### Basic Video Analysis\n\n```bash\n# Analyze a video from URL\nz-ai vision --prompt \"Summarize what happens in this video\" --image \"https:\u002F\u002Fexample.com\u002Fvideo.mp4\"\n\n# Note: Use --image flag for video URLs as well\nz-ai vision -p \"Describe the key events\" -i \"https:\u002F\u002Fexample.com\u002Fpresentation.mp4\"\n```\n\n### Analyze Local Videos\n\n```bash\n# Analyze a local video file\nz-ai vision -p \"What activities are shown in this video?\" -i \".\u002Frecording.mp4\"\n\n# Save response to file\nz-ai vision -p \"Provide a detailed summary\" -i \".\u002Fmeeting.mp4\" -o summary.json\n```\n\n### Advanced Video Analysis\n\n```bash\n# Complex scene understanding with thinking\nz-ai vision \\\n  -p \"Analyze this video and identify: 1) Main events, 2) People and their actions, 3) Timeline of key moments\" \\\n  -i \".\u002Fevent.mp4\" \\\n  --thinking \\\n  -o analysis.json\n\n# Action detection\nz-ai vision \\\n  -p \"Identify all actions performed by people in this video\" \\\n  -i \".\u002Fsports.mp4\" \\\n  --thinking\n```\n\n### Streaming Output\n\n```bash\n# Stream the video analysis\nz-ai vision -p \"Describe this video content\" -i \".\u002Fvideo.mp4\" --stream\n```\n\n### CLI Parameters\n\n- `--prompt, -p \u003Ctext>`: **Required** - Question or instruction about the video\n- `--image, -i \u003CURL or path>`: Optional - Video URL or local file path (despite the name, it works for videos too)\n- `--thinking, -t`: Optional - Enable chain-of-thought reasoning for complex analysis (default: disabled)\n- `--output, -o \u003Cpath>`: Optional - Output file path (JSON format)\n- `--stream`: Optional - Stream the response in real-time\n\n### Supported Video Formats\n\n- MP4 (.mp4) - Most widely supported format\n- AVI (.avi) - Audio Video Interleave\n- MOV (.mov) - QuickTime format\n- WebM (.webm) - Web-optimized format\n- MKV (.mkv) - Matroska format\n- FLV (.flv) - Flash Video format\n\n### When to Use CLI vs SDK\n\n**Use CLI for:**\n- Quick video summaries\n- One-off video analysis\n- Testing video understanding capabilities\n- Simple automation scripts\n- Generating video descriptions\n\n**Use SDK for:**\n- Multi-turn conversations about videos\n- Complex video processing pipelines\n- Production applications with error handling\n- Custom integration with video processing logic\n- Batch video processing with custom workflows\n\n## Recommended Approach\n\nFor better performance and reliability with local videos, consider:\n1. Uploading videos to a CDN and using URLs\n2. For shorter videos, convert key frames to images for faster analysis\n3. For long videos, consider chunking or sampling at intervals\n\n## Basic Video Understanding Implementation\n\n### Single Video Analysis\n\n```javascript\nimport ZAI from 'z-ai-web-dev-sdk';\n\nasync function analyzeVideo(videoUrl, prompt) {\n  const zai = await ZAI.create();\n\n  const response = await zai.chat.completions.createVision({\n    messages: [\n      {\n        role: 'user',\n        content: [\n          {\n            type: 'text',\n            text: prompt\n          },\n          {\n            type: 'video_url',\n            video_url: {\n              url: videoUrl\n            }\n          }\n        ]\n      }\n    ],\n    thinking: { type: 'disabled' }\n  });\n\n  return response.choices[0]?.message?.content;\n}\n\n\u002F\u002F Usage examples\nconst summary = await analyzeVideo(\n  'https:\u002F\u002Fexample.com\u002Fpresentation.mp4',\n  'Summarize the key points presented in this video'\n);\n\nconst actionDetection = await analyzeVideo(\n  'https:\u002F\u002Fexample.com\u002Fsports.mp4',\n  'Identify and describe all athletic actions performed in this video'\n);\n```\n\n### Video Scene Understanding\n\n```javascript\nimport ZAI from 'z-ai-web-dev-sdk';\n\nasync function understandVideoScenes(videoUrl) {\n  const zai = await ZAI.create();\n\n  const prompt = `Analyze this video and provide:\n1. Overall summary of the video content\n2. Main scenes or segments (with approximate timestamps if possible)\n3. Key people or characters and their roles\n4. Important actions or events in chronological order\n5. Setting and environment description\n6. Overall mood or tone`;\n\n  const response = await zai.chat.completions.createVision({\n    messages: [\n      {\n        role: 'user',\n        content: [\n          { type: 'text', text: prompt },\n          { type: 'video_url', video_url: { url: videoUrl } }\n        ]\n      }\n    ],\n    thinking: { type: 'enabled' } \u002F\u002F Enable for detailed analysis\n  });\n\n  return response.choices[0]?.message?.content;\n}\n\n\u002F\u002F Usage\nconst sceneAnalysis = await understandVideoScenes(\n  'https:\u002F\u002Fexample.com\u002Fdocumentary.mp4'\n);\n```\n\n### Motion and Action Detection\n\n```javascript\nimport ZAI from 'z-ai-web-dev-sdk';\n\nasync function detectActions(videoUrl, specificAction = null) {\n  const zai = await ZAI.create();\n\n  const prompt = specificAction\n    ? `Identify all instances of \"${specificAction}\" in this video. For each instance, describe when it occurs and provide details about how it's performed.`\n    : 'Identify and describe all significant actions and movements in this video. Include who is performing them and when they occur.';\n\n  const response = await zai.chat.completions.createVision({\n    messages: [\n      {\n        role: 'user',\n        content: [\n          { type: 'text', text: prompt },\n          { type: 'video_url', video_url: { url: videoUrl } }\n        ]\n      }\n    ],\n    thinking: { type: 'enabled' }\n  });\n\n  return response.choices[0]?.message?.content;\n}\n\n\u002F\u002F Usage\nconst runningActions = await detectActions(\n  'https:\u002F\u002Fexample.com\u002Fsports.mp4',\n  'running'\n);\n\nconst allActions = await detectActions(\n  'https:\u002F\u002Fexample.com\u002Factivity.mp4'\n);\n```\n\n### Event Timeline Extraction\n\n```javascript\nimport ZAI from 'z-ai-web-dev-sdk';\n\nasync function extractTimeline(videoUrl) {\n  const zai = await ZAI.create();\n\n  const prompt = `Create a detailed timeline of events in this video:\n- Identify key moments and transitions\n- Note approximate timing (beginning, middle, end or specific timestamps if visible)\n- Describe what happens at each key point\n- Identify any cause-and-effect relationships between events\n\nFormat as a chronological list.`;\n\n  const response = await zai.chat.completions.createVision({\n    messages: [\n      {\n        role: 'user',\n        content: [\n          { type: 'text', text: prompt },\n          { type: 'video_url', video_url: { url: videoUrl } }\n        ]\n      }\n    ],\n    thinking: { type: 'enabled' }\n  });\n\n  return response.choices[0]?.message?.content;\n}\n```\n\n### Video Content Classification\n\n```javascript\nimport ZAI from 'z-ai-web-dev-sdk';\n\nasync function classifyVideo(videoUrl) {\n  const zai = await ZAI.create();\n\n  const prompt = `Classify this video content:\n1. Primary category (e.g., educational, entertainment, sports, news, tutorial)\n2. Sub-category or genre\n3. Target audience\n4. Content style (professional, casual, documentary, etc.)\n5. Key themes or topics\n6. Suggested tags (10-15 keywords)\n\nFormat your response as structured JSON.`;\n\n  const response = await zai.chat.completions.createVision({\n    messages: [\n      {\n        role: 'user',\n        content: [\n          { type: 'text', text: prompt },\n          { type: 'video_url', video_url: { url: videoUrl } }\n        ]\n      }\n    ],\n    thinking: { type: 'disabled' }\n  });\n\n  const content = response.choices[0]?.message?.content;\n  \n  try {\n    return JSON.parse(content);\n  } catch (e) {\n    return { rawResponse: content };\n  }\n}\n```\n\n## Advanced Use Cases\n\n### Multi-turn Video Conversation\n\n```javascript\nimport ZAI from 'z-ai-web-dev-sdk';\n\nclass VideoConversation {\n  constructor() {\n    this.messages = [];\n  }\n\n  async initialize() {\n    this.zai = await ZAI.create();\n  }\n\n  async loadVideo(videoUrl, initialQuestion) {\n    this.messages.push({\n      role: 'user',\n      content: [\n        { type: 'text', text: initialQuestion },\n        { type: 'video_url', video_url: { url: videoUrl } }\n      ]\n    });\n\n    return this.getResponse();\n  }\n\n  async askFollowUp(question) {\n    this.messages.push({\n      role: 'user',\n      content: [\n        { type: 'text', text: question }\n      ]\n    });\n\n    return this.getResponse();\n  }\n\n  async getResponse() {\n    const response = await this.zai.chat.completions.createVision({\n      messages: this.messages,\n      thinking: { type: 'disabled' }\n    });\n\n    const assistantMessage = response.choices[0]?.message?.content;\n    \n    this.messages.push({\n      role: 'assistant',\n      content: assistantMessage\n    });\n\n    return assistantMessage;\n  }\n}\n\n\u002F\u002F Usage\nconst conversation = new VideoConversation();\nawait conversation.initialize();\n\nconst initial = await conversation.loadVideo(\n  'https:\u002F\u002Fexample.com\u002Flecture.mp4',\n  'What is the main topic of this lecture?'\n);\n\nconst followup1 = await conversation.askFollowUp(\n  'Can you explain the key concepts mentioned?'\n);\n\nconst followup2 = await conversation.askFollowUp(\n  'What examples were used to illustrate these concepts?'\n);\n```\n\n### Video Quality Assessment\n\n```javascript\nimport ZAI from 'z-ai-web-dev-sdk';\n\nasync function assessVideoQuality(videoUrl) {\n  const zai = await ZAI.create();\n\n  const prompt = `Assess the quality of this video:\n1. Visual quality (resolution, clarity, lighting) - Rate 1-10\n2. Audio quality (if audio is present) - Rate 1-10\n3. Camera work (stability, framing, composition) - Rate 1-10\n4. Production value (editing, transitions, effects) - Rate 1-10\n5. Content clarity (is the message clear?) - Rate 1-10\n6. Pacing (too fast, too slow, just right)\n7. Technical issues (artifacts, blur, audio sync, etc.)\n8. Overall rating - 1-10\n9. Specific recommendations for improvement\n\nProvide detailed feedback for each criterion.`;\n\n  const response = await zai.chat.completions.createVision({\n    messages: [\n      {\n        role: 'user',\n        content: [\n          { type: 'text', text: prompt },\n          { type: 'video_url', video_url: { url: videoUrl } }\n        ]\n      }\n    ],\n    thinking: { type: 'enabled' }\n  });\n\n  return response.choices[0]?.message?.content;\n}\n```\n\n### Video Content Moderation\n\n```javascript\nimport ZAI from 'z-ai-web-dev-sdk';\n\nasync function moderateVideo(videoUrl) {\n  const zai = await ZAI.create();\n\n  const prompt = `Review this video for content moderation:\n1. Check for any inappropriate or sensitive content\n2. Identify any potential safety concerns\n3. Note any content that might violate common community guidelines\n4. Assess age-appropriateness\n5. Identify any copyrighted material visible (logos, brands, music)\n6. Overall safety rating: Safe \u002F Caution \u002F Review Required\n\nProvide specific examples for any concerns identified.`;\n\n  const response = await zai.chat.completions.createVision({\n    messages: [\n      {\n        role: 'user',\n        content: [\n          { type: 'text', text: prompt },\n          { type: 'video_url', video_url: { url: videoUrl } }\n        ]\n      }\n    ],\n    thinking: { type: 'enabled' }\n  });\n\n  return response.choices[0]?.message?.content;\n}\n```\n\n### Video Transcript Generation (Visual Description)\n\n```javascript\nimport ZAI from 'z-ai-web-dev-sdk';\n\nasync function generateVisualTranscript(videoUrl) {\n  const zai = await ZAI.create();\n\n  const prompt = `Generate a detailed visual transcript of this video:\n- Describe what's happening in each scene\n- Note any text that appears on screen\n- Describe important visual elements\n- Mention any scene changes or transitions\n- Include descriptions of people's actions and expressions\n\nFormat as a time-based narrative (e.g., \"At the beginning...\", \"Then...\", \"Finally...\").`;\n\n  const response = await zai.chat.completions.createVision({\n    messages: [\n      {\n        role: 'user',\n        content: [\n          { type: 'text', text: prompt },\n          { type: 'video_url', video_url: { url: videoUrl } }\n        ]\n      }\n    ],\n    thinking: { type: 'disabled' }\n  });\n\n  return response.choices[0]?.message?.content;\n}\n```\n\n### Sports Video Analysis\n\n```javascript\nimport ZAI from 'z-ai-web-dev-sdk';\n\nasync function analyzeSportsVideo(videoUrl, sport = null) {\n  const zai = await ZAI.create();\n\n  const prompt = sport\n    ? `Analyze this ${sport} video in detail:\n1. Identify players and their positions\n2. Describe key plays and strategies\n3. Note scoring events or important moments\n4. Assess player performance\n5. Identify any rule violations or fouls\n6. Describe the pace and flow of the game`\n    : `Analyze this sports video:\n1. Identify the sport being played\n2. Describe the key actions and plays\n3. Note any scoring or significant events\n4. Describe player movements and strategies\n5. Overall assessment of the game or match`;\n\n  const response = await zai.chat.completions.createVision({\n    messages: [\n      {\n        role: 'user',\n        content: [\n          { type: 'text', text: prompt },\n          { type: 'video_url', video_url: { url: videoUrl } }\n        ]\n      }\n    ],\n    thinking: { type: 'enabled' }\n  });\n\n  return response.choices[0]?.message?.content;\n}\n```\n\n### Educational Video Summarization\n\n```javascript\nimport ZAI from 'z-ai-web-dev-sdk';\n\nasync function summarizeEducationalVideo(videoUrl) {\n  const zai = await ZAI.create();\n\n  const prompt = `Summarize this educational video for students:\n1. Main topic or learning objective\n2. Key concepts explained (in order)\n3. Important definitions or terminology\n4. Examples used to illustrate concepts\n5. Visual aids or demonstrations shown\n6. Key takeaways or conclusions\n7. Suggested review points\n\nFormat as a study guide.`;\n\n  const response = await zai.chat.completions.createVision({\n    messages: [\n      {\n        role: 'user',\n        content: [\n          { type: 'text', text: prompt },\n          { type: 'video_url', video_url: { url: videoUrl } }\n        ]\n      }\n    ],\n    thinking: { type: 'enabled' }\n  });\n\n  return response.choices[0]?.message?.content;\n}\n```\n\n## Batch Video Processing\n\n### Process Multiple Videos\n\n```javascript\nimport ZAI from 'z-ai-web-dev-sdk';\n\nclass VideoBatchProcessor {\n  constructor() {\n    this.zai = null;\n  }\n\n  async initialize() {\n    this.zai = await ZAI.create();\n  }\n\n  async processVideo(videoUrl, prompt) {\n    const response = await this.zai.chat.completions.createVision({\n      messages: [\n        {\n          role: 'user',\n          content: [\n            { type: 'text', text: prompt },\n            { type: 'video_url', video_url: { url: videoUrl } }\n          ]\n        }\n      ],\n      thinking: { type: 'disabled' }\n    });\n\n    return response.choices[0]?.message?.content;\n  }\n\n  async processBatch(videoUrls, prompt) {\n    const results = [];\n    \n    for (const videoUrl of videoUrls) {\n      try {\n        console.log(`Processing: ${videoUrl}`);\n        const result = await this.processVideo(videoUrl, prompt);\n        results.push({ videoUrl, success: true, result });\n        \n        \u002F\u002F Add delay to avoid rate limiting\n        await new Promise(resolve => setTimeout(resolve, 1000));\n      } catch (error) {\n        results.push({ \n          videoUrl, \n          success: false, \n          error: error.message \n        });\n      }\n    }\n\n    return results;\n  }\n}\n\n\u002F\u002F Usage\nconst processor = new VideoBatchProcessor();\nawait processor.initialize();\n\nconst videos = [\n  'https:\u002F\u002Fexample.com\u002Fvideo1.mp4',\n  'https:\u002F\u002Fexample.com\u002Fvideo2.mp4',\n  'https:\u002F\u002Fexample.com\u002Fvideo3.mp4'\n];\n\nconst results = await processor.processBatch(\n  videos,\n  'Provide a brief summary of this video suitable for a content catalog'\n);\n```\n\n## Best Practices\n\n### 1. Video Preparation\n- Use standard video formats (MP4, MOV, AVI)\n- Ensure videos are accessible via public URLs or properly encoded\n- For long videos, consider creating shorter clips for specific analysis\n- Optimize video size for faster processing\n- Ensure good lighting and audio quality in source videos\n\n### 2. Prompt Engineering for Videos\n- Be specific about temporal aspects (\"beginning\", \"throughout\", \"at the end\")\n- Mention what type of analysis you need (actions, events, scenes, etc.)\n- For long videos, ask for summaries or key moments\n- Use thinking mode for complex temporal reasoning\n- Specify if you need chronological or thematic organization\n\n### 3. Error Handling\n\n```javascript\nasync function safeVideoAnalysis(videoUrl, prompt) {\n  try {\n    const zai = await ZAI.create();\n    \n    const response = await zai.chat.completions.createVision({\n      messages: [\n        {\n          role: 'user',\n          content: [\n            { type: 'text', text: prompt },\n            { type: 'video_url', video_url: { url: videoUrl } }\n          ]\n        }\n      ],\n      thinking: { type: 'disabled' }\n    });\n\n    return {\n      success: true,\n      content: response.choices[0]?.message?.content\n    };\n  } catch (error) {\n    console.error('Video analysis error:', error);\n    return {\n      success: false,\n      error: error.message\n    };\n  }\n}\n```\n\n### 4. Performance Optimization\n- Cache SDK instance for batch processing\n- Implement request throttling (add delays between requests)\n- Process videos asynchronously when possible\n- For very long videos, consider analyzing at specific intervals\n- Use appropriate thinking mode (disabled for simple descriptions, enabled for complex analysis)\n\n### 5. Security Considerations\n- Validate video URLs before processing\n- Implement rate limiting for public APIs\n- Sanitize user-provided video URLs\n- Never expose SDK credentials in client-side code\n- Implement content moderation for user-uploaded videos\n- Consider video file size limits\n\n## Common Use Cases\n\n1. **Content Moderation**: Automatically review video uploads for policy compliance\n2. **Video Cataloging**: Generate descriptions and tags for video libraries\n3. **Sports Analysis**: Analyze games, identify plays, assess performance\n4. **Educational Content**: Summarize lectures, create study guides\n5. **Security & Surveillance**: Detect events, track activities (with appropriate authorization)\n6. **Quality Control**: Assess video production quality\n7. **Social Media**: Generate video captions and descriptions\n8. **Training & Documentation**: Analyze training videos, create documentation\n9. **Event Recording**: Summarize meetings, conferences, presentations\n10. **Entertainment**: Analyze films, shows for content, themes, scenes\n\n## Integration Examples\n\n### Express.js API Endpoint\n\n```javascript\nimport express from 'express';\nimport ZAI from 'z-ai-web-dev-sdk';\n\nconst app = express();\napp.use(express.json());\n\nlet zaiInstance;\n\nasync function initZAI() {\n  zaiInstance = await ZAI.create();\n}\n\n\u002F\u002F Analyze video from URL\napp.post('\u002Fapi\u002Fanalyze-video', async (req, res) => {\n  try {\n    const { videoUrl, prompt } = req.body;\n\n    if (!videoUrl || !prompt) {\n      return res.status(400).json({ \n        error: 'videoUrl and prompt are required' \n      });\n    }\n\n    const response = await zaiInstance.chat.completions.createVision({\n      messages: [\n        {\n          role: 'user',\n          content: [\n            { type: 'text', text: prompt },\n            { type: 'video_url', video_url: { url: videoUrl } }\n          ]\n        }\n      ],\n      thinking: { type: 'disabled' }\n    });\n\n    res.json({\n      success: true,\n      analysis: response.choices[0]?.message?.content\n    });\n  } catch (error) {\n    res.status(500).json({\n      success: false,\n      error: error.message\n    });\n  }\n});\n\n\u002F\u002F Get video summary\napp.post('\u002Fapi\u002Fvideo-summary', async (req, res) => {\n  try {\n    const { videoUrl } = req.body;\n\n    if (!videoUrl) {\n      return res.status(400).json({ error: 'videoUrl is required' });\n    }\n\n    const prompt = 'Provide a comprehensive summary of this video including: 1) Main content\u002Ftopic, 2) Key events in chronological order, 3) Important people or subjects, 4) Overall takeaway.';\n\n    const response = await zaiInstance.chat.completions.createVision({\n      messages: [\n        {\n          role: 'user',\n          content: [\n            { type: 'text', text: prompt },\n            { type: 'video_url', video_url: { url: videoUrl } }\n          ]\n        }\n      ],\n      thinking: { type: 'enabled' }\n    });\n\n    res.json({\n      success: true,\n      summary: response.choices[0]?.message?.content\n    });\n  } catch (error) {\n    res.status(500).json({\n      success: false,\n      error: error.message\n    });\n  }\n});\n\ninitZAI().then(() => {\n  app.listen(3000, () => {\n    console.log('Video understanding API running on port 3000');\n  });\n});\n```\n\n### Next.js API Route\n\n```javascript\n\u002F\u002F pages\u002Fapi\u002Fvideo-understand.js\nimport ZAI from 'z-ai-web-dev-sdk';\n\nlet zaiInstance = null;\n\nasync function getZAI() {\n  if (!zaiInstance) {\n    zaiInstance = await ZAI.create();\n  }\n  return zaiInstance;\n}\n\nexport default async function handler(req, res) {\n  if (req.method !== 'POST') {\n    return res.status(405).json({ error: 'Method not allowed' });\n  }\n\n  try {\n    const { videoUrl, prompt, enableThinking = false } = req.body;\n\n    if (!videoUrl || !prompt) {\n      return res.status(400).json({ \n        error: 'videoUrl and prompt are required' \n      });\n    }\n\n    const zai = await getZAI();\n\n    const response = await zai.chat.completions.createVision({\n      messages: [\n        {\n          role: 'user',\n          content: [\n            { type: 'text', text: prompt },\n            { type: 'video_url', video_url: { url: videoUrl } }\n          ]\n        }\n      ],\n      thinking: { type: enableThinking ? 'enabled' : 'disabled' }\n    });\n\n    res.status(200).json({\n      success: true,\n      analysis: response.choices[0]?.message?.content\n    });\n  } catch (error) {\n    console.error('Error:', error);\n    res.status(500).json({\n      success: false,\n      error: error.message\n    });\n  }\n}\n```\n\n## Troubleshooting\n\n**Issue**: \"SDK must be used in backend\"\n- **Solution**: Ensure z-ai-web-dev-sdk is only imported and used in server-side code, never in client\u002Fbrowser code\n\n**Issue**: Video not loading or being analyzed\n- **Solution**: Verify the video URL is accessible, returns correct MIME type, and is in a supported format\n\n**Issue**: Inaccurate temporal analysis\n- **Solution**: Enable thinking mode for complex temporal reasoning, provide more specific prompts about time\u002Fsequence\n\n**Issue**: Slow response times for videos\n- **Solution**: Videos take longer to process than images; consider shorter clips or sampling for long videos\n\n**Issue**: Missing details from video\n- **Solution**: Be more specific in your prompt, ask about particular time segments or aspects\n\n**Issue**: Video format not supported\n- **Solution**: Convert video to MP4 (most widely supported), check that URL returns proper video MIME type\n\n## Remember\n\n- Always use z-ai-web-dev-sdk in backend code only\n- The SDK is already installed - import as shown in examples\n- Use `video_url` content type for video files\n- Video analysis takes longer than image analysis - be patient\n- Enable thinking mode for complex temporal reasoning and event detection\n- Structure prompts to include temporal information (beginning, middle, end)\n- Handle errors gracefully in production\n- Implement rate limiting and delays for batch processing\n- Validate and sanitize user inputs\n- Consider privacy and security when processing user videos\n- For very long videos, consider analyzing specific segments or key frames\n",{"name":5,"license":14,"description":7},"main","9dadc89cfa047e1ab6a783afb806ff1a1d591a51","skills\u002Fvideo-understand","https:\u002F\u002Fgithub.com\u002Fsy220284\u002F999","https:\u002F\u002Fgithub.com\u002Fsy220284","2026-10-30 12:27:48",{"source":8,"skillName":5,"commands":31,"prompt":41,"zipAvailable":42},[32,35,38],{"tool":33,"command":34},"npx","npx skills add sy220284\u002F999 --skill video-understand",{"tool":36,"command":37},"bunx","bunx skills add sy220284\u002F999 --skill video-understand",{"tool":39,"command":40},"pnpm","pnpm dlx skills add sy220284\u002F999 --skill video-understand","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fsy220284\u002F999\u002Fblob\u002Fmain\u002Fskills\u002Fvideo-understand\u002FSKILL.md",true,[44,49],{"path":45,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":48,"sourceHtmlUrl":15},"LICENSE.txt","LICENSE","许可证",1080,{"path":50,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":53,"sourceHtmlUrl":54},"scripts\u002Fvideo-understand.ts","SCRIPT","脚本",1047,"https:\u002F\u002Fgithub.com\u002Fsy220284\u002F999\u002Fblob\u002Fmain\u002Fskills\u002Fvideo-understand\u002Fscripts\u002Fvideo-understand.ts",[56,64,72,80,88,96],{"skillNo":57,"name":58,"nameZh":6,"description":59,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":60,"sourceHtmlUrl":61,"categories":62,"keywords":63,"publishedAt":19},"01M7D4SEEQEMV92N2Z6E6R20QA","zone-of-proximal-development","在当前对话中按用户解题思路逐步提示。用户提交题目并说“带我做”“先给提示别给答案”“看看卡在哪”，或接受当前题目的带练邀请时使用。常规练习答错、表示不会或解析后仍不懂时可邀请，未同意不切换。普通出题、原题批量导入、直接要答案、最近发展区理论问答不自动进入带练；不替代原测验评分与复习记录。","https:\u002F\u002Fgithub.com\u002Fsy220284\u002F999\u002Fblob\u002Fmain\u002Fskills\u002Fzone-of-proximal-development\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fsy220284\u002F999\u002Fblob\u002Fmain\u002Fskills\u002Fzone-of-proximal-development\u002FSKILL.md",[],[],{"skillNo":65,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":68,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":19},"01M7D4S2MMW0A1GSBTVJKERMT3","web-search","Implement web search capabilities using the z-ai-web-dev-sdk. Use this skill when the user needs to search for real-time information from the web, retrieve up-to-date content beyond the knowledge cutoff, or find the latest news and data. Returns structured search results with URLs, snippets, and metadata.","https:\u002F\u002Fgithub.com\u002Fsy220284\u002F999\u002Fblob\u002Fmain\u002Fskills\u002Fweb-search\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fsy220284\u002F999\u002Fblob\u002Fmain\u002Fskills\u002Fweb-search\u002FSKILL.md",[],[],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":76,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":19},"01M7D4RVQCWXDZZN4B7BEKVTME","web-reader","Implement web page content extraction capabilities using the z-ai-web-dev-sdk. Use this skill when the user needs to scrape web pages, extract article content, retrieve page metadata, or build applications that process web content. Supports automatic content extraction with title, HTML, and publication time retrieval.","https:\u002F\u002Fgithub.com\u002Fsy220284\u002F999\u002Fblob\u002Fmain\u002Fskills\u002Fweb-reader\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fsy220284\u002F999\u002Fblob\u002Fmain\u002Fskills\u002Fweb-reader\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":84,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":19},"01M7D4RSDG1WJ11D9A6E3G7KR3","web-page-fetch","通过清言serp-moe网页读取入口获取已知公开网页正文；用于法律来源原文核对和用户提供的公开网页，不用于搜索、登录后页面、用户上传文件或附件下载地址。","https:\u002F\u002Fgithub.com\u002Fsy220284\u002F999\u002Fblob\u002Fmain\u002Fskills\u002Fweb-page-fetch\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fsy220284\u002F999\u002Fblob\u002Fmain\u002Fskills\u002Fweb-page-fetch\u002FSKILL.md",[],[],{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":92,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":19},"01M7D4R7ZXWXNJ9X2G9REGBD42","Video Generation","Implement AI-powered video generation capabilities using the z-ai-web-dev-sdk. Use this skill when the user needs to generate videos from text prompts or images, create video content programmatically, or build applications that produce video outputs. Supports asynchronous task management with status polling and result retrieval.","https:\u002F\u002Fgithub.com\u002Fsy220284\u002F999\u002Fblob\u002Fmain\u002Fskills\u002Fvideo-generation\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fsy220284\u002F999\u002Fblob\u002Fmain\u002Fskills\u002Fvideo-generation\u002FSKILL.md",[],[],{"skillNo":97,"name":98,"nameZh":6,"description":99,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":100,"licenseFileUrl":101,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":19},"01M7D4PRVBZ85Z6TWA7ZEYYXJX","skill-creator","Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fsy220284\u002F999\u002Fblob\u002Fmain\u002Fskills\u002Fskill-creator\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fsy220284\u002F999\u002Fblob\u002Fmain\u002Fskills\u002Fskill-creator\u002FSKILL.md",[],[]]