ModelRouterModelRouter
⚠️合规提示:本项目仅用于合法授权的 API 网关、内部管理和私有化部署场景。请遵守上游服务条款、平台规则、监管要求和内容安全要求。
接口调用视频模型

视频通用说明

用 OpenAI 兼容的 Videos 接口调用可灵视频:提交任务、查询进度、下载视频,以及各型号参数与计费。

流程

视频生成是异步任务,分三步:

  1. POST /v1/videos 提交任务,拿到任务 id。
  2. GET /v1/videos/{id} 轮询进度,直到 status 为 completed 或 failed。
  3. GET /v1/videos/{id}/content 下载 MP4。

一条视频通常需要 1–5 分钟。建议每 10–15 秒查询一次,不要高频轮询。

所有请求都使用 Authorization: Bearer YOUR_API_KEY 认证。

提交任务

POST https://modelrouter.club/v1/videos
字段类型必填说明
modelstring是模型 ID,例如 kling-3.0
promptstring文生视频必填画面与运动描述
secondsinteger否时长(秒),默认 5,范围见下表
resolutionstring否720P 或 1080P,默认 720P
aspect_ratiostring否16:9、9:16、1:1;只对文生视频生效
sizestring否也可用 1280x720 这类尺寸代替 resolution + aspect_ratio
audioboolean否是否同步生成音频,默认 false;仅部分型号支持
input_referencestring / array图生视频必填首帧图片 URL;传两张时,第一张为首帧,第二张为尾帧
negative_promptstring否不希望出现的内容
seedinteger否随机种子
注意

首帧、尾帧只接受公网可访问的 http(s) 图片 URL,不支持上传文件或 Base64。图生视频的画面比例跟随首帧图片,此时 aspect_ratio 不生效。

各型号参数

模型 ID时长分辨率有声
kling-3.03–15 秒720P / 1080P支持
kling-3.0-omni3–15 秒720P / 1080P支持
kling-2.63–15 秒720P / 1080P仅 1080P 支持
kling-3.0-turbo3–15 秒720P / 1080P不支持
kling-o13–15 秒720P / 1080P不支持
kling-2.55 或 10 秒720P / 1080P不支持

所有型号都支持文生视频,以及首帧 / 首尾帧图生视频。

示例:文生视频

curl https://modelrouter.club/v1/videos \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kling-3.0",
    "prompt": "清晨的海边,一只柯基在沙滩上奔跑,镜头缓慢跟随",
    "seconds": 5,
    "resolution": "720P",
    "aspect_ratio": "16:9"
  }'

示例:首尾帧图生视频

curl https://modelrouter.club/v1/videos \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kling-3.0",
    "prompt": "花朵从含苞到完全绽放",
    "seconds": 5,
    "input_reference": [
      "https://example.com/first.jpg",
      "https://example.com/last.jpg"
    ]
  }'

提交成功后返回任务对象(示例结构):

{
  "id": "task_xxxxxxxx",
  "object": "video",
  "status": "queued",
  "progress": 0
}

查询进度

GET https://modelrouter.club/v1/videos/{id}
curl https://modelrouter.club/v1/videos/task_xxxxxxxx \
  -H "Authorization: Bearer YOUR_API_KEY"
{
  "id": "task_xxxxxxxx",
  "object": "video",
  "status": "completed",
  "progress": 100,
  "seconds": "5"
}
status含义
queued排队中
in_progress生成中;progress 为 0–100 的进度
completed已完成,可以下载
failed失败;error.message 给出原因,费用自动退回

失败时的响应示例:

{
  "id": "task_xxxxxxxx",
  "object": "video",
  "status": "failed",
  "progress": 100,
  "error": { "code": "task_failed", "message": "..." }
}

下载视频

GET https://modelrouter.club/v1/videos/{id}/content
curl -L https://modelrouter.club/v1/videos/task_xxxxxxxx/content \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -o video.mp4

返回 MP4 文件内容。

注意

视频约 7 天内可以下载。过期后接口返回 410,错误码为 artifact_gone,无法再取回。请在任务完成后及时下载,转存到自己的存储。

计费

  • 按秒计费,按分辨率和是否有声分档,费用为「单价 × 时长」。
  • 提交任务时按请求的时长、分辨率预扣费用;任务失败后自动全额退回。
  • 各型号的实时单价见 模型广场,更多说明见 价格说明。

常见错误

错误信息原因
prompt or input_reference is required既没有 prompt,也没有首帧图片
seconds must be an integer between 3 and 15时长超出范围
seconds must be one of 5, 10kling-2.5 只支持 5 秒或 10 秒
resolution must be one of 720P, 1080P分辨率不支持
aspect_ratio must be one of ...比例不支持
this model does not generate audio该型号不支持有声
audio requires 1080P for this modelkling-2.6 有声需要 1080P
at most two images are supported ...图片超过两张(首帧 + 尾帧)
input_reference must be an HTTP(S) URL ...图片不是 URL,或传了文件 / Base64

其他错误见 排错指南。