Music to Video Pro

Music to Video Pro 可根据 1 个公网音乐文件 URL 生成 AI 音乐视频。你可以添加参考图、视觉提示词、字幕、输出比例、分辨率和歌词口型同步参数。

该模型内部使用 Revid music-to-videoai-video / pro 模式。输出时长跟随服务端检测到的音频时长。

原有 music-video-generator 模型继续保留,两者并存。

模型

模型名称模式
music-to-video-pro基于音频 URL 生成 Revid AI 音乐视频,可选参考图与口型同步

定价

本模型按检测到的音频时长和请求分辨率计费。

audio_billable_duration = max(4, ceil(audio_seconds / 4) * 4)

720p credits  = audio_billable_duration * 117
1080p credits = audio_billable_duration * 175.5
4k credits    = audio_billable_duration * 234

audio_billable_duration 会向上取整到 4 秒片段。任务失败会自动退还预扣积分。

音频时长720p1080p4k
30s3,744 credits5,616 credits7,488 credits
60s7,020 credits10,530 credits14,040 credits
180s21,060 credits31,590 credits42,120 credits

创建任务

POST https://api.aivideoapi.ai/v1/videos/generations

请求体

字段类型必填说明
modelstringmusic-to-video-pro
inputobject生成参数
callback_urlstring接收任务完成/失败通知的 URL

Input 参数

字段类型必填说明
audio_urlsstring[]必须且只能传 1 个公网 HTTP(S) 音频文件 URL。支持 MP3、WAV、M4A 或 MP4 容器,用于服务端检测时长并计费。
image_urlsstring[]0-4 张参考图 URL,会作为视觉参考使用。
promptstring可选视觉剧情提示词,最长 2500 字符。
aspect_ratiostring默认 9:16,可选 16:91:14:5auto
resolutionstring默认 720p,可选 1080p4k。分辨率会影响平台计费。
subtitle_enabledboolean是否烧录字幕/字幕标题,默认 true
subtitle_positionstring默认 bottom,可选 topmiddle
lipsync_enabledboolean是否启用歌词口型同步,默认 false
lipsync_frequencynumber口型同步镜头占比,范围 01,默认 0.3

本模型不支持 output_count

预估费用

curl -X POST https://api.aivideoapi.ai/v1/estimate \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "music-to-video-pro",
    "input": {
      "audio_urls": ["https://example.com/song.mp3"],
      "resolution": "720p",
      "aspect_ratio": "9:16"
    }
  }'

示例

仅音频来源

curl -X POST https://api.aivideoapi.ai/v1/videos/generations \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "music-to-video-pro",
    "callback_url": "https://your-server.com/webhook",
    "input": {
      "audio_urls": ["https://example.com/song.mp3"]
    }
  }'

完整请求

curl -X POST https://api.aivideoapi.ai/v1/videos/generations \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "music-to-video-pro",
    "callback_url": "https://your-server.com/webhook",
    "input": {
      "audio_urls": ["https://example.com/song.mp3"],
      "image_urls": ["https://example.com/singer.jpg"],
      "prompt": "雨夜霓虹楼顶演出",
      "aspect_ratio": "16:9",
      "resolution": "1080p",
      "subtitle_enabled": true,
      "lipsync_enabled": true,
      "lipsync_frequency": 0.3
    }
  }'

响应

{
  "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 -> completedfailed


常见错误码

请求失败时,API 返回 JSON 格式的错误响应:

{
  "error": {
    "code": "insufficient_credits",
    "message": "Your credit balance is too low. Please top up.",
    "type": "billing_error"
  }
}

错误码一览

HTTP 状态码错误码类型说明
400invalid_requestinvalid_request_error缺少必填参数或参数无效
401invalid_api_keyauthentication_errorAPI Key 无效、已禁用或已删除
402insufficient_creditsbilling_error积分余额不足,请充值
403ip_not_allowedpermission_error请求 IP 不在 Key 的白名单中
404model_not_foundinvalid_request_error模型不存在或已停用
404task_not_foundinvalid_request_error任务 ID 不存在
429rate_limit_exceededrate_limit_error请求过于频繁,请降低频率
429spend_limit_exceededbilling_error达到 Key 的消费限额(每小时/每天/总量)
500internal_errorapi_error服务器内部错误
503upstream_errorupstream_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 服务返回错误,可能原因:

  • 输入内容包含敏感或违规信息
  • 上游服务暂时不可用
  • 请求参数不被上游支持

因上游错误导致任务失败时,预扣积分会自动退还。