跳转到主要内容
POST
/
api
/
v1
/
generate
/
extend
延长音乐
curl --request POST \
  --url https://api.sunoapi.org/api/v1/generate/extend \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "defaultParamFlag": true,
  "audioId": "e231****-****-****-****-****8cadc7dc",
  "model": "V4_5ALL",
  "callBackUrl": "https://api.example.com/callback",
  "prompt": "用更多舒缓的音符延长音乐",
  "style": "古典",
  "title": "宁静钢琴延长版",
  "continueAt": 60,
  "personaId": "persona_123",
  "personaModel": "style_persona",
  "negativeTags": "舒缓钢琴",
  "vocalGender": "m",
  "styleWeight": 0.65,
  "weirdnessConstraint": 0.65,
  "audioWeight": 0.65
}
'
import requests

url = "https://api.sunoapi.org/api/v1/generate/extend"

payload = {
"defaultParamFlag": True,
"audioId": "e231****-****-****-****-****8cadc7dc",
"model": "V4_5ALL",
"callBackUrl": "https://api.example.com/callback",
"prompt": "用更多舒缓的音符延长音乐",
"style": "古典",
"title": "宁静钢琴延长版",
"continueAt": 60,
"personaId": "persona_123",
"personaModel": "style_persona",
"negativeTags": "舒缓钢琴",
"vocalGender": "m",
"styleWeight": 0.65,
"weirdnessConstraint": 0.65,
"audioWeight": 0.65
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
defaultParamFlag: true,
audioId: 'e231****-****-****-****-****8cadc7dc',
model: 'V4_5ALL',
callBackUrl: 'https://api.example.com/callback',
prompt: '用更多舒缓的音符延长音乐',
style: '古典',
title: '宁静钢琴延长版',
continueAt: 60,
personaId: 'persona_123',
personaModel: 'style_persona',
negativeTags: '舒缓钢琴',
vocalGender: 'm',
styleWeight: 0.65,
weirdnessConstraint: 0.65,
audioWeight: 0.65
})
};

fetch('https://api.sunoapi.org/api/v1/generate/extend', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sunoapi.org/api/v1/generate/extend",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'defaultParamFlag' => true,
'audioId' => 'e231****-****-****-****-****8cadc7dc',
'model' => 'V4_5ALL',
'callBackUrl' => 'https://api.example.com/callback',
'prompt' => '用更多舒缓的音符延长音乐',
'style' => '古典',
'title' => '宁静钢琴延长版',
'continueAt' => 60,
'personaId' => 'persona_123',
'personaModel' => 'style_persona',
'negativeTags' => '舒缓钢琴',
'vocalGender' => 'm',
'styleWeight' => 0.65,
'weirdnessConstraint' => 0.65,
'audioWeight' => 0.65
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.sunoapi.org/api/v1/generate/extend"

payload := strings.NewReader("{\n \"defaultParamFlag\": true,\n \"audioId\": \"e231****-****-****-****-****8cadc7dc\",\n \"model\": \"V4_5ALL\",\n \"callBackUrl\": \"https://api.example.com/callback\",\n \"prompt\": \"用更多舒缓的音符延长音乐\",\n \"style\": \"古典\",\n \"title\": \"宁静钢琴延长版\",\n \"continueAt\": 60,\n \"personaId\": \"persona_123\",\n \"personaModel\": \"style_persona\",\n \"negativeTags\": \"舒缓钢琴\",\n \"vocalGender\": \"m\",\n \"styleWeight\": 0.65,\n \"weirdnessConstraint\": 0.65,\n \"audioWeight\": 0.65\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.sunoapi.org/api/v1/generate/extend")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"defaultParamFlag\": true,\n \"audioId\": \"e231****-****-****-****-****8cadc7dc\",\n \"model\": \"V4_5ALL\",\n \"callBackUrl\": \"https://api.example.com/callback\",\n \"prompt\": \"用更多舒缓的音符延长音乐\",\n \"style\": \"古典\",\n \"title\": \"宁静钢琴延长版\",\n \"continueAt\": 60,\n \"personaId\": \"persona_123\",\n \"personaModel\": \"style_persona\",\n \"negativeTags\": \"舒缓钢琴\",\n \"vocalGender\": \"m\",\n \"styleWeight\": 0.65,\n \"weirdnessConstraint\": 0.65,\n \"audioWeight\": 0.65\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.sunoapi.org/api/v1/generate/extend")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"defaultParamFlag\": true,\n \"audioId\": \"e231****-****-****-****-****8cadc7dc\",\n \"model\": \"V4_5ALL\",\n \"callBackUrl\": \"https://api.example.com/callback\",\n \"prompt\": \"用更多舒缓的音符延长音乐\",\n \"style\": \"古典\",\n \"title\": \"宁静钢琴延长版\",\n \"continueAt\": 60,\n \"personaId\": \"persona_123\",\n \"personaModel\": \"style_persona\",\n \"negativeTags\": \"舒缓钢琴\",\n \"vocalGender\": \"m\",\n \"styleWeight\": 0.65,\n \"weirdnessConstraint\": 0.65,\n \"audioWeight\": 0.65\n}"

