Genjutsu 1.0
Genjutsu 1.0 用一段源视频和 1–20 张参考图生成新视频,支持两种模式:
mode | 作用 |
|---|---|
motion_control | 动作迁移:参考图里的人物做出源视频中的动作 |
replace_object | 物体替换:把源视频中的某个物体换成参考图里的物体 |
输出分辨率支持 480p / 720p / 1080p,源视频最长 30 秒。
模型
| 模型名称 | 说明 |
|---|---|
genjutsu-1.0 | 源视频 + 参考图生成视频(动作迁移 / 物体替换) |
定价
费用 = 源视频的计费秒数 × 所选分辨率的每秒单价:
| 分辨率 | 积分/秒 | 5 秒 | 15 秒 | 30 秒 |
|---|---|---|---|---|
480p | 35.1 | 175.5 | 526.5 | 1053 |
720p | 81.9 | 409.5 | 1228.5 | 2457 |
1080p | 234 | 1170 | 3510 | 7020 |
计费秒数由服务端探测源视频时长后计算,不需要也不能由客户端传入:
motion_control:四舍五入到整秒,不足 4 秒按 4 秒计。replace_object:向上取整到整秒,源视频需为 4–30 秒。- 编码带来的几十毫秒误差不计入(例如文件显示 30.02 秒的视频按 30 秒处理)。
源视频时长探测失败(URL 无法访问或不是 MP4/MOV)、超过 30 秒,或 replace_object 短于 4 秒时,创建任务直接返回 400 错误,不扣积分。积分在创建任务时预扣,任务失败会全额退还。以上为账户倍率前价格。
创建任务
POST https://api.aivideoapi.ai/v1/videos/generations
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | genjutsu-1.0 |
input | object | 是 | 生成参数 |
callback_url | string | 否 | 接收任务完成/失败通知的 URL |
Input 参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
mode | string | 是 | motion_control 或 replace_object |
video_urls | string[] | 是 | 恰好 1 个源视频 URL。MP4/MOV,最长 30 秒;replace_object 为 4–30 秒。计费按该视频时长。 |
image_urls | string[] | 是 | 1–20 张参考图 URL,常见图片格式。 |
resolution | string | 否 | 480p、720p(默认)或 1080p,决定每秒单价。 |
prompt | string | 否 | 最长 5000 字符。可以用 @Image1…@Image20 按顺序指代 image_urls 里的图片,用 @Video1 指代源视频。 |
所有素材必须是公网可直接下载的 HTTP(S) 链接(不支持 base64 / data URL),并在任务结束前保持可访问。不支持 duration 参数:输出时长跟随源视频。
示例
动作迁移
curl -X POST https://api.aivideoapi.ai/v1/videos/generations \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "genjutsu-1.0",
"callback_url": "https://your-server.com/webhook",
"input": {
"mode": "motion_control",
"video_urls": ["https://example.com/dance.mp4"],
"image_urls": ["https://example.com/person.png"],
"resolution": "720p",
"prompt": "@Image1 跟随 @Video1 的舞蹈动作"
}
}'
物体替换(1080p)
curl -X POST https://api.aivideoapi.ai/v1/videos/generations \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "genjutsu-1.0",
"input": {
"mode": "replace_object",
"video_urls": ["https://example.com/street.mp4"],
"image_urls": ["https://example.com/red-car.png"],
"resolution": "1080p",
"prompt": "把 @Video1 中的汽车替换成 @Image1 中的红色跑车"
}
}'
响应
{
"code": 200,
"msg": "success",
"data": {
"taskId": "8b6a5162-5c91-4a42-8e80-4c8ef5486f24"
}
}
查询任务
curl https://api.aivideoapi.ai/v1/tasks/{taskId} \
-H "Authorization: Bearer sk-your-api-key"
状态变化:pending -> processing -> completed 或 failed。生成通常需要数分钟,建议优先使用 callback_url,或每 15 秒以上轮询一次。
- 成功时视频地址在
output.urls[0],链接有效期 24 小时,请及时下载保存。 - 任务失败时,预扣的积分会全额退还。
- 该模型的任务提交后不支持取消。
回调 (Callback)
创建任务时传入 callback_url,系统会在任务完成或失败时自动向你的 URL 发送 POST 请求。请求头与重试策略详见回调说明。
任务完成时回调
{
"id": "8b6a5162-5c91-4a42-8e80-4c8ef5486f24",
"status": "completed",
"model": "genjutsu-1.0",
"created_at": 1795600000,
"completed_at": 1795600240,
"output": {
"urls": [
"https://file.aivideoapi.ai/videos/2026/11/25/abc.mp4"
]
}
}
任务失败时回调
{
"id": "57c8772c-f834-46f3-9b7d-81f92e104050",
"status": "failed",
"model": "genjutsu-1.0",
"created_at": 1795600000,
"error": {
"code": "upstream_error",
"message": "The source video or a reference image could not be read. Ensure every URL is public and directly downloadable (video: MP4 or MOV)."
}
}
常见失败原因:提示词或素材不符合内容政策、源视频或参考图无法读取、源视频时长不符合要求,以及一般性的生成失败。
重要说明
- 收到回调后请尽快返回 2xx 状态码(建议 3 秒内)。返回非 2xx 或超时(10 秒)将触发重试,最多 3 次(间隔分别为 3 分钟、10 分钟)。
- 业务侧应根据
X-Task-Id做幂等处理,避免同一任务重复入库。 - 任务最终状态以
GET /v1/tasks/{taskId}查询为准;如果 3 次回调都失败,仍可主动轮询兜底。
常见错误码
请求失败时,API 返回 JSON 格式的错误响应:
{
"error": {
"code": "insufficient_credits",
"message": "Your credit balance is too low. Please top up.",
"type": "billing_error"
}
}
错误码一览
| HTTP 状态码 | 错误码 | 类型 | 说明 |
|---|---|---|---|
| 400 | invalid_request | invalid_request_error | 缺少必填参数或参数无效 |
| 401 | invalid_api_key | authentication_error | API Key 无效、已禁用或已删除 |
| 402 | insufficient_credits | billing_error | 积分余额不足,请充值 |
| 403 | ip_not_allowed | permission_error | 请求 IP 不在 Key 的白名单中 |
| 404 | model_not_found | invalid_request_error | 模型不存在或已停用 |
| 404 | task_not_found | invalid_request_error | 任务 ID 不存在 |
| 429 | rate_limit_exceeded | rate_limit_error | 请求过于频繁,请降低频率 |
| 429 | spend_limit_exceeded | billing_error | 达到 Key 的消费限额(每小时/每天/总量) |
| 500 | internal_error | api_error | 服务器内部错误 |
| 503 | upstream_error | upstream_error | 上游 AI 服务返回错误 |
常见场景
invalid_request (400)
缺少必填字段或参数格式错误时返回。
{
"error": {
"code": "invalid_request",
"message": "'model' is required.",
"type": "invalid_request_error"
}
}
insufficient_credits (402)
积分不足。可通过 GET /v1/credits 查询余额,前往 Dashboard > Billing 充值。
invalid_api_key (401)
可能原因:
- Key 不以
sk-开头 - Key 已被禁用或删除
- 用户账户已被封禁
upstream_error (503)
上游 AI 服务返回错误,可能原因:
- 输入内容包含敏感或违规信息
- 上游服务暂时不可用
- 请求参数不被上游支持
因上游错误导致任务失败时,预扣积分会自动退还。