概览
使用您的 API Key 通过我们的 HTTP 接口生成音乐。我们支持多种生成模式。
基础 URL
https://api.sunomusic.fun/v1/music认证方式
在请求头中加入 API Key:
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json1. 查询任务状态
查询音乐生成任务的状态。
- 接口地址:
GET /status - 查询参数:
ids(逗号分隔的任务 ID)
GET https://api.sunomusic.fun/v1/music/status?ids=TASK_ID_1,TASK_ID_2
Authorization: Bearer YOUR_API_KEY返回示例:
{
"code": 0,
"message": "ok",
"data": [
{
"id": "TASK_ID_1",
"status": "success",
"data": {
"clips": [
{
"id": "task_id_1",
"clip_id": "clip_id_1",
"status": "streaming",
"audio_url": "https://...",
"video_url": "https://...",
"image_url": "https://...",
"title": "歌曲标题",
"duration": 120,
"model_name": "chirp-v4",
"metadata": {
"tags": "xxx",
"prompt": "xxx",
"gpt_description_prompt": "xxx"
},
"created_at": "2025-01-10T16:40:23.000Z"
},
{
"id": "task_id_2",
"clip_id": "clip_id_2",
"status": "streaming",
"audio_url": "https://...",
"video_url": "https://...",
"image_url": "https://...",
"title": "歌曲标题",
"duration": 120,
"model_name": "chirp-v4",
"metadata": {
"tags": "xxx",
"prompt": "xxx",
"gpt_description_prompt": "xxx"
},
"created_at": "2025-01-10T16:40:23.000Z"
}
]
}
}
]
}2. 生成音乐
使用不同的模式创建音乐。
- 接口地址:
POST /generate - 请求体: JSON 对象
参数说明
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 否 | 模型 ID (例如 chirp-v3-5, chirp-v4) |
gpt_description_prompt | string | 否 | 灵感模式: 音乐风格或主题的描述 |
prompt | string | 否 | 自定义模式: 歌词内容 |
title | string | 否 | 自定义模式: 歌曲标题 |
tags | string | 否 | 自定义模式: 风格标签 (例如 "pop, rock") |
make_instrumental | boolean | 否 | 是否生成纯音乐 (无人声) |
continue_clip_id | string | 否 | 续写模式: 要续写的片段 ID |
continue_at | number | 否 | 续写模式: 开始续写的时间点 (秒) |
callback_url | string | 否 | 异步通知的回调 URL |
模式 1: 灵感模式 (描述生成)
通过描述主题或风格来生成音乐。
POST /generate
{
"gpt_description_prompt": "一首关于夏日海滩的轻快流行歌曲",
"model": "chirp-v4"
}模式 2: 自定义模式 (歌词生成)
指定歌词、标题和标签来生成音乐。
POST /generate
{
"prompt": "[Verse]\n夏天的风轻轻吹过\n海浪拍打着沙滩\n\n[Chorus]\n让我们一起跳舞",
"title": "海边的夏天",
"tags": "pop, chinese, summer",
"model": "chirp-v3-5"
}模式 3: 纯音乐
生成没有人声的纯音乐。
POST /generate
{
"gpt_description_prompt": "一首轻快的电子舞曲",
"make_instrumental": true,
"model": "chirp-v4"
}模式 4: 音乐续写
延续现有的音乐片段。
POST /generate
{
"continue_clip_id": "EXISTING_CLIP_ID",
"continue_at": 60,
"prompt": "[Outro]\n旋律逐渐消失在夕阳中...",
"model": "chirp-v4"
}异步通知 (Webhook)
您可以在 /generate 接口中提供 callback_url,以便在生成完成时接收 POST 请求。
{
"prompt": "测试歌曲",
"callback_url": "https://your-server.com/callback"
}回调内容:
{
"clips": [
{
"id": "task_id_1",
"clip_id": "clip_id_1",
"status": "streaming",
"audio_url": "https://...",
"video_url": "https://...",
"image_url": "https://...",
"title": "歌曲标题",
"duration": 120,
"model_name": "chirp-v4",
"metadata": {
"tags": "xxx",
"prompt": "xxx",
"gpt_description_prompt": "xxx"
},
"created_at": "2025-01-10T16:40:23.000Z"
},
{
"id": "task_id_2",
"clip_id": "clip_id_2",
"status": "streaming",
"audio_url": "https://...",
"video_url": "https://...",
"image_url": "https://...",
"title": "歌曲标题",
"duration": 120,
"model_name": "chirp-v4",
"metadata": {
"tags": "xxx",
"prompt": "xxx",
"gpt_description_prompt": "xxx"
},
"created_at": "2025-01-10T16:40:23.000Z"
}
],
"status": "completed"
}