文档 / 音乐系列 / Suno / 辅助功能
获取歌词时间轴
获取已生成 clip 的歌词对齐时间轴。
用途#
提交一个 歌词时间轴(TIMING) 任务,获取本服务已生成 clip 的歌词对齐时间轴(每段/每词对应的时间戳)。接口为异步模式:服务在校验通过后立即返回公开 task_id,不会等待任务完成。后续通过 GET /v1/tasks/:id 轮询任务状态与结果。
TIMING 是一个仅依赖源 clip_id 的派生动作:它不重新生成音乐,而是基于已有 clip 计算并返回歌词时间轴,常用于做卡拉 OK 式歌词高亮、字幕同步等。clip_id 必须来自本服务已生成的任务结果,结果通过任务的 data 字段返回。
TIMING 只需要源 clip_id;callback_url 为可选的任务回调地址。
请求字段#
| 字段 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
clip_id | string | 是 | — | 目标 Suno clip 的 UUID,须来自本服务已生成的任务结果 |
callback_url | string | 否 | — | 任务到达终态时的回调通知地址 |
clip_id 为必填。若为空,服务端返回错误码 clip_id_empty。该 clip 必须来自本服务历史任务,否则请求会失败。
callback_url 必须是公网可访问的 HTTPS 地址,长度不超过 2048 字符;禁止使用本机、内网、回环、链路本地地址,也禁止使用解析到这些地址的域名。
任务完成或失败后,服务会向该地址发送 POST JSON。回调接收端须在 10 秒内返回任意 2xx 状态码;超时、网络错误或非 2xx 响应均视为失败。
失败后会分别等待 1 秒、2 秒和 4 秒重试,连同首次请求最多发送 4 次。接收端应使用任务 ID 做幂等处理,避免重复处理。
不合法的 callback_url 不会导致提交失败,但该任务不会收到回调。
请求示例#
curl --request POST \
--url https://api.apimax.ai/v1/music/timing \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"clip_id": "1f78f8de-4ca6-4375-ae79-46c33a2c97f7",
"callback_url": ""
}'成功响应#
{
"created_at": 1795404820,
"id": "task_AH0CG8v11LkvIri7qFBKeVbCxmjEr08l",
"model": "suno_timing",
"status": "queued",
"task_id": "task_AH0CG8v11LkvIri7qFBKeVbCxmjEr08l"
}响应字段#
| 字段 | 类型 | 说明 |
|---|---|---|
task_id | string | 公开任务 ID,用于后续查询与回调 |
id | string | 与 task_id 相同 |
status | string | 提交后固定为 queued |
model | string | 模型名,固定为 suno_timing |
created_at | integer | 任务创建时间(Unix 秒) |
所有后续查询都使用 task_id。
错误响应#
出错时统一返回下面的结构,error.code 是错误码,error.message 是具体原因:
{
"error": {
"code": "plugin_request_invalid",
"message": "clip_id_empty",
"type": "max_api_error"
}
}| HTTP | error.code | error.message | 场景 |
|---|---|---|---|
| 400 | plugin_request_invalid | clip_id_empty | clip_id 为空 |
| 400 | invalid_request | 具体的解析错误 | 请求体不是合法的 JSON 对象 |
| 503 | model_not_found | 无可用渠道(含分组与模型名) | 当前没有可用渠道 |
查询任务结果#
提交成功后,使用返回的 task_id 轮询:
- 单个查询:
GET /v1/tasks/:id
status 枚举#
| 值 | 说明 |
|---|---|
queued | 任务已创建,等待处理 |
in_progress | 任务正在处理 |
completed | 任务处理完成,可读取 data |
failed | 任务处理失败,可读取 error |
completed 和 failed 为终态;其余状态请继续轮询。
响应字段#
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 公开任务 ID |
object | string | 固定为 task |
model | string | 模型名,固定为 suno_timing |
platform / type | string | 固定为 suno |
status | string | 任务状态,见上方枚举 |
progress | integer | 进度百分比,0–100 |
created_at | integer | 提交时间(Unix 秒) |
started_at | integer | 开始处理时间(Unix 秒),未开始时不返回 |
finished_at | integer | 结束时间(Unix 秒),未结束时不返回 |
data | — | 任务结果,仅 completed 时返回,结构见下文 |
error | object | 失败信息,仅 failed 时返回,含 code 与 message |
任务失败时 status 为 failed,原因在 error.message(例如上游超时的 task_timeout),该次费用会退回。
clip_id 不是本服务生成的 clip 时,任务会在提交后十几秒内变为 failed,error.message 为上游返回的找不到 clip 的提示(如 Clip not found.)。
结果字段(data)#
查询结果中的 data 字段包含歌词时间轴数据,通常包含每段歌词文本及其对应的起止时间戳。
{
"id": "task_r5KHNQmUUtRAS4G0ED0m2x9CZMVtD68n",
"model": "suno_timing",
"object": "task",
"platform": "suno",
"type": "suno",
"status": "completed",
"progress": 100,
"created_at": 1783071970,
"started_at": 1783071971,
"finished_at": 1783071982,
"data": [
{
"state": "complete",
"alignment": [
{ "word": "[V", "start_s": 12.527, "end_s": 12.686, "p_align": 1, "success": true },
{ "word": "er", "start_s": 13.085, "end_s": 13.245, "p_align": 1, "success": true },
{ "word": "s", "start_s": 13.644, "end_s": 13.723, "p_align": 1, "success": true },
{ "word": "e", "start_s": 14.441, "end_s": 14.521, "p_align": 1, "success": true },
{ "word": "] test", "start_s": 24.814, "end_s": 25.293, "p_align": 1, "success": true },
{ "word": "ing", "start_s": 25.452, "end_s": 25.691, "p_align": 1, "success": true }
]
}
]
}data[].alignment 为逐词对齐数组:word 为词/片段文本,start_s / end_s 为起止秒,p_align 为对齐置信度,success 表示该词是否成功对齐。字段名与结构以实际响应为准。

