下载 Markdown

更新日期

生视频

视频耗时长,对外强制异步。POST 立即返回任务(HTTP 200,不是 202),不要阻塞到生成完成。后台生成等待至少约 60 分钟(按时长可更长,上限 2 小时);超时对外 failed,不扣费。

创建

请求体按 Seedance / 方舟 字段收。duration 与 seconds 同义,ratio 与 aspect_ratio 同义;同时出现时以前者为准。下表为推荐规范名;snake_case 与 camelCase 均可(如 generate_audio / generateAudio)。

字段类型必填说明
modelstring是对外 id
promptstring是文本。多模态参考里可用 [Image 1] / [Video 1]
durationint ≥ 1否秒;默认 5。也可用 seconds
ratiostring否16:9 / 9:16 / 1:1 / 4:3 / 3:4 / 21:9 / adaptive。也可用 aspect_ratio / aspectRatio
resolution480p | 720p | 1080p | 4k否短边档位。也可用 resolution_name / resolutionName
sizestring否1280x720 会推成比例;720p 会当成 resolution
generate_audioboolean否同步配音(模型需支持)。也可用 generateAudio
watermarkboolean否默认 false
camera_fixedboolean否固定机位。也可用 cameraFixed
draftboolean否草稿预览(1.5 Pro)
seedint否随机种子
first_framestring否首帧 URL。也可用 firstFrame、image.url;完整别名见下表
last_framestring否尾帧 URL,与首帧组成首尾帧。也可用 lastFrame
reference_imagesstring[]否参考图,最多视模型(Seedance 2.0 最多 9)。也可用 referenceImages;完整别名见下表
reference_videosstring[]否参考视频。也可用 referenceVideos;完整别名见下表
reference_audiostring[]否参考音频。也可用 referenceAudio;完整别名见下表

媒体字段别名

图 / 音 / 视频参考下列字段名都认(含各自 camelCase / snake_case)。值可以是:

形态说明
公网 URLhttp:// / https:// 字符串,或字符串数组,或 { "url": "..." }
Base64data:*;base64,...,或可识别为媒体的裸 base64;会先转存
文件流multipart/form-data 上传(如 -F input_reference[][email protected]);会先转存

不支持本机文件路径。单文件约 10MB,最多 9 个文件。

用途规范字段也认(写全)
首帧 / 单图first_framefirstFrame、first_frame_image、firstFrameImage、init_image、initImage、image_url、imageUrl、image(字符串)、file、input_image、inputImage
参考图reference_imagesreferenceImages、reference_image、referenceImage、image_urls、imageUrls、images、input_reference、inputReference
尾帧last_framelastFrame、last_frame_image、lastFrameImage
参考音频reference_audioreferenceAudio、reference_audios、referenceAudios、audio_url、audioUrl、audio_urls、audioUrls、audio、audios、input_audio、inputAudio、voice、music
参考视频reference_videosreferenceVideos、reference_video、referenceVideo、video_url、videoUrl、video_urls、videoUrls、video、videos、input_video、inputVideo、clip、clips

单独传一张图(如仅 image_url)会当作首帧;若已有 reference_images / 参考音视频,则同类别名并入参考素材。首尾帧与参考素材不要混用:有参考素材时,部分模型会忽略首尾帧语义。即梦类模型会尽量映射成 image_urls;音频 / 参考视频是否生效取决于所选模型。

计费按创建时写入的 duration(或 seconds,默认 5)与 resolution。配置了价目表的模型按 mode 查表:per_second 为单价 × 秒数,per_resolution 为分辨率一口价(与秒无关),fixed 为分辨率 × 秒数档位一口价;否则按单价 × 秒数,resolution / size / ratio 可能乘价格系数。

curl https://tokenmei.com/v1/videos \
-H "Authorization: Bearer $MOMO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "model": "YOUR_VIDEO_MODEL",
  "prompt": "镜头跟随橙猫穿过雨夜街道",
  "duration": 5,
  "ratio": "16:9",
  "resolution": "720p",
  "generate_audio": false
}'