response = http.request(request)
puts response.read_body
{
  "code": 200,
  "msg": "success",
  "data": {
    "taskId": "5c79****be8e"
  }
}

参数使用指南

  • 当 defaultParamFlag 为 true(自定义参数)时:
    • 需要提供 prompt、style、title 和 continueAt
    • Prompt 长度限制:
      • 对于 V4 模型:3000字符
      • 对于 V4_5、V4_5PLUS、V4_5ALL、V5 和 V5_5 模型:5000字符
    • Style 长度限制:
      • 对于 V4 模型:200字符
      • 对于 V4_5、V4_5PLUS、V4_5ALL、V5 和 V5_5 模型:1000字符
    • Title 长度限制:
      • 对于 V4 和 V4_5ALL 模型:80字符
      • 对于 V4_5、V4_5PLUS、V5 和 V5_5 模型:100字符
  • 当 defaultParamFlag 为 false(使用默认参数)时:
    • 仅需提供 audioId
    • 其他参数将使用原音频的参数

可选参数

  • personaId(string):使用自定义参数时可传入 Persona ID 或 Suno Voice 生成的 voiceId。如果使用 Voice 生成的 ID,personaModel 必须设置为 voice_persona
  • personaModel(string):Persona 类型。生成 Persona 接口返回的 ID 使用 style_persona,Suno Voice 生成的 ID 使用 voice_persona

开发者注意事项

  1. 生成的文件将保留15天
  2. 模型版本必须与源音乐保持一致
  3. 此功能非常适合通过延长现有音乐创作更长的作品

授权

Authorization
string
header
必填

🔑 API 认证说明

所有接口都需要通过 Bearer Token 方式进行认证。

获取 API Key

  1. 访问 API Key 管理页面 获取您的 API Key

使用方式

在请求头中添加:

Authorization: Bearer YOUR_API_KEY

⚠️ 注意:

  • 请妥善保管您的 API Key,不要泄露给他人
  • 如果怀疑 API Key 泄露,请立即在管理页面重置

请求体

application/json
defaultParamFlag
boolean
必填

控制参数使用模式。

  • true:使用自定义参数(需要提供 continueAtpromptstyletitle)。
  • false:使用原始音频参数(只需提供 audioId)。
示例:

true

audioId
string
必填

要延长的音轨的音频ID。这是将要继续的源音轨。

示例:

"e231****-****-****-****-****8cadc7dc"

model
enum<string>
必填

