ai-video
Overview
Use this skill to turn OpenAPI definitions into working video-generation API calls for
skills.video.
Prefer deterministic extraction from
openapi.json instead of guessing fields.
Prerequisites
- 1. Obtain an API key at: INLINECODE2
- Configure
SKILLS_VIDEO_API_KEY before using the skill.
Preferred OpenClaw setup:
- - Open the skill settings for INLINECODE4
- Add an environment variable named INLINECODE5
- Paste the API key as its value
Equivalent config shape:
CODEBLOCK0
Other valid ways to provide the key:
- - Shell: INLINECODE6
- Tool-specific env config: any runtime that injects INLINECODE7
Workflow
- 1. Check API key and bootstrap environment on first use.
- Identify the active spec.
- Select the SSE endpoint pair for a video model.
- Extract request schema and generate a payload template.
- Execute
POST /generation/sse/... as default and keep the stream open. - If SSE does not reach terminal completion, poll
GET /generation/{id} to terminal status. - Return only terminal result (
COMPLETED/SUCCEEDED/FAILED/CANCELED), never IN_PROGRESS. - Apply retry and failure handling.
0) Check API key (first run)
Run this check before any API call.
CODEBLOCK1
If ok is false, tell the user to:
- - Follow the setup in INLINECODE17
Example:
CODEBLOCK2
1) Identify the spec
Load the most specific OpenAPI first.
- - Prefer model-specific OpenAPI when available (for example
/v1/openapi.json under a model namespace). - Fall back to platform-level
openapi.json. - Use
references/open-platform-api.md for base URL, auth, and async lifecycle.
2) Select a video endpoint
If
docs.json exists, derive video endpoints from the
Videos navigation group.
Use
default_endpoints from the script output as the primary list (SSE first).
CODEBLOCK3
When docs.json is unavailable, pass a known endpoint directly (for example /generation/sse/kling-ai/kling-v2.6).
Use references/video-model-endpoints.md as a snapshot list.
3) Extract schema and build payload
Inspect endpoint details and generate a request template from required/default fields.
CODEBLOCK4
Use the returned request_template as the starting point.
Do not add fields not defined by the endpoint schema.
Use default_create_endpoint from output unless an explicit override is required.
4) Execute SSE request (default) with automatic fallback
Prefer the helper script. It creates via SSE and keeps streaming; if stream ends before terminal completion, it automatically switches to polling fallback.
CODEBLOCK5
Treat SSE as the default result channel.
Do not finish the task on IN_QUEUE or IN_PROGRESS.
Return only after terminal result.
5) Fall back to polling
Use polling only if SSE cannot be established, disconnects early, or does not reach a terminal state.
Use
GET /generation/{id} (or model-spec equivalent path if the OpenAPI uses
/v1/...).
CODEBLOCK6
Stop polling on terminal states:
- - INLINECODE33
- INLINECODE34
- INLINECODE35
Recommended helper:
CODEBLOCK7
Return to user only after helper emits event=terminal.
6) Handle errors and retries
Handle these response codes for create, SSE, and fallback poll operations:
- -
400: request format issue - INLINECODE38 : missing/invalid API key
- INLINECODE39 : possible payment/credits issue in runtime
- INLINECODE40 : endpoint or generation id not found
- INLINECODE41 : schema validation failed
Classify non-2xx runtime errors with:
CODEBLOCK8
If category is insufficient_credits, tell the user to recharge:
- - Open
https://skills.video/dashboard and go to Billing/Credits - Recharge or purchase additional credits
- Retry after recharge
Optional balance check:
CODEBLOCK9
Apply retries only for transient conditions (network failure or temporary 5xx).
Use bounded exponential backoff (for example 1s, 2s, 4s, max 16s, then fail).
Do not retry unchanged payloads after 4xx validation errors.
Rate limits and timeouts
Treat rate limits and server-side timeout windows as unknown unless documented in the active OpenAPI or product docs.
If unknown, explicitly note this in output and choose conservative client defaults.
Resources
- -
scripts/ensure_api_key.py: validate SKILLS_VIDEO_API_KEY and show first-run setup guidance - INLINECODE52 : classify runtime errors and provide recharge guidance for insufficient credits
- INLINECODE53 : extract SSE/polling endpoint pair, contract, and payload template
- INLINECODE54 : create via SSE and auto-fallback to polling when stream does not reach terminal status
- INLINECODE55 : poll generation status until terminal completion and return final response
- INLINECODE56 : SSE-first lifecycle, fallback polling, retry baseline
- INLINECODE57 : current video endpoint snapshot from INLINECODE58
ai-video
概述
使用此技能可将OpenAPI定义转换为skills.video可用的视频生成API调用。
优先从openapi.json中确定性提取字段,而非猜测字段。
前置条件
- 1. 在以下地址获取API密钥:https://skills.video/dashboard/developer
- 使用技能前配置SKILLSVIDEOAPI_KEY。
推荐的OpenClaw配置方式:
- - 打开ai-video的技能设置
- 添加名为SKILLSVIDEOAPI_KEY的环境变量
- 将API密钥粘贴为其值
等效配置格式:
json
{
skills: {
entries: {
ai-video: {
enabled: true,
env: {
SKILLSVIDEOAPIKEY: yourapikeyhere
}
}
}
}
}
其他有效的密钥提供方式:
- - Shell:export SKILLSVIDEOAPIKEY=yourapikeyhere
- 工具特定环境配置:任何注入SKILLSVIDEOAPI_KEY的运行时环境
工作流程
- 1. 首次使用时检查API密钥并引导环境配置。
- 识别当前使用的规范。
- 选择视频模型的SSE端点对。
- 提取请求模式并生成负载模板。
- 默认执行POST /generation/sse/...并保持流连接。
- 若SSE未达到终端完成状态,轮询GET /generation/{id}直至终端状态。
- 仅返回终端结果(COMPLETED/SUCCEEDED/FAILED/CANCELED),绝不返回IN_PROGRESS。
- 应用重试和失败处理机制。
0) 检查API密钥(首次运行)
在任何API调用前执行此检查。
bash
python scripts/ensureapikey.py
若ok为false,告知用户:
示例:
bash
export SKILLSVIDEOAPIKEY=API_KEY>
1) 识别规范
优先加载最具体的OpenAPI。
- - 优先使用模型特定的OpenAPI(例如模型命名空间下的/v1/openapi.json)。
- 回退至平台级别的openapi.json。
- 使用references/open-platform-api.md获取基础URL、认证和异步生命周期信息。
2) 选择视频端点
若docs.json存在,从Videos导航组中推导视频端点。
使用脚本输出的default_endpoints作为主列表(优先SSE)。
bash
python scripts/inspect_openapi.py \
--openapi /abs/path/to/openapi.json \
--docs /abs/path/to/docs.json \
--list-endpoints
当docs.json不可用时,直接传递已知端点(例如/generation/sse/kling-ai/kling-v2.6)。
使用references/video-model-endpoints.md作为快照列表。
3) 提取模式并构建负载
检查端点详情并从必需/默认字段生成请求模板。
bash
python scripts/inspect_openapi.py \
--openapi /abs/path/to/openapi.json \
--endpoint /generation/sse/kling-ai/kling-v2.6 \
--include-template
使用返回的request_template作为起点。
不添加端点模式未定义的字段。
除非需要显式覆盖,否则使用输出中的defaultcreateendpoint。
4) 执行SSE请求(默认)并自动回退
优先使用辅助脚本。该脚本通过SSE创建并保持流连接;若流在终端完成前结束,自动切换至轮询回退。
bash
python scripts/createandwait.py \
--sse-endpoint /generation/sse/kling-ai/kling-v2.6 \
--payload {prompt:霓虹城市雨夜的电影级推轨镜头} \
--poll-timeout 900 \
--poll-interval 3
将SSE视为默认结果通道。
在INQUEUE或INPROGRESS状态下不完成任务。
仅在获得终端结果后返回。
5) 回退至轮询
仅在SSE无法建立、过早断开或未达到终端状态时使用轮询。
使用GET /generation/{id}(或OpenAPI使用/v1/...时的模型特定等效路径)。
bash
curl -X GET https://open.skills.video/api/v1/generation/ \
-H Authorization: Bearer $SKILLSVIDEOAPI_KEY
在以下终端状态时停止轮询:
- - COMPLETED
- FAILED
- CANCELED
推荐辅助脚本:
bash
python scripts/wait_generation.py \
--generation-id \
--timeout 900 \
--interval 3
仅在辅助脚本发出event=terminal后向用户返回结果。
6) 错误处理和重试
处理创建、SSE和回退轮询操作的以下响应码:
- - 400:请求格式问题
- 401:缺少/无效的API密钥
- 402:运行时可能的支付/积分问题
- 404:端点或生成ID未找到
- 422:模式验证失败
使用以下方式分类非2xx运行时错误:
bash
python scripts/handleruntimeerror.py \
--status \
--body ERRORBODYJSONOR_TEXT>
若类别为insufficient_credits,告知用户充值:
- - 打开https://skills.video/dashboard并进入计费/积分页面
- 充值或购买额外积分
- 充值后重试
可选余额检查:
bash
curl -X GET https://open.skills.video/api/v1/credits \
-H Authorization: Bearer $SKILLSVIDEOAPI_KEY
仅对瞬态条件(网络故障或临时5xx)应用重试。
使用有界指数退避(例如1s、2s、4s,最大16s,然后失败)。
在4xx验证错误后不重试未更改的负载。
速率限制和超时
除非在活跃的OpenAPI或产品文档中有说明,否则将速率限制和服务器端超时窗口视为未知。
若未知,在输出中明确注明并选择保守的客户端默认值。
资源
- - scripts/ensureapikey.py:验证SKILLSVIDEOAPIKEY并显示首次运行设置指南
- scripts/handleruntimeerror.py:分类运行时错误并为积分不足提供充值指南
- scripts/inspectopenapi.py:提取SSE/轮询端点对、契约和负载模板
- scripts/createandwait.py:通过SSE创建并在流未达到终端状态时自动回退至轮询
- scripts/wait_generation.py:轮询生成状态直至终端完成并返回最终响应
- references/open-platform-api.md:SSE优先生命周期、回退轮询、重试基线
- references/video-model-endpoints.md:来自docs.json的当前视频端点快照