Suno 任务查询
查询单个任务
复制
GET /suno/fetch/{id}
请求示例
复制
curl https://crazyrouter.com/suno/fetch/suno_task_abc123 \
-H "Authorization: Bearer YOUR_API_KEY"
响应示例(处理中)
复制
{
"code": 1,
"data": {
"task_id": "suno_task_abc123",
"status": "processing",
"data": []
}
}
响应示例(已完成)
复制
{
"code": 1,
"data": {
"task_id": "suno_task_abc123",
"status": "complete",
"data": [
{
"id": "clip_001",
"title": "夏日海边",
"audio_url": "https://cdn.suno.ai/audio/clip_001.mp3",
"image_url": "https://cdn.suno.ai/image/clip_001.png",
"duration": 120.5,
"tags": "pop, chinese, upbeat",
"prompt": "[Verse]\n阳光洒在海面上...",
"status": "complete"
},
{
"id": "clip_002",
"title": "夏日海边",
"audio_url": "https://cdn.suno.ai/audio/clip_002.mp3",
"image_url": "https://cdn.suno.ai/image/clip_002.png",
"duration": 118.3,
"tags": "pop, chinese, upbeat",
"prompt": "[Verse]\n阳光洒在海面上...",
"status": "complete"
}
]
}
}
批量查询
复制
POST /suno/fetch
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
ids | array | 是 | 任务 ID 列表 |
请求示例
cURL
复制
curl -X POST https://crazyrouter.com/suno/fetch \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"ids": ["suno_task_abc123", "suno_task_def456"]
}'
获取 WAV 格式
部分任务完成后可获取无损 WAV 格式的音频。在响应的audio_url 基础上替换扩展名即可:
复制
https://cdn.suno.ai/audio/clip_001.wav
任务状态
| 状态 | 说明 |
|---|---|
submitted | 已提交 |
processing | 生成中 |
complete | 已完成 |
error | 失败 |
完整流程示例
Python
复制
import requests
import time
API_KEY = "YOUR_API_KEY"
BASE_URL = "https://crazyrouter.com"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {API_KEY}"
}
# 1. 提交歌曲生成任务
resp = requests.post(f"{BASE_URL}/suno/submit/music", headers=headers, json={
"gpt_description_prompt": "一首关于夏天的欢快中文流行歌曲",
"mv": "chirp-v4"
})
task_id = resp.json()["result"]
print(f"任务已创建: {task_id}")
# 2. 轮询查询
while True:
resp = requests.get(f"{BASE_URL}/suno/fetch/{task_id}", headers=headers)
result = resp.json()["data"]
if result["status"] == "complete":
for clip in result["data"]:
print(f"歌曲: {clip['title']}")
print(f"音频: {clip['audio_url']}")
print(f"时长: {clip['duration']}秒")
print("---")
break
elif result["status"] == "error":
print("生成失败")
break
time.sleep(10)
每次歌曲生成任务通常会返回 2 首变体。歌曲生成通常需要 1-3 分钟,建议轮询间隔为 10 秒。