TensorsLab Video Generation
Overview
This skill enables AI-powered video generation through TensorsLab's API, supporting both text-to-video and image-to-video workflows. Video generation is a time-intensive process - tasks typically take several minutes to complete.
Authentication Check
Before any video generation, verify the API key is configured:
CODEBLOCK0
If not set, display this friendly message:
CODEBLOCK1
Models
| Model | Description | Best For | Max Duration |
|---|
| seedancev2 | Latest, highest quality | General purpose, cinematic content | 15s |
| seedancev15pro |
Pro quality | High-end productions | 10s |
|
seedancev1profast | Fast generation | Quick previews | 10s |
|
seedancev1 | Standard lite | Basic videos | 10s |
Default: INLINECODE0
Workflow
1. Text-to-Video Generation
User request: "做一段 10 秒钟横屏的宇宙飞船穿梭星际的视频"
Agent processing:
- 1. Extract parameters:
duration=10, INLINECODE2 - Enhance prompt with cinematic details, camera movements, scene descriptions
- Call API with enriched prompt
- Monitor progress with heartbeat updates (every 60 seconds)
- Download to INLINECODE3
Example enhanced prompt:
CODEBLOCK2
2. Image-to-Video Generation
User request: "让这张人物合影 family.jpg 动起来" or "让风景照动起来"
Agent processing:
- 1. Extract image file paths (1-2 images supported)
- Enhance prompt with motion instructions
- Monitor progress with heartbeat updates
- Download results
Parameters for image-to-video:
- -
sourceImage: Array of image files (1-2 images max) - INLINECODE5 : Comma-separated URLs of source images
- INLINECODE6 : Description of desired motion/animation
3. Resolution and Aspect Ratio
Aspect ratios:
- -
9:16 - Vertical (TikTok, Reels, Shorts) - default - INLINECODE8 - Horizontal (YouTube, standard video)
- Other ratios available depending on model
Resolutions:
- -
480p - SD quality, faster generation - INLINECODE10 - HD quality - default
- INLINECODE11 - Full HD
- INLINECODE12 - 2K quality (seedancev2 only)
4. Duration Options
- - seedancev2: 5-15 seconds
- Other models: 5-10 seconds
Longer videos take proportionally more time to generate.
5. Special Features (seedancev2 only)
| Feature | Parameter | Description |
|---|
| Audio Generation | INLINECODE13 | Generate soundtrack with video |
| Last Frame |
return_last_frame=1 | Also return final frame as image |
Progress Tracking
Video generation takes several minutes. Keep users informed:
CODEBLOCK3
Heartbeat interval: Print encouraging message every 60 seconds.
Using the Script
依赖:脚本需要 requests 库,首次使用前执行:
CODEBLOCK4
Execute the Python script directly:
CODEBLOCK5
Task Status Flow
| Status | Code | Meaning |
|---|
| Pending | 1 | Task waiting in queue |
| Processing |
2 | Currently generating |
| Completed | 3 | Done, video ready |
| Failed | 4 | Error occurred |
| Uploading | 5 | Uploading generated video |
Error Handling
Translate API errors to user-friendly messages:
| Error Code | Meaning | User Message |
|---|
| 9000 | Insufficient credits | "亲,积分用完啦,请前往 https://tensorslab.tensorslab.com/ 充值" |
| 9999 |
General error | Show the specific error message |
Output
All videos are saved to output directory with naming pattern:
- - Default:
./tensorslab_output/ (current working directory) - Custom: Use
--output-dir or -o to specify a different path - Naming:
{task_id}_{index}.mp4 - e.g., INLINECODE20
After completion, inform user:
CODEBLOCK6
Tips for Better Results
Text-to-Video
- - Include cinematic terms: "wide shot", "close-up", "pan", "dolly"
- Describe motion: "flying rapidly", "slowly drifting", "zooming in"
- Specify style: "cinematic", "documentary style", "dreamy"
Image-to-Video
- - Describe the desired motion: "gentle sway", "subtle movement"
- For landscapes: "clouds moving", "water flowing", "leaves rustling"
Resources
- - scripts/tensorslabvideo.py: Main API client with full CLI support
- references/apireference.md: Detailed API documentation
TensorsLab 视频生成
概述
此技能通过 TensorsLab 的 API 实现 AI 驱动的视频生成,支持文本转视频和图像转视频两种工作流程。视频生成是一个耗时较长的过程——任务通常需要几分钟才能完成。
身份验证检查
在任何视频生成之前,请确认 API 密钥已配置:
bash
仅检查变量是否存在,不输出完整值
[ -n $TENSORSLAB
APIKEY ] && echo ✅ API 密钥已设置 || echo ❌ TENSORSLAB
APIKEY 未设置
如果未设置,请显示以下友好提示:
您好!要生成高质量的内容,您需要先进行简单的配置:
- 1. 访问 https://tensorslab.tensorslab.com/ 登录并订阅。
- 在控制台中获取您的专属 API Key。
- 将其保存为环境变量:
- Windows (PowerShell): $env:TENSORSLAB
APIKEY=您的Key
- Mac/Linux: export TENSORSLAB
APIKEY=您的Key
模型
| 模型 | 描述 | 最佳用途 | 最大时长 |
|---|
| seedancev2 | 最新、最高质量 | 通用用途、电影级内容 | 15秒 |
| seedancev15pro |
专业质量 | 高端制作 | 10秒 |
|
seedancev1profast | 快速生成 | 快速预览 | 10秒 |
|
seedancev1 | 标准精简版 | 基础视频 | 10秒 |
默认值:seedancev1profast
工作流程
1. 文本转视频生成
用户请求:做一段 10 秒钟横屏的宇宙飞船穿梭星际的视频
智能体处理流程:
- 1. 提取参数:duration=10,ratio=16:9
- 使用电影级细节、镜头运动、场景描述增强提示词
- 使用增强后的提示词调用 API
- 通过心跳更新监控进度(每 60 秒)
- 下载至 ./tensorslab_output/
增强提示词示例:
电影级广角镜头,宇宙飞船在太空中快速飞行,掠过发光的星云和遥远的恒星,
镜头光晕,戏剧性的镜头运动,史诗般的规模,电影级视觉效果,流畅的24fps运动
2. 图像转视频生成
用户请求:让这张人物合影 family.jpg 动起来 或 让风景照动起来
智能体处理流程:
- 1. 提取图像文件路径(支持 1-2 张图像)
- 使用运动指令增强提示词
- 通过心跳更新监控进度
- 下载结果
图像转视频参数:
- - sourceImage:图像文件数组(最多 1-2 张图像)
- imageUrl:源图像的逗号分隔 URL
- prompt:所需运动/动画的描述
3. 分辨率和宽高比
宽高比:
- - 9:16 - 竖屏(TikTok、Reels、Shorts) - 默认
- 16:9 - 横屏(YouTube、标准视频)
- 其他宽高比取决于模型
分辨率:
- - 480p - 标清画质,生成速度更快
- 720p - 高清画质 - 默认
- 1080p - 全高清
- 1440p - 2K 画质(仅限 seedancev2)
4. 时长选项
- - seedancev2:5-15 秒
- 其他模型:5-10 秒
较长的视频生成时间相应增加。
5. 特殊功能(仅限 seedancev2)
| 功能 | 参数 | 描述 |
|---|
| 音频生成 | generateaudio=1 | 随视频生成配乐 |
| 最后一帧 |
returnlast_frame=1 | 同时返回最终帧作为图像 |
进度追踪
视频生成需要几分钟时间。请让用户了解进度:
⏳ 等待视频生成完成...
(这可能需要几分钟,请耐心等待)
🔄 状态:处理中(已耗时:45秒)
🚀 正在渲染电影级大片,已耗时 60 秒,请稍安勿躁...
🚀 正在渲染电影级大片,已耗时 120 秒,请稍安勿躁...
✅ 任务完成!
心跳间隔: 每 60 秒打印一条鼓励信息。
使用脚本
依赖:脚本需要 requests 库,首次使用前执行:
bash
pip install requests
直接执行 Python 脚本:
bash
文本转视频(默认5秒,竖屏9:16)
python scripts/tensorslab_video.py 宇宙飞船在太空中飞行
10秒横屏视频
python scripts/tensorslab_video.py 海面上的日落 --duration 10 --ratio 16:9
图像转视频
python scripts/tensorslab_video.py 让这张照片动起来 --source portrait.jpg
快速预览
python scripts/tensorslab_video.py 抽象的流动色彩 --model seedancev1profast
高质量带音频
python scripts/tensorslab_video.py 史诗级山脉延时摄影 --resolution 1440p --duration 10 --audio
自定义输出目录
python scripts/tensorslab
video.py 日落延时摄影 --output-dir ./myvideos
任务状态流程
2 | 正在生成 |
| 已完成 | 3 | 完成,视频已就绪 |
| 失败 | 4 | 发生错误 |
| 上传中 | 5 | 正在上传生成的视频 |
错误处理
将 API 错误转换为用户友好的消息:
| 错误代码 | 含义 | 用户消息 |
|---|
| 9000 | 积分不足 | 亲,积分用完啦,请前往 https://tensorslab.tensorslab.com/ 充值 |
| 9999 |
一般错误 | 显示具体的错误信息 |
输出
所有视频均保存至输出目录,命名规则如下:
- - 默认:./tensorslaboutput/(当前工作目录)
- 自定义:使用 --output-dir 或 -o 指定不同路径
- 命名:{taskid}{index}.mp4 - 例如:abcd1234567890_0.mp4
完成后,通知用户:
🎉 您的视频处理完毕!已存放于 ./tensorslab_output/{filename}
获得更好效果的技巧
文本转视频
- - 包含电影术语:广角镜头、特写、平移、推轨
- 描述运动:快速飞行、缓慢漂移、放大
- 指定风格:电影级、纪录片风格、梦幻
图像转视频
- - 描述所需的运动:轻柔摆动、细微移动
- 对于风景:云层移动、水流、树叶沙沙作响
资源
- - scripts/tensorslabvideo.py:主 API 客户端,支持完整 CLI
- references/apireference.md:详细 API 文档