Suno 文字轉音樂
使用文字轉音樂端點以建立非同步任務。
概覽
使用文字轉音樂端點配合受支援的模型。使用返回的任務 ID 來檢索其狀態,或提供 callback_url 以接收以下記錄的推送通知。
快速入門
- 建立 API 金鑰並將其設定為 RUNAPI_API_KEY。
- 選擇支援的模型,並發送主體符合該模型結構的 POST 請求。
- 儲存返回的任務 ID,然後輪詢直至達到終止狀態,或處理下方說明的回呼。
端點
- 基礎 URL
https://runapi.ai- API 版本
v1- 身份驗證
Authorization: Bearer YOUR_API_TOKEN
支援的模型
開啟模型頁面以查看當前定價、速率限制及商業用途詳情。
請求結構
欄位及允許的值取決於所選模型。提供後,callback_url 將接收以下記錄的 Task 交付內容。
suno-v415 個欄位
audio_weightnumber音訊權重(0-1)。
範圍:0 - 1
callback_urlstring用於非同步通知的 Webhook URL。
continue_atnumber繼續播放的時間戳(以秒計)。
lyricsstring演唱的確切歌詞。
邊界值:5000
modelstring模型標識符。
negative_tagsstring需要避免的風格。
persona_idstringPersona ID。
persona_typestringPersona 類型。
允許值:style, voice
promptstring用於自動生成歌詞的歌曲簡介。
邊界值:5000
stylestring音樂風格。
邊界值:1000
style_weightnumber風格遵循權重(0-1)。
範圍:0 - 1
titlestring音樂標題。
邊界值:80
vocal_genderstring人聲性別。
允許值:male, female
vocal_modestring人聲生成模式。
允許值:auto_lyrics, exact_lyrics, instrumental
weirdness_constraintnumber奇異度限制(0-1)。
範圍:0 - 1
suno-v4.515 個欄位
audio_weightnumber音訊權重(0-1)。
範圍:0 - 1
callback_urlstring用於非同步通知的 Webhook URL。
continue_atnumber繼續播放的時間戳(以秒計)。
lyricsstring演唱的確切歌詞。
邊界值:5000
modelstring模型標識符。
negative_tagsstring需要避免的風格。
persona_idstringPersona ID。
persona_typestringPersona 類型。
允許值:style, voice
promptstring用於自動生成歌詞的歌曲簡介。
邊界值:5000
stylestring音樂風格。
邊界值:1000
style_weightnumber風格遵循權重(0-1)。
範圍:0 - 1
titlestring音樂標題。
邊界值:80
vocal_genderstring人聲性別。
允許值:male, female
vocal_modestring人聲生成模式。
允許值:auto_lyrics, exact_lyrics, instrumental
weirdness_constraintnumber奇異度限制(0-1)。
範圍:0 - 1
suno-v4.5-all15 個欄位
audio_weightnumber音訊權重(0-1)。
範圍:0 - 1
callback_urlstring用於非同步通知的 Webhook URL。
continue_atnumber繼續播放的時間戳(以秒計)。
lyricsstring演唱的確切歌詞。
邊界值:5000
modelstring模型標識符。
negative_tagsstring需要避免的風格。
persona_idstringPersona ID。
persona_typestringPersona 類型。
允許值:style, voice
promptstring用於自動生成歌詞的歌曲簡介。
邊界值:5000
stylestring音樂風格。
邊界值:1000
style_weightnumber風格遵循權重(0-1)。
範圍:0 - 1
titlestring音樂標題。
邊界值:80
vocal_genderstring人聲性別。
允許值:male, female
vocal_modestring人聲生成模式。
允許值:auto_lyrics, exact_lyrics, instrumental
weirdness_constraintnumber奇異度限制(0-1)。
範圍:0 - 1
suno-v4.5-plus15 個欄位
audio_weightnumber音訊權重(0-1)。
範圍:0 - 1
callback_urlstring用於非同步通知的 Webhook URL。
continue_atnumber繼續播放的時間戳(以秒計)。
lyricsstring演唱的確切歌詞。
邊界值:5000
modelstring模型標識符。
negative_tagsstring需要避免的風格。
persona_idstringPersona ID。
persona_typestringPersona 類型。
允許值:style, voice
promptstring用於自動生成歌詞的歌曲簡介。
邊界值:5000
stylestring音樂風格。
邊界值:1000
style_weightnumber風格遵循權重(0-1)。
範圍:0 - 1
titlestring音樂標題。
邊界值:80
vocal_genderstring人聲性別。
允許值:male, female
vocal_modestring人聲生成模式。
允許值:auto_lyrics, exact_lyrics, instrumental
weirdness_constraintnumber奇異度限制(0-1)。
範圍:0 - 1
suno-v515 個欄位
audio_weightnumber音訊權重(0-1)。
範圍:0 - 1
callback_urlstring用於非同步通知的 Webhook URL。
continue_atnumber繼續播放的時間戳(以秒計)。
lyricsstring演唱的確切歌詞。
邊界值:5000
modelstring模型標識符。
negative_tagsstring需要避免的風格。
persona_idstringPersona ID。
persona_typestringPersona 類型。
允許值:style, voice
promptstring用於自動生成歌詞的歌曲簡介。
邊界值:5000
stylestring音樂風格。
邊界值:1000
style_weightnumber風格遵循權重(0-1)。
範圍:0 - 1
titlestring音樂標題。
邊界值:80
vocal_genderstring人聲性別。
允許值:male, female
vocal_modestring人聲生成模式。
允許值:auto_lyrics, exact_lyrics, instrumental
weirdness_constraintnumber奇異度限制(0-1)。
範圍:0 - 1
suno-v5.516 個欄位
audio_weightnumber音訊權重(0-1)。
範圍:0 - 1
callback_urlstring用於非同步通知的 Webhook URL。
continue_atnumber繼續播放的時間戳(以秒計)。
duration_secondsinteger首選時長(秒);僅適用於 Suno V5.5 自訂請求。
範圍:10 - 360
lyricsstring演唱的確切歌詞。
邊界值:5000
modelstring模型標識符。
negative_tagsstring需要避免的風格。
persona_idstringPersona ID。
persona_typestringPersona 類型。
允許值:style, voice
promptstring用於自動生成歌詞的歌曲簡介。
邊界值:5000
stylestring音樂風格。
邊界值:1000
style_weightnumber風格遵循權重(0-1)。
範圍:0 - 1
titlestring音樂標題。
邊界值:80
vocal_genderstring人聲性別。
允許值:male, female
vocal_modestring人聲生成模式。
允許值:auto_lyrics, exact_lyrics, instrumental
weirdness_constraintnumber奇異度限制(0-1)。
範圍:0 - 1
條件規則
當所有列出的條件均符合時,這些要求方才適用。
-
當
vocal_mode = auto_lyrics- 必填
prompt- 不接受
lyrics,style,title,negative_tags,vocal_gender,duration_seconds
-
當
vocal_mode = exact_lyrics- 必填
lyrics,style,title- 不接受
prompt
-
當
vocal_mode = instrumental- 必填
style,title- 不接受
prompt,lyrics,vocal_gender
-
當
model = suno-v4- 必填
- 不接受
duration_seconds
-
當
model = suno-v4.5- 必填
- 不接受
duration_seconds
-
當
model = suno-v4.5-all- 必填
- 不接受
duration_seconds
-
當
model = suno-v4.5-plus- 必填
- 不接受
duration_seconds
-
當
model = suno-v5- 必填
- 不接受
duration_seconds
建立接受
POST /api/v1/suno/text_to_music
回應結構
{
"properties": {
"billing": {
"properties": {
"refund": {
"oneOf": [
{
"properties": {
"refunded_at": {
"type": "string"
}
},
"required": [
"refunded_at"
],
"type": "object",
"unevaluatedProperties": false
},
{
"enum": [
null
]
}
]
},
"reservation": {
"oneOf": [
{
"properties": {
"amount_cents": {
"type": "integer"
}
},
"required": [
"amount_cents"
],
"type": "object",
"unevaluatedProperties": false
},
{
"enum": [
null
]
}
]
},
"settlement": {
"oneOf": [
{
"properties": {
"amount_micro_cents": {
"type": "integer"
},
"charged_amount_cents": {
"type": "integer"
}
},
"required": [
"charged_amount_cents",
"amount_micro_cents"
],
"type": "object",
"unevaluatedProperties": false
},
{
"enum": [
null
]
}
]
}
},
"required": [
"reservation",
"settlement",
"refund"
],
"type": "object",
"unevaluatedProperties": false
},
"id": {
"type": "string"
},
"status": {
"enum": [
"processing"
],
"type": "string"
},
"task_replayed": {
"type": "boolean"
}
},
"required": [
"id",
"status",
"billing"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"billing": {
"refund": null,
"reservation": null,
"settlement": null
},
"id": "tsk_reference_demo",
"status": "processing"
}
輪詢處理中
GET /api/v1/suno/text_to_music/:id
回應結構
{
"properties": {
"audios": {
"items": {
"properties": {
"audio_url": {
"type": "string",
"x-runapi-generated-media": true
},
"duration": {
"type": "number"
},
"id": {
"type": "string"
},
"image_url": {
"type": "string",
"x-runapi-generated-media": true
},
"lyrics": {
"type": "string"
},
"model_name": {
"type": "string"
},
"stream_audio_url": {
"type": "string",
"x-runapi-generated-media": true
},
"tags": {
"items": {
"type": "string"
},
"type": "array"
},
"title": {
"type": "string"
}
},
"required": [
"id"
],
"type": "object",
"unevaluatedProperties": false
},
"type": "array"
},
"billing": {
"properties": {
"refund": {
"oneOf": [
{
"properties": {
"refunded_at": {
"type": "string"
}
},
"required": [
"refunded_at"
],
"type": "object",
"unevaluatedProperties": false
},
{
"enum": [
null
]
}
]
},
"reservation": {
"oneOf": [
{
"properties": {
"amount_cents": {
"type": "integer"
}
},
"required": [
"amount_cents"
],
"type": "object",
"unevaluatedProperties": false
},
{
"enum": [
null
]
}
]
},
"settlement": {
"oneOf": [
{
"properties": {
"amount_micro_cents": {
"type": "integer"
},
"charged_amount_cents": {
"type": "integer"
}
},
"required": [
"charged_amount_cents",
"amount_micro_cents"
],
"type": "object",
"unevaluatedProperties": false
},
{
"enum": [
null
]
}
]
}
},
"required": [
"reservation",
"settlement",
"refund"
],
"type": "object",
"unevaluatedProperties": false
},
"generation_stage": {
"enum": [
"text_generated",
"first_audio_ready"
],
"type": "string"
},
"id": {
"type": "string"
},
"status": {
"enum": [
"processing"
],
"type": "string"
}
},
"required": [
"id",
"status",
"billing"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"billing": {
"refund": null,
"reservation": null,
"settlement": null
},
"generation_stage": "text_generated",
"id": "tsk_reference_demo",
"status": "processing"
}
輪詢已完成
GET /api/v1/suno/text_to_music/:id
回應結構
{
"properties": {
"audios": {
"items": {
"properties": {
"audio_url": {
"type": "string",
"x-runapi-generated-media": true
},
"duration": {
"type": "number"
},
"id": {
"type": "string"
},
"image_url": {
"type": "string",
"x-runapi-generated-media": true
},
"lyrics": {
"type": "string"
},
"model_name": {
"type": "string"
},
"stream_audio_url": {
"type": "string",
"x-runapi-generated-media": true
},
"tags": {
"items": {
"type": "string"
},
"type": "array"
},
"title": {
"type": "string"
}
},
"required": [
"id"
],
"type": "object",
"unevaluatedProperties": false
},
"type": "array"
},
"billing": {
"properties": {
"refund": {
"oneOf": [
{
"properties": {
"refunded_at": {
"type": "string"
}
},
"required": [
"refunded_at"
],
"type": "object",
"unevaluatedProperties": false
},
{
"enum": [
null
]
}
]
},
"reservation": {
"oneOf": [
{
"properties": {
"amount_cents": {
"type": "integer"
}
},
"required": [
"amount_cents"
],
"type": "object",
"unevaluatedProperties": false
},
{
"enum": [
null
]
}
]
},
"settlement": {
"oneOf": [
{
"properties": {
"amount_micro_cents": {
"type": "integer"
},
"charged_amount_cents": {
"type": "integer"
}
},
"required": [
"charged_amount_cents",
"amount_micro_cents"
],
"type": "object",
"unevaluatedProperties": false
},
{
"enum": [
null
]
}
]
}
},
"required": [
"reservation",
"settlement",
"refund"
],
"type": "object",
"unevaluatedProperties": false
},
"generation_stage": {
"enum": [
"text_generated",
"first_audio_ready",
"all_audios_ready",
"failed"
],
"type": "string"
},
"id": {
"type": "string"
},
"status": {
"enum": [
"completed"
],
"type": "string"
}
},
"required": [
"id",
"status",
"audios",
"billing"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"audios": [
{
"audio_url": "https://file.runapi.ai/reference-audio.mp3",
"id": "audio_reference"
}
],
"billing": {
"refund": null,
"reservation": null,
"settlement": null
},
"id": "tsk_reference_demo",
"status": "completed"
}
輪詢失敗
GET /api/v1/suno/text_to_music/:id
回應結構
{
"properties": {
"billing": {
"properties": {
"refund": {
"oneOf": [
{
"properties": {
"refunded_at": {
"type": "string"
}
},
"required": [
"refunded_at"
],
"type": "object",
"unevaluatedProperties": false
},
{
"enum": [
null
]
}
]
},
"reservation": {
"oneOf": [
{
"properties": {
"amount_cents": {
"type": "integer"
}
},
"required": [
"amount_cents"
],
"type": "object",
"unevaluatedProperties": false
},
{
"enum": [
null
]
}
]
},
"settlement": {
"oneOf": [
{
"properties": {
"amount_micro_cents": {
"type": "integer"
},
"charged_amount_cents": {
"type": "integer"
}
},
"required": [
"charged_amount_cents",
"amount_micro_cents"
],
"type": "object",
"unevaluatedProperties": false
},
{
"enum": [
null
]
}
]
}
},
"required": [
"reservation",
"settlement",
"refund"
],
"type": "object",
"unevaluatedProperties": false
},
"error": {
"type": "string"
},
"id": {
"type": "string"
},
"status": {
"enum": [
"failed"
],
"type": "string"
}
},
"required": [
"id",
"status",
"error",
"billing"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"billing": {
"refund": null,
"reservation": null,
"settlement": null
},
"error": "Task processing failed.",
"id": "tsk_reference_demo",
"status": "failed"
}
客戶回呼:處理中
POST callback_url
回應結構
{
"properties": {
"audios": {
"items": {
"properties": {
"audio_url": {
"type": "string",
"x-runapi-generated-media": true
},
"duration": {
"type": "number"
},
"id": {
"type": "string"
},
"image_url": {
"type": "string",
"x-runapi-generated-media": true
},
"lyrics": {
"type": "string"
},
"model_name": {
"type": "string"
},
"stream_audio_url": {
"type": "string",
"x-runapi-generated-media": true
},
"tags": {
"items": {
"type": "string"
},
"type": "array"
},
"title": {
"type": "string"
}
},
"required": [
"id"
],
"type": "object",
"unevaluatedProperties": false
},
"type": "array"
},
"generation_stage": {
"enum": [
"text_generated",
"first_audio_ready"
],
"type": "string"
},
"id": {
"type": "string"
},
"status": {
"enum": [
"processing"
],
"type": "string"
}
},
"required": [
"id",
"status"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"generation_stage": "text_generated",
"id": "tsk_reference_demo",
"status": "processing"
}
客戶回呼:已完成
POST callback_url
回應結構
{
"properties": {
"audios": {
"items": {
"properties": {
"audio_url": {
"type": "string",
"x-runapi-generated-media": true
},
"duration": {
"type": "number"
},
"id": {
"type": "string"
},
"image_url": {
"type": "string",
"x-runapi-generated-media": true
},
"lyrics": {
"type": "string"
},
"model_name": {
"type": "string"
},
"stream_audio_url": {
"type": "string",
"x-runapi-generated-media": true
},
"tags": {
"items": {
"type": "string"
},
"type": "array"
},
"title": {
"type": "string"
}
},
"required": [
"id"
],
"type": "object",
"unevaluatedProperties": false
},
"type": "array"
},
"generation_stage": {
"enum": [
"text_generated",
"first_audio_ready",
"all_audios_ready",
"failed"
],
"type": "string"
},
"id": {
"type": "string"
},
"status": {
"enum": [
"completed"
],
"type": "string"
}
},
"required": [
"id",
"status",
"audios"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"audios": [
{
"audio_url": "https://file.runapi.ai/reference-audio.mp3",
"id": "audio_reference"
}
],
"id": "tsk_reference_demo",
"status": "completed"
}
客戶回呼:已失敗
POST callback_url
回應結構
{
"properties": {
"error": {
"oneOf": [
{
"type": "string"
},
{
"properties": {
"code": {
"type": "string"
},
"limit_cents": {
"type": "integer"
},
"message": {
"type": "string"
},
"reset_at": {
"format": "date-time",
"type": [
"string",
"null"
]
},
"used_cents": {
"type": "integer"
},
"window": {
"enum": [
"1h",
"1d",
"7d",
"daily",
"weekly",
"monthly",
"lifetime"
],
"type": "string"
}
},
"required": [
"code",
"message"
],
"type": "object",
"unevaluatedProperties": false
}
]
},
"id": {
"type": "string"
},
"status": {
"enum": [
"failed"
],
"type": "string"
}
},
"required": [
"id",
"status",
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"error": {
"code": "generation_failed",
"message": "Task processing failed."
},
"id": "tsk_reference_demo",
"status": "failed"
}
錯誤
POST /api/v1/suno/text_to_music
回應結構
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"error": "Authentication required"
}
錯誤
GET /api/v1/suno/text_to_music/:id
回應結構
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"error": "Authentication required"
}
錯誤
POST /api/v1/suno/text_to_music
回應結構
{
"oneOf": [
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
},
{
"properties": {
"error": {
"description": "人類可讀的驗證摘要。",
"type": "string"
},
"errors": {
"additionalProperties": {
"items": {
"type": "string"
},
"type": "array"
},
"description": "以公開請求欄位為鍵的驗證訊息,每個欄位對應一組人類可讀的字串陣列。",
"type": "object"
}
},
"required": [
"error",
"errors"
],
"type": "object",
"unevaluatedProperties": false
}
]
}
回應範例
{
"error": "Validation failed",
"errors": {
"prompt": [
"is required"
]
}
}
錯誤
POST /api/v1/suno/text_to_music
回應結構
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"error": "Insufficient balance"
}
錯誤
POST /api/v1/suno/text_to_music
回應結構
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"error": "API key credit limit exceeded"
}
錯誤
POST /api/v1/suno/text_to_music
回應結構
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"error": "The request uses features that are not supported for the selected model"
}
錯誤
POST /api/v1/suno/text_to_music
回應結構
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"error": "Rate limit reached. Please retry later."
}
錯誤
POST /api/v1/suno/text_to_music
回應結構
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"error": "Service under maintenance, please try again later"
}
錯誤
POST /api/v1/suno/text_to_music
回應結構
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"error": "The request timed out"
}
錯誤
GET /api/v1/suno/text_to_music/:id
回應結構
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"error": "Task with id 'tsk_reference_demo' not found"
}
已生成的程式碼範例
直接使用 cURL,或為您的語言安裝 SDK。每個範例均提交本參考中所示的已驗證請求。
安裝
pip install runapi-suno
import os
from runapi.suno import SunoClient
client = SunoClient(api_key=os.environ["RUNAPI_API_KEY"])
task = client.text_to_music.create(
model="suno-v5",
vocal_mode="auto_lyrics",
prompt="An uplifting acoustic pop song about a rainy city night.",
persona_id="persona_reference",
persona_type="style"
)