Music to Video Pro
Music to Video Pro 可根据 1 个公网音乐文件 URL 生成 AI 音乐视频。你可以添加参考图、视觉提示词、字幕、输出比例、分辨率和歌词口型同步参数。
该模型内部使用 Revid music-to-video 的 ai-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 秒片段。任务失败会自动退还预扣积分。
| 音频时长 | 720p | 1080p | 4k |
|---|---|---|---|
| 30s | 3,744 credits | 5,616 credits | 7,488 credits |
| 60s | 7,020 credits | 10,530 credits | 14,040 credits |
| 180s | 21,060 credits | 31,590 credits | 42,120 credits |
创建任务
POST https://api.aivideoapi.ai/v1/videos/generations
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | music-to-video-pro |
input | object | 是 | 生成参数 |
callback_url | string | 否 | 接收任务完成/失败通知的 URL |
Input 参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
audio_urls | string[] | 是 | 必须且只能传 1 个公网 HTTP(S) 音频文件 URL。支持 MP3、WAV、M4A 或 MP4 容器,用于服务端检测时长并计费。 |
image_urls | string[] | 否 | 0-4 张参考图 URL,会作为视觉参考使用。 |
prompt | string | 否 | 可选视觉剧情提示词,最长 2500 字符。 |
aspect_ratio | string | 否 | 默认 9:16,可选 16:9、1:1、4:5、auto。 |
resolution | string | 否 | 默认 720p,可选 1080p、4k。分辨率会影响平台计费。 |
subtitle_enabled | boolean | 否 | 是否烧录字幕/字幕标题,默认 true。 |
subtitle_position | string | 否 | 默认 bottom,可选 top、middle。 |
lipsync_enabled | boolean | 否 | 是否启用歌词口型同步,默认 false。 |
lipsync_frequency | number | 否 | 口型同步镜头占比,范围 0 到 1,默认 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 -> completed 或 failed。
常见错误码
请求失败时,API 返回 JSON 格式的错误响应:
{
"error": {
"code": "insufficient_credits",
"message": "Your credit balance is too low. Please top up.",
"type": "billing_error"
}
}
错误码一览
| HTTP 状态码 | 错误码 | 类型 | 说明 |
|---|---|---|---|
| 400 | invalid_request | invalid_request_error | 缺少必填参数或参数无效 |
| 401 | invalid_api_key | authentication_error | API Key 无效、已禁用或已删除 |
| 402 | insufficient_credits | billing_error | 积分余额不足,请充值 |
| 403 | ip_not_allowed | permission_error | 请求 IP 不在 Key 的白名单中 |
| 404 | model_not_found | invalid_request_error | 模型不存在或已停用 |
| 404 | task_not_found | invalid_request_error | 任务 ID 不存在 |
| 429 | rate_limit_exceeded | rate_limit_error | 请求过于频繁,请降低频率 |
| 429 | spend_limit_exceeded | billing_error | 达到 Key 的消费限额(每小时/每天/总量) |
| 500 | internal_error | api_error | 服务器内部错误 |
| 503 | upstream_error | upstream_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 服务返回错误,可能原因:
- 输入内容包含敏感或违规信息
- 上游服务暂时不可用
- 请求参数不被上游支持
因上游错误导致任务失败时,预扣积分会自动退还。