使用的模型版本,必须与源音频保持一致。

  • 可选择:
    • V5_5: Unleash Your Voice: Custom Models Tailored to Your Unique Taste.
    • V5: 更卓越的音乐表现力,生成速度更快。
    • V4_5PLUS: V4.5+ 音色更丰富,新的创作方式,最长8分钟。
    • V4_5ALL: V4.5-all 更好的歌曲结构,最长8分钟。
    • V4_5: V4.5 更智能的提示词,更快的生成速度,最长8分钟。
    • V4: V4 改进的人声质量,最长4分钟。
可用选项:
V4,
V4_5,
V4_5PLUS,
V4_5ALL,
V5,
V5_5
示例:

"V4_5ALL"

callBackUrl
string<uri>
必填

在音乐延长完成时接收任务完成通知的URL。

  • 详细的回调格式和实现指南,请参见 音乐扩展回调
  • 或者,您也可以使用获取音乐生成详情接口来轮询任务状态
示例:

"https://api.example.com/callback"

prompt
string

描述音乐应如何延长。当 defaultParamFlag 为 true 时必填。

示例:

"用更多舒缓的音符延长音乐"

style
string

音乐风格,例如爵士、古典、电子等

示例:

"古典"

title
string

音乐标题

示例:

"宁静钢琴延长版"

continueAt
number

音频开始扩展的时间点(以秒为单位)。

  • defaultParamFlagtrue 时必填。
  • 取值范围:大于0且小于该生成音频的总时长。
  • 指定从原始音频的哪个时间点开始进行扩展。
示例:

60

personaId
string

仅在开启自定义参数时可用。应用到生成音乐的 Persona ID,可选。你可以传入以下两类 ID:

  • 通过 生成 Persona 接口生成的 Persona ID。此时可使用 personaModel: style_persona,或省略 personaModel 使用默认值。
  • 通过 Suno Voice 流程生成的 voiceId。当使用 Voice 生成的 ID 时,必须设置 personaModel: voice_persona
示例:

"persona_123"

personaModel
enum<string>
默认值:style_persona

使用 personaId 时应用的 Persona 模型类型,可选。

  • style_persona(默认):用于生成 Persona 接口返回的 Persona ID。
  • voice_persona:当 personaId 使用 Suno Voice 生成的 voiceId 时必须选择该值。该选项仅在 V5 与 V5_5 模型下可用。
可用选项:
style_persona,
voice_persona
示例:

"style_persona"

negativeTags
string

需要在生成中排除的音乐风格

示例:

"舒缓钢琴"

vocalGender
enum<string>

期望的人声性别(可选)

可用选项:
m,
f
示例:

"m"

styleWeight
number

风格指引权重,范围 0.00–1.00

必填范围: 0 <= x <= 1必须是以下数值的倍数 0.01
示例:

0.65

weirdnessConstraint
number

创意发散/奇异度约束,范围 0.00–1.00

必填范围: 0 <= x <= 1必须是以下数值的倍数 0.01
示例:

0.65

audioWeight
number

输入音频影响力权重(如适用),范围 0.00–1.00

必填范围: 0 <= x <= 1必须是以下数值的倍数 0.01
示例:

0.65

回调

POST
{$request.body#/callBackUrl}audioExtend

请求体

application/json
code
integer

状态码

示例:

200

msg
string

返回消息

示例:

"All generated successfully"

data
object

响应

200

回调接收成功

响应

请求成功

code
enum<integer>

状态码说明

  • ✅ 200 - 请求成功
  • ⚠️ 400 - 参数错误
  • ⚠️ 401 - 没有访问权限
  • ⚠️ 404 - 请求方式或者路径错误
  • ⚠️ 405 - 调用超过限制
  • ⚠️ 413 - 主题或者prompt过长
  • ⚠️ 429 - 积分不足
  • ⚠️ 430 - 您的调用频率过高,请稍后再试。
  • ⚠️ 455 - 网站维护
  • ❌ 500 - 服务器异常
可用选项:
200,
400,
401,
404,
405,
413,
429,
430,
455,
500
示例:

200

msg
string

当 code != 200 时,展示错误信息

示例:

"success"

data
object