cURL
curl --request POST \
--url https://api.ttapi.io/suno/v1/sample \
--header 'Content-Type: application/json' \
--header 'TT-API-KEY: <api-key>' \
--data '
{
"music_id": "<string>",
"chop_sample_start_s": 0,
"chop_sample_end_s": 60,
"custom": false,
"instrumental": false,
"mv": "chirp-v5",
"gpt_description_prompt": "夜晚城市 lo-fi 钢琴搭配雨声,柔和人声唱段,主题:“在灯火阑珊处”",
"prompt": "<string>",
"title": "<string>",
"tags": "rock, blues, hip-hop, r&b",
"negative_tags": "<string>",
"style_weight": 0.5,
"weirdness_constraint": 0.5,
"audio_weight": 0.5,
"auto_lyrics": false,
"isStorage": true,
"hookUrl": "<string>"
}
'import requests
url = "https://api.ttapi.io/suno/v1/sample"
payload = {
"music_id": "<string>",
"chop_sample_start_s": 0,
"chop_sample_end_s": 60,
"custom": False,
"instrumental": False,
"mv": "chirp-v5",
"gpt_description_prompt": "夜晚城市 lo-fi 钢琴搭配雨声,柔和人声唱段,主题:“在灯火阑珊处”",
"prompt": "<string>",
"title": "<string>",
"tags": "rock, blues, hip-hop, r&b",
"negative_tags": "<string>",
"style_weight": 0.5,
"weirdness_constraint": 0.5,
"audio_weight": 0.5,
"auto_lyrics": False,
"isStorage": True,
"hookUrl": "<string>"
}
headers = {
"TT-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'TT-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
music_id: '<string>',
chop_sample_start_s: 0,
chop_sample_end_s: 60,
custom: false,
instrumental: false,
mv: 'chirp-v5',
gpt_description_prompt: '夜晚城市 lo-fi 钢琴搭配雨声,柔和人声唱段,主题:“在灯火阑珊处”',
prompt: '<string>',
title: '<string>',
tags: 'rock, blues, hip-hop, r&b',
negative_tags: '<string>',
style_weight: 0.5,
weirdness_constraint: 0.5,
audio_weight: 0.5,
auto_lyrics: false,
isStorage: true,
hookUrl: '<string>'
})
};
fetch('https://api.ttapi.io/suno/v1/sample', 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.ttapi.io/suno/v1/sample",
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([
'music_id' => '<string>',
'chop_sample_start_s' => 0,
'chop_sample_end_s' => 60,
'custom' => false,
'instrumental' => false,
'mv' => 'chirp-v5',
'gpt_description_prompt' => '夜晚城市 lo-fi 钢琴搭配雨声,柔和人声唱段,主题:“在灯火阑珊处”',
'prompt' => '<string>',
'title' => '<string>',
'tags' => 'rock, blues, hip-hop, r&b',
'negative_tags' => '<string>',
'style_weight' => 0.5,
'weirdness_constraint' => 0.5,
'audio_weight' => 0.5,
'auto_lyrics' => false,
'isStorage' => true,
'hookUrl' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"TT-API-KEY: <api-key>"
],
]);
$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.ttapi.io/suno/v1/sample"
payload := strings.NewReader("{\n \"music_id\": \"<string>\",\n \"chop_sample_start_s\": 0,\n \"chop_sample_end_s\": 60,\n \"custom\": false,\n \"instrumental\": false,\n \"mv\": \"chirp-v5\",\n \"gpt_description_prompt\": \"夜晚城市 lo-fi 钢琴搭配雨声,柔和人声唱段,主题:“在灯火阑珊处”\",\n \"prompt\": \"<string>\",\n \"title\": \"<string>\",\n \"tags\": \"rock, blues, hip-hop, r&b\",\n \"negative_tags\": \"<string>\",\n \"style_weight\": 0.5,\n \"weirdness_constraint\": 0.5,\n \"audio_weight\": 0.5,\n \"auto_lyrics\": false,\n \"isStorage\": true,\n \"hookUrl\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("TT-API-KEY", "<api-key>")
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.ttapi.io/suno/v1/sample")
.header("TT-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"music_id\": \"<string>\",\n \"chop_sample_start_s\": 0,\n \"chop_sample_end_s\": 60,\n \"custom\": false,\n \"instrumental\": false,\n \"mv\": \"chirp-v5\",\n \"gpt_description_prompt\": \"夜晚城市 lo-fi 钢琴搭配雨声,柔和人声唱段,主题:“在灯火阑珊处”\",\n \"prompt\": \"<string>\",\n \"title\": \"<string>\",\n \"tags\": \"rock, blues, hip-hop, r&b\",\n \"negative_tags\": \"<string>\",\n \"style_weight\": 0.5,\n \"weirdness_constraint\": 0.5,\n \"audio_weight\": 0.5,\n \"auto_lyrics\": false,\n \"isStorage\": true,\n \"hookUrl\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ttapi.io/suno/v1/sample")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["TT-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"music_id\": \"<string>\",\n \"chop_sample_start_s\": 0,\n \"chop_sample_end_s\": 60,\n \"custom\": false,\n \"instrumental\": false,\n \"mv\": \"chirp-v5\",\n \"gpt_description_prompt\": \"夜晚城市 lo-fi 钢琴搭配雨声,柔和人声唱段,主题:“在灯火阑珊处”\",\n \"prompt\": \"<string>\",\n \"title\": \"<string>\",\n \"tags\": \"rock, blues, hip-hop, r&b\",\n \"negative_tags\": \"<string>\",\n \"style_weight\": 0.5,\n \"weirdness_constraint\": 0.5,\n \"audio_weight\": 0.5,\n \"auto_lyrics\": false,\n \"isStorage\": true,\n \"hookUrl\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"status": "SUCCESS",
"message": "success",
"data": {
"jobId": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
}{
"status": "FAILED",
"message": "<string>",
"data": {}
}{
"status": "FAILED",
"message": "Wrong TT-API-KEY or email is not activated."
}Suno
Suno Sample API 文档
通过 Suno 音频样本生成接口基于短音频片段扩展出完整歌曲,适合素材扩写、灵感延展和采样再创作。
POST
/
suno
/
v1
/
sample
cURL
curl --request POST \
--url https://api.ttapi.io/suno/v1/sample \
--header 'Content-Type: application/json' \
--header 'TT-API-KEY: <api-key>' \
--data '
{
"music_id": "<string>",
"chop_sample_start_s": 0,
"chop_sample_end_s": 60,
"custom": false,
"instrumental": false,
"mv": "chirp-v5",
"gpt_description_prompt": "夜晚城市 lo-fi 钢琴搭配雨声,柔和人声唱段,主题:“在灯火阑珊处”",
"prompt": "<string>",
"title": "<string>",
"tags": "rock, blues, hip-hop, r&b",
"negative_tags": "<string>",
"style_weight": 0.5,
"weirdness_constraint": 0.5,
"audio_weight": 0.5,
"auto_lyrics": false,
"isStorage": true,
"hookUrl": "<string>"
}
'import requests
url = "https://api.ttapi.io/suno/v1/sample"
payload = {
"music_id": "<string>",
"chop_sample_start_s": 0,
"chop_sample_end_s": 60,
"custom": False,
"instrumental": False,
"mv": "chirp-v5",
"gpt_description_prompt": "夜晚城市 lo-fi 钢琴搭配雨声,柔和人声唱段,主题:“在灯火阑珊处”",
"prompt": "<string>",
"title": "<string>",
"tags": "rock, blues, hip-hop, r&b",
"negative_tags": "<string>",
"style_weight": 0.5,
"weirdness_constraint": 0.5,
"audio_weight": 0.5,
"auto_lyrics": False,
"isStorage": True,
"hookUrl": "<string>"
}
headers = {
"TT-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'TT-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
music_id: '<string>',
chop_sample_start_s: 0,
chop_sample_end_s: 60,
custom: false,
instrumental: false,
mv: 'chirp-v5',
gpt_description_prompt: '夜晚城市 lo-fi 钢琴搭配雨声,柔和人声唱段,主题:“在灯火阑珊处”',
prompt: '<string>',
title: '<string>',
tags: 'rock, blues, hip-hop, r&b',
negative_tags: '<string>',
style_weight: 0.5,
weirdness_constraint: 0.5,
audio_weight: 0.5,
auto_lyrics: false,
isStorage: true,
hookUrl: '<string>'
})
};
fetch('https://api.ttapi.io/suno/v1/sample', 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.ttapi.io/suno/v1/sample",
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([
'music_id' => '<string>',
'chop_sample_start_s' => 0,
'chop_sample_end_s' => 60,
'custom' => false,
'instrumental' => false,
'mv' => 'chirp-v5',
'gpt_description_prompt' => '夜晚城市 lo-fi 钢琴搭配雨声,柔和人声唱段,主题:“在灯火阑珊处”',
'prompt' => '<string>',
'title' => '<string>',
'tags' => 'rock, blues, hip-hop, r&b',
'negative_tags' => '<string>',
'style_weight' => 0.5,
'weirdness_constraint' => 0.5,
'audio_weight' => 0.5,
'auto_lyrics' => false,
'isStorage' => true,
'hookUrl' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"TT-API-KEY: <api-key>"
],
]);
$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.ttapi.io/suno/v1/sample"
payload := strings.NewReader("{\n \"music_id\": \"<string>\",\n \"chop_sample_start_s\": 0,\n \"chop_sample_end_s\": 60,\n \"custom\": false,\n \"instrumental\": false,\n \"mv\": \"chirp-v5\",\n \"gpt_description_prompt\": \"夜晚城市 lo-fi 钢琴搭配雨声,柔和人声唱段,主题:“在灯火阑珊处”\",\n \"prompt\": \"<string>\",\n \"title\": \"<string>\",\n \"tags\": \"rock, blues, hip-hop, r&b\",\n \"negative_tags\": \"<string>\",\n \"style_weight\": 0.5,\n \"weirdness_constraint\": 0.5,\n \"audio_weight\": 0.5,\n \"auto_lyrics\": false,\n \"isStorage\": true,\n \"hookUrl\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("TT-API-KEY", "<api-key>")
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.ttapi.io/suno/v1/sample")
.header("TT-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"music_id\": \"<string>\",\n \"chop_sample_start_s\": 0,\n \"chop_sample_end_s\": 60,\n \"custom\": false,\n \"instrumental\": false,\n \"mv\": \"chirp-v5\",\n \"gpt_description_prompt\": \"夜晚城市 lo-fi 钢琴搭配雨声,柔和人声唱段,主题:“在灯火阑珊处”\",\n \"prompt\": \"<string>\",\n \"title\": \"<string>\",\n \"tags\": \"rock, blues, hip-hop, r&b\",\n \"negative_tags\": \"<string>\",\n \"style_weight\": 0.5,\n \"weirdness_constraint\": 0.5,\n \"audio_weight\": 0.5,\n \"auto_lyrics\": false,\n \"isStorage\": true,\n \"hookUrl\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ttapi.io/suno/v1/sample")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["TT-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"music_id\": \"<string>\",\n \"chop_sample_start_s\": 0,\n \"chop_sample_end_s\": 60,\n \"custom\": false,\n \"instrumental\": false,\n \"mv\": \"chirp-v5\",\n \"gpt_description_prompt\": \"夜晚城市 lo-fi 钢琴搭配雨声,柔和人声唱段,主题:“在灯火阑珊处”\",\n \"prompt\": \"<string>\",\n \"title\": \"<string>\",\n \"tags\": \"rock, blues, hip-hop, r&b\",\n \"negative_tags\": \"<string>\",\n \"style_weight\": 0.5,\n \"weirdness_constraint\": 0.5,\n \"audio_weight\": 0.5,\n \"auto_lyrics\": false,\n \"isStorage\": true,\n \"hookUrl\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"status": "SUCCESS",
"message": "success",
"data": {
"jobId": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
}{
"status": "FAILED",
"message": "<string>",
"data": {}
}{
"status": "FAILED",
"message": "Wrong TT-API-KEY or email is not activated."
}请求体
application/json
样本音乐ID,通过上传返回的music_id
样本音乐开始时间,单位:秒
样本音乐结束时间,单位:秒
是否使用自定义模式。
- true:音频将从歌词中生成
- false:音频将根据灵感模式提示词生成
是否生成纯音乐。
- true:生成纯音乐
- false:生成含歌词音轨,
- 灵感模式下 gpt_description_prompt 参数必填
- 自定义模型下 prompt 参数必填
使用模型
可用选项:
chirp-v5-5, chirp-v5, chirp-v4-5+, chirp-v4-5, chirp-v4-5-all, chirp-v4, chirp-v3-5, chirp-v3-0 灵感模式提示词
非自定义模式下(custom=false):始终必填。将根据此提示词自动生成歌词,最多3000字符。
示例:
"夜晚城市 lo-fi 钢琴搭配雨声,柔和人声唱段,主题:“在灯火阑珊处”"
歌词
自定义模式下(custom=true):当 instrumental 为 false 时必填。将作为歌词使用并在生成的音轨中演唱,最多5000字符。
音乐标题
自定义模式下(custom=true)使用,最多80字符。
音乐风格
自定义模式下(custom=true)使用,最多1000字符
示例:
"rock, blues, hip-hop, r&b"
不想要生成的音乐风格
自定义模式下(custom=true)使用。
音乐风格权重,范围0.00-1.00
自定义模式下使用,赋值范围: 0 <= x <= 1。
示例:
0.5
音频奇妙度权重,范围0.00-1.00
自定义模式下使用,赋值范围: 0 <= x <= 1。
示例:
0.5
音频权重,范围0.00-1.00
自定义模式下使用,赋值范围: 0 <= x <= 1。
示例:
0.5
是否自动生成歌词,自定义模式专用
- true:根据输入的歌词进行二次创作,与灵感模式提示词效果一致
- false:使用输入的歌词生成音乐
音色性别
-
Male:男性
-
Female:女性
可用选项:
Male, Female 是否转存
- true:音频将进行转存,返回TTAPI CDN地址
- false:返回官方源地址
回调通知地址
最后修改于 2026年3月21日
⌘I