创建响应:

json
{
  "id": "video_a1b2c3d4e5f6",
  "object": "video",
  "model": "YOUR_VIDEO_MODEL",
  "status": "queued",
  "progress": 0,
  "created_at": 1710000000,
  "completed_at": null,
  "error": null
}
字段类型说明
idstring前缀固定 video_,用于查询
objectstring固定 video
modelstring对外模型 id
statusstring见下方状态表
progressint0–100
created_atintUnix 秒
completed_atint | null未完成时为 null
errorstring | null成功为 null,失败为说明字符串,不是 { message } 对象

用这个 id 去查询,推荐 GET /v1/tasks/{id}。GET /v1/videos/{id} 是同一查询的别名。

图生视频(首帧):

json
{
  "model": "YOUR_VIDEO_MODEL",
  "prompt": "猫转头看向镜头",
  "duration": 5,
  "first_frame": "https://cdn.example.com/frame.png"
}

首尾帧:

json
{
  "first_frame": "https://cdn.example.com/first.png",
  "last_frame": "https://cdn.example.com/last.png"
}

多模态参考(Seedance 2.0):

json
{
  "prompt": "让 [Image 1] 的人物走在 [Video 1] 的街道上",
  "duration": 8,
  "ratio": "16:9",
  "reference_images": ["https://cdn.example.com/person.png"],
  "reference_videos": ["https://cdn.example.com/street.mp4"]
}

只能查本租户的任务。别人的 id 或未知 id:404(code 为 model_not_found,param 为 id)。余额为 0 时仍可 GET。GET /v1/videos/{id} 返回同一份 JSON。

客户可见 status:

对外内部在做什么
queued已受理
in_progress生成中,或已生成正在转存(未关闭转存的模型)
completed生成完成,可取 url
failed失败或超时;error 为说明字符串

内部「转存中」对外仍是 in_progress,此时还没有 url;生成成功后即已扣费,转存失败不会退还。上架视频模型可以关闭「产物转存」,此时完成后直接返回上游视频地址;若上游需要鉴权或不是公网 HTTPS 链接,平台会自动回退转存。直链有效期由上游决定。error 成功时为 null,失败时是字符串,不是 { message } 对象。

轮询

建议 2–5 秒一次,直到 completed 或 failed。不要用创建请求一直挂着等。图和视频共用 GET /v1/tasks/{id},详见任务查询。

curl https://tokenmei.com/v1/tasks/video_a1b2c3d4e5f6 \
-H "Authorization: Bearer $MOMO_API_KEY"

完成后:

json
{
  "id": "video_a1b2c3d4e5f6",
  "object": "video",
  "model": "YOUR_VIDEO_MODEL",
  "status": "completed",
  "progress": 100,
  "created_at": 1710000000,
  "completed_at": 1710000120,
  "error": null,
  "url": "https://cdn.example.com/v/xxx.mp4",
  "usage": {
    "seconds": 5,
    "cost": { "amount": "0.5000", "currency": "CNY" }
  }
}
字段类型说明
urlstring视频结果地址,仅 completed 时出现;默认是平台转存后的稳定地址,关闭转存的模型可能直接是上游地址
usage.secondsint计费秒数,取创建时的 duration / seconds
usage.costobject可选,对外售价

任务未完成时 404(同样是 model_not_found / param=id)。完成后:

Accept结果
application/json{ "url": "..." }
其他302 到结果地址(平台稳定地址或上游地址)
curl -L https://tokenmei.com/v1/videos/video_a1b2c3d4e5f6/content \
-H "Authorization: Bearer $MOMO_API_KEY" \
-o clip.mp4

curl https://tokenmei.com/v1/videos/video_a1b2c3d4e5f6/content \
-H "Authorization: Bearer $MOMO_API_KEY" \
-H "Accept: application/json"
生视频 · MomoAI算力超市