ModelSite

视频生成

POST /v1/videos/generations — 异步视频生成,完全兼容各厂商原生参数

视频生成是异步的,分三步:创建任务 → 轮询状态 → 下载内容。

POST /v1/videos/generations — 提交任务,立即返回 idstatus: "processing"

GET /v1/videos/{video_id} — 轮询状态,直到 status 变成 completedfailed

GET /v1/videos/{video_id}/content — 下载视频二进制(或直接用响应里的 output_url

视频生成通常耗时 30 秒到数分钟,取决于模型和时长。建议轮询间隔 5-10 秒,不要更密。id 是不透明加密令牌,内含 provider / model / 时长信息,请原样回传,不要解析或截断。

完整示例

示例中的模型名(如 wan2.5-t2v-preview)仅作演示。你账户实际可用的视频模型以 模型页GET /v1/models 返回的列表为准 —— 取决于平台已为你开通哪些上游。下文的原厂参数对任何视频模型都适用。

import time, requests

BASE = "https://api.modelsite.ai/v1"
H = {"Authorization": "Bearer ms_live_sk_xxx", "Content-Type": "application/json"}

# 1. 创建任务
job = requests.post(f"{BASE}/videos/generations", headers=H, json={
"model": "wan2.5-t2v-preview",
"prompt": "A cat playing piano on a rooftop at sunset",
"seconds": 5,
"size": "1280x720",
}).json()
video_id = job["id"]

# 2. 轮询
while True:
v = requests.get(f"{BASE}/videos/{video_id}", headers=H).json()
if v["status"] in ("completed", "failed"):
    break
time.sleep(5)

if v["status"] == "failed":
raise RuntimeError(v["error"]["message"])

# 3. 下载
mp4 = requests.get(f"{BASE}/videos/{video_id}/content", headers=H).content
open("out.mp4", "wb").write(mp4)

下面的接口卡片由 OpenAPI 规范自动渲染(Request body 参数表、Response schema)。

POST
/videos/generations

Authorization

BearerAuth
AuthorizationBearer <token>

Authorization: Bearer $MODELSITE_API_KEY

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

标准跨厂商字段。除此之外的任何顶层字段都作为上游原生参数原样透传。

Response Body

application/json

application/json

curl -X POST "https://example.com/videos/generations" \  -H "Content-Type: application/json" \  -d '{    "model": "string",    "prompt": "string"  }'
{  "id": "string",  "object": "video",  "status": "processing",  "model": "string",  "seconds": 0,  "created_at": 0,  "completed_at": 0,  "output_url": "string",  "usage": {    "completion_tokens": 0,    "total_tokens": 0  },  "error": {    "code": "string",    "message": "string"  },  "vendor_data": {}}
GET
/videos/{video_id}

Authorization

BearerAuth
AuthorizationBearer <token>

Authorization: Bearer $MODELSITE_API_KEY

In: header

Path Parameters

video_id*string

创建任务时返回的 id(不透明加密令牌,内含 provider / model / 时长,请原样回传)。

Response Body

application/json

curl -X GET "https://example.com/videos/video_ual7J0gEbKHcrUcqI7nV7wkR6_V57Y_vlasce6jMjWOSfTKbgVcoIhA5"
{  "id": "string",  "object": "video",  "status": "processing",  "model": "string",  "seconds": 0,  "created_at": 0,  "completed_at": 0,  "output_url": "string",  "usage": {    "completion_tokens": 0,    "total_tokens": 0  },  "error": {    "code": "string",    "message": "string"  },  "vendor_data": {}}
GET
/videos/{video_id}/content

Authorization

BearerAuth
AuthorizationBearer <token>

Authorization: Bearer $MODELSITE_API_KEY

In: header

Path Parameters

video_id*string

创建任务时返回的 id

Response Body

video/mp4

curl -X GET "https://example.com/videos/string/content"
"string"

原厂参数完全兼容

上表的标准字段只是跨厂商的公共子集。上游厂商接受的任何参数,都可以按原厂参数名直接写在请求体顶层,原样透传,不需要任何包装、也不需要等平台加字段支持。

{
  "model": "veo-3.0-generate-001",
  "prompt": "A cat playing piano",
  "seconds": 8,
  "sampleCount": 2,
  "personGeneration": "dont_allow",
  "storageUri": "gs://my-bucket/output/"
}

三条规则:

  • 原生参数名优先。同时传标准字段和原生字段时,原生字段胜出。例如 {"seconds": 8, "durationSeconds": 4} 发给上游的是 4 —— 你写原生参数就是要精确控制,翻译层让位。
  • 每个模型只接受自己厂商的参数。传了属于其他厂商的参数会被拒绝并返回 400 —— 例如给 DashScope(wan)模型传 Seedance 的 camera_fixed、或给 Veo 模型传 Sora 的 n_seconds。请按你实际调用的模型所属厂商查阅下方参数。跨厂商通用的参数(durationseedsizeresolutionnegative_prompt 等)不受此限制。
  • 嵌套结构递归合并。如 Nova Reel 的 videoGenerationConfig: {"fps": 30} 会与标准字段翻译出的 durationSeconds / dimension 合并,而不是整体覆盖。

响应侧同样零损耗:上游返回的所有非标准字段都保留在 vendor_data 里,包括本文档尚未收录的新字段。

各厂商原生参数名要点

同一个概念在各厂商的参数名和类型经常不同。用标准字段时平台自动翻译;写原生参数时必须用下表的原厂名字

厂商时长尺寸宽高比其他注意
DashScope(wan 系)durationsize星号分隔 1280*720ratio原生 media[]frame_images追加关系
ModelArk(Seedance)duration-1 = 模型自决,仅 1.5 pro)ratio原生 content[] 非空时整体取代派生结果;frames 优先于 duration
Vertex AI(Veo)durationSecondsaspectRatio原生名是 camelCase;snake_case 别名也接受并自动转换
OpenAI(Sora)seconds字符串 "8"size
Azure(Sora)n_seconds整数width / height没有 size / seconds
OneRouterduration(字符串,格式随模型族变化)aspect_ratio

