Music Video Generator

Music Video Generator 是 AI 音乐视频(MV)生成模型。传入一首歌和最多 3 张人物参考照片,即可生成口型同步、带电影感运镜和自然转场的完整音乐视频。AI 自动完成人声分析、分镜规划、多机位场景生成与成片合成,最长支持 10 分钟。

模型

模型名称模式
music-video-generator音频 + 参考图生成音乐视频

定价

按输出视频秒数(= 音频时长)× 分辨率计费:

分辨率积分/秒
480p9
720p18

音频时长由服务端自动探测,最低按 5 秒计费,上限 600 秒(10 分钟)。

创建任务

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

请求体

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

Input 参数

字段类型必填说明
audio_urlsstring[]必须且只能传 1 个音频 URL
image_urlsstring[]0-3 张人物参考图 URL,图中人物将贯穿全片
promptstring场景/风格描述,最长 2500 字符,例如"女歌手在霓虹灯舞台上弹吉他演唱"
aspect_ratiostring16:99:16,缺省时根据参考图自动判断
resolutionstring480p(默认)或 720p

不支持 duration 参数:输出视频时长等于音频时长。

音频限制:仅支持公网 HTTP(S) URL;格式支持 MP3、WAV、M4A(不支持裸 ADTS .aac 流);时长不超过 600 秒(10 分钟)。服务端会自动探测音频时长用于计费,探测失败(URL 不可访问或格式不支持)时任务创建会返回 400 错误且不扣积分。

参考图建议:清晰、正面、五官可见的人像效果最佳;不传 image_urls 时,AI 会根据音频中的人声(男声/女声)自动生成表演者。

生成耗时:1 分钟音频约需 3-6 分钟,更长的音频按比例增加。

示例

纯音频生成

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-video-generator",
    "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-video-generator",
    "callback_url": "https://your-server.com/webhook",
    "input": {
      "audio_urls": ["https://example.com/song.mp3"],
      "image_urls": [
        "https://example.com/singer-front.jpg",
        "https://example.com/singer-side.jpg"
      ],
      "prompt": "摇滚歌手在霓虹灯舞台上激情演唱",
      "aspect_ratio": "9:16",
      "resolution": "720p"
    }
  }'

响应

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

任务失败时,预扣的积分会自动退还。

回调 (Callback)

创建任务时传入 callback_url,系统会在任务完成或失败时自动向你的 URL 发送 POST 请求。请求头与重试策略详见回调说明

任务完成时回调

{
  "id": "8b6a5162-5c91-4a42-8e80-4c8ef5486f24",
  "status": "completed",
  "model": "music-video-generator",
  "created_at": 1781136227,
  "completed_at": 1781136589,
  "output": {
    "urls": [
      "https://file.aivideoapi.ai/videos/2026/06/11/abc.mp4"
    ],
    "metadata": {
      "model": "music-video-generator",
      "has_nsfw_contents": [false]
    }
  }
}

任务失败时回调

{
  "id": "57c8772c-f834-46f3-9b7d-81f92e104050",
  "status": "failed",
  "model": "music-video-generator",
  "created_at": 1781136227,
  "error": {
    "code": "upstream_error",
    "message": "Video generation failed"
  }
}

重要说明

  • 收到回调后请尽快返回 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 状态码错误码类型说明
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 服务返回错误,可能原因:

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

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