API 參考
音樂
/v1/music/generations/v1/music/tasks/{task_id}/v1/music/tasks/{task_id}/content一個介面做 Suno 歌曲、歌詞和 32 個工具。每次呼叫立刻回傳 task_id;輪詢任務(或用 webhook)直到完成,然後讀取檔案。
#請求參數
modelstring必填模型頁上的音樂模型 ID:suno。
operationstring選填要做什麼:music(預設)生成歌曲,lyrics 寫歌詞,下面的工具用來編輯、續寫、分析或匯出歌曲。
promptstring選填靈感模式:歌曲內容描述,最多 3000 字。自訂模式:歌詞,最多 5000 字。自訂模式的純音樂可以不填。lyrics 時:寫歌詞的要求。
customboolean選填false(預設):靈感模式,prompt 描述歌曲。true:自訂模式,prompt 是歌詞,title、style、negative_tags、auto_lyrics、persona_id、duration 和 max_mode 生效。
instrumentalboolean選填true:不要人聲。
versionstring選填v6(預設)、v6-wild 或 v6-mini。設定了 custom_model_id 時不要傳。
titlestring選填歌名,最多 80 字。自訂模式。
stylestring選填風格標籤,如曲風、情緒、樂器,最多 1000 字。自訂模式。也可以用 tags。
negative_tagsstring選填不想要的風格。自訂模式。
vocal_genderstring選填Male(男聲)或 Female(女聲)。
auto_lyricsboolean選填true:創意改寫給定的歌詞。自訂模式。
style_weightnumber選填0 到 1:歌曲貼合風格的程度。0 也是有效值。
weirdness_constraintnumber選填0 到 1:歌曲的大膽程度。
audio_weightnumber選填0 到 1:參考錄音的影響程度。
varietystring選填off、normal、high、extra 或 max:結果之間的差異程度。
max_modeboolean選填true:Max 模式,品質更高,價格翻倍。自訂模式。
audio_formatstring選填mp3, m4a or wav.
durationinteger選填目標時長(秒),10 到 360。自訂模式;成品時長可能不同。
persona_idstring選填用 persona 工具做出的歌手 Persona。自訂模式;不能和 custom_model_id 同時用。
custom_model_idstring選填用 create-model 訓練的模型。取代 version;不能和 persona_id 同時用。
parametersobject選填工具自己的欄位(見下方「工具」),例如所處理歌曲的 task_id 和 audio_index。
webhook_urlstring選填任務進入終態後回呼的 HTTPS 網址。
webhook_secretstring選填設定後,回呼帶 X-Xiaoxiang-Signature: sha256=hex(HMAC-SHA256(body, secret))。
兩種寫歌方式
#處理你做過的歌
處理歌曲的工具要傳 task_id(本介面回傳的、做出這首歌的任務)和 audio_index(這首歌在該任務裡的位置:第一首是 1,第二首是 2)。只能用你自己已完成的 Suno 任務。
要從你自己的錄音開始,先用 upload 匯入,或者用 upload-cover、upload-extend,它們直接接收 audio_url。add-vocals、add-instrumental 和 sample 只接受匯入的錄音。
#工具
把工具名放在 operation,欄位放在 parameters。必填欄位已標出;價格是一首歌價格的倍數。
Create
inspoInspiration references×1.36可開 Max 模式Generate a new song from 1–4 public audio references.
audio_urls*tags
soundsSound effects×0.192Generate a sound effect from a text description.
prompt*type
mashupMashup×1可開 Max 模式Create a mashup from exactly two platform tasks.
task_ids*audio_indexestags
Start from your own audio
uploadImport audio×0.08Import external audio for use in later studio operations.
audioFilePath*
upload-coverCover your audio×1可開 Max 模式Upload audio and remake it in a new style in one step.
audio_url*customtagspromptinstrumental
upload-extendExtend your audio×1可開 Max 模式Upload audio and continue it from a chosen second.
audio_url*continue_at*prompttags
add-vocalsAdd vocals×1可開 Max 模式Layer vocals onto your uploaded instrumental or song.
task_id*audio_indexcustomprompttags
add-instrumentalAdd instrumental×1可開 Max 模式Layer an instrumental onto your uploaded vocals or song.
task_id*audio_indextags
sampleSample to song×1可開 Max 模式Generate a new song from an existing song or sample.
task_id*audio_indexstart_s*end_s*instrumentaltags
Edit a song
extendExtend song×1可開 Max 模式Continue and extend an existing song from a specified time.
task_id*audio_indexcontinue_at*prompttags
concatAssemble full song×0.08Assemble existing segments into a complete song.
task_id*audio_index
coverStyle cover×1可開 Max 模式Rearrange an existing song in a new musical style.
task_id*audio_indextags
replaceReplace section×1可開 Max 模式Regenerate the music within a specified time range.
task_id*audio_indexstart_s*end_s*infill_lyrics
remove-sectionRemove section×0.16Remove a specified time range from a song.
task_id*audio_indexstart_s*end_s*
cropCrop audio×0.16Keep only the specified time range.
task_id*audio_indexstart_s*end_s*
fade-inFade in×0.16Add a fade-in effect to the beginning of a song.
task_id*audio_indexduration_s*
fade-outFade out×0.16Add a fade-out effect to the end of a song.
task_id*audio_indexduration_s*
adjust-speedAdjust speed×0.48Change playback speed without changing pitch.
task_id*audio_indexspeed*keep_pitch
remasterRemaster×1Improve the clarity, loudness, and overall texture of a song.
task_id*audio_indexvariation_category
add-stemAdd a stem×1可開 Max 模式Layer a new stem onto an existing song.
task_id*audio_indextags
Stems, voices and models
stemsExtract a stem×2Extract a selected stem from a song.
task_id*audio_indexstem_type
stems-allSeparate all stems×4.8Separate every available stem in a song.
task_id*audio_index
personaCreate Persona×0.08Create a singer Persona from a song or Vox result.
task_id*audio_indexname*describestyles
create-voiceCreate voice×0.32Create a reusable voice from a public audio URL.
audio_url*
create-modelTrain a custom model×19.2Train a model on 6–24 of your own tracks, then use it as custom_model_id. Training can take about 20 minutes.
name*audio_urls*
voxExtract Vox×0.08已棄用Deprecated: make a Persona straight from a song instead.
task_id*audio_indexvocal_start_svocal_end_s
Export and analyse
downloadDownload audio×0.032Get a song as MP3, M4A or WAV files.
task_id*audio_indexformats
generate-mp4Generate music video×0.08Render a song as an MP4 music video.
task_id*audio_index
midiGenerate MIDI×1Convert a song into a MIDI result.
task_id*audio_index
aligned-lyricsLyrics timeline×0.016Generate a line-aligned lyrics timeline.
task_id*audio_index
bpmAnalyze BPM×0.016Analyze the tempo of a song.
task_id*audio_index
* 為必填。在工作台的「工具」裡,可以為你做過的歌自動填好這些欄位。
#價格
一首歌按目錄價收費,每次請求出兩首。工具按這個價格乘以它的倍數收費,支援的工具開 max_mode 價格翻倍。報價和預扣按這些倍數計算,任務按實際費用結算,失敗的任務全額退回。
#結果
GET /v1/music/tasks/{task_id} 隨時可查;GET /v1/music/tasks/{task_id}/content 在任務完成後回傳第一首歌的音訊檔(之前是 400)。完成的任務包含:
url第一首歌的音訊。
assets任務做出的每個檔案:type(audio、video、image、midi、archive 或 file)和 url。
data.music各首歌的 audio_url,依順序。
data.lyrics歌詞:text 和 title。
data.result工具自己的結果:music[](audio_id、title、lyrics、tags、duration、audio_url、image_url)、persona_id、model_id、upsampled_tags、avg_bpm、files、videoUrl、alignment 等。
billing任務結算後的費用。
請下載你需要的檔案:檔案保留 3 天。
#相關錯誤碼
- 400 invalid_request缺少操作需要的欄位(task_id_required、continue_at_required …)或超出範圍(style_weight_out_of_range、duration_out_of_range、max_mode_requires_custom …)。不扣費。
- 400 source_task_not_foundtask_id 不是你已完成的 Suno 任務;任務還在跑時回傳 source_task_not_ready。
- 410 media_expired任務的檔案已在 3 天後刪除。任務還沒完成就讀取 /content 會回傳 400:請改為輪詢任務。
- 404 not_found路徑不存在、模型名稱不存在,或 task_id 已過期 / 不屬於目前帳號。
- 401Bearer 權杖無效或缺失。這條路徑不帶 error.code,請依狀態碼判斷。
- 402 insufficient_user_quota錢包餘額不足以覆蓋預扣估算。
- 429帳號請求頻率上限(預設每分鐘 500 次模型請求)。請退避後重試,有 Retry-After 時按它等待。若 429 帶有 insufficient_user_quota,那是每日消費上限,不是限流。
- 503 model_not_found模型名稱不存在,或目前沒有健康的通道可以提供服務。
#請求範例
# a song: describe it
curl https://apiking.ai/v1/music/generations \
-H "Authorization: Bearer sk-YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "suno", "prompt": "a warm cinematic piano theme", "instrumental": true}'
# or write the lyrics yourself
curl https://apiking.ai/v1/music/generations \
-H "Authorization: Bearer sk-YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "suno", "custom": true, "title": "Neon Rain",
"prompt": "[Verse]\nCity lights in the rain\n[Chorus]\nWe run till dawn",
"style": "synthwave, female vocal"}'
# poll every 5s until completed
curl https://apiking.ai/v1/music/tasks/$TASK_ID -H "Authorization: Bearer sk-YOUR_KEY"
# a tool on the second song: extend it from 0:60
curl https://apiking.ai/v1/music/generations \
-H "Authorization: Bearer sk-YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "suno", "operation": "extend",
"parameters": {"task_id": "'$TASK_ID'", "audio_index": 2, "continue_at": 60}}'#回應
// POST — submit accepted
{"id": "task_xxx", "task_id": "task_xxx", "object": "music.task", "model": "suno", "status": "queued"}
// GET /v1/music/tasks/{task_id}
{
"task_id": "task_xxx",
"object": "music.task",
"operation": "music",
"status": "completed",
"progress": "100%",
"url": "https://…/audio/task_xxx",
"assets": [
{"type": "audio", "url": "https://…"},
{"type": "audio", "url": "https://…"},
{"type": "image", "url": "https://…"}
],
"data": {
"music": [{"audio_url": "https://…"}],
"lyrics": {"title": "Neon Rain", "text": "[Verse] …"},
"result": {"music": [{"audio_id": "…", "title": "Neon Rain", "duration": 182.4, "audio_url": "https://…", "image_url": "https://…"}]}
},
"billing": {"…": "…"}
}還是沒解決?
把請求 ID 或錯誤訊息傳給我們,我們來查。