这些表不是白名单 —— 未列出的原厂参数同样透传。上游新增参数当天就能用,不需要等平台跟版本。

常用原生参数

Vertex AI Veo(进入请求的 parameters 对象):

参数类型说明
sampleCountinteger生成候选视频数量(1-4)
personGenerationstringallow_adult(默认)/ dont_allow / allow_all(需申请)
enhancePromptbool用 Gemini 自动增强提示词(仅 Veo 2)
compressionQualitystringoptimized(默认)/ lossless
resizeModestring图生视频缩放模式:pad(默认)/ crop(仅 Veo 3 图生视频)
storageUristring输出到指定 GCS 路径;不给则返回 base64

instance 级原生字段(last_frameinput_videomaskmask_modereference_images)会正确写进 Veo 的 instances,不会误落到 parameters

ModelArk Seedance(合并到请求顶层):

参数类型说明
camera_fixedbool固定镜头
watermarkbool添加水印
draftboolDraft 预览模式(仅 Seedance 1.5 pro)
callback_urlstring任务状态变更回调地址
contentarray原生内容块数组(text / image_url / audio_url / video_url / draft_task

DashScope wan:input 级原生参数(mediatemplatereference_urlsfirst_frame_urllast_frame_urlaudio_url 等)自动分流到请求的 input 对象,其余生成旋钮进 parameters —— 你只管写在顶层,平台负责落位。

图生视频与参考素材

两组字段用途不同,别混用:

字段语义用途
frame_images硬约束指定首帧 / 尾帧,模型必须精确还原这一帧
input_references软引导提供风格 / 构图 / 运镜参考,不要求精确还原
{
  "model": "wan2.5-i2v-preview",
  "prompt": "The cat stands up and walks away",
  "seconds": 5,
  "frame_images": [
    { "image_url": "https://example.com/first.jpg", "frame_type": "first_frame" },
    { "image_url": "https://example.com/last.jpg", "frame_type": "last_frame" }
  ],
  "input_references": [
    { "type": "video", "url": "https://example.com/motion.mp4", "role": "reference_video" }
  ]
}

各厂商对参考素材的支持差异较大,不支持的厂商会静默忽略 input_references,不报错。

尺寸参数:三种写法

sizeresolution + aspect_ratio 是等价的两种表达,选一种即可:

{ "size": "1280x720" }
{ "resolution": "720p", "aspect_ratio": "16:9" }

同时传且互相冲突时返回 400。别名 ratio(DashScope / ModelArk 的原生名)等同于 aspect_ratio

计费

视频时长计费:费用 = 时长(秒) × 该模型的每秒单价。时长取实际生成结果的秒数,任务失败不计费。单价见 模型页

写原生参数覆盖时长时(如 Veo 的 durationSeconds、ModelArk 的 duration),计费按上游实际返回的时长计算,不是按标准字段 seconds 的值。

错误处理

statusfailed 时读 error 对象:

{
  "id": "video_xxx",
  "object": "video",
  "status": "failed",
  "error": { "code": "content_policy_violation", "message": "..." }
}

常见失败原因:提示词触发内容审核、参考图片无法访问、请求的时长 / 尺寸组合该模型不支持。参数类错误在创建阶段就返回 400,不会进入异步流程。完整错误码见 错误处理

On this page