curl --request POST \
--url https://api.sunoapi.org/api/v1/generate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"customMode": true,
"instrumental": true,
"model": "V4_5ALL",
"callBackUrl": "https://api.example.com/callback",
"prompt": "A calm and relaxing piano track with soft melodies",
"style": "Classical",
"title": "Peaceful Piano Meditation",
"personaId": "persona_123",
"personaModel": "style_persona",
"duration": 60,
"negativeTags": "Heavy Metal, Upbeat Drums",
"vocalGender": "m",
"styleWeight": 0.65,
"weirdnessConstraint": 0.65,
"audioWeight": 0.65
}
'import requests
url = "https://api.sunoapi.org/api/v1/generate"
payload = {
"customMode": True,
"instrumental": True,
"model": "V4_5ALL",
"callBackUrl": "https://api.example.com/callback",
"prompt": "A calm and relaxing piano track with soft melodies",
"style": "Classical",
"title": "Peaceful Piano Meditation",
"personaId": "persona_123",
"personaModel": "style_persona",
"duration": 60,
"negativeTags": "Heavy Metal, Upbeat Drums",
"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({
customMode: true,
instrumental: true,
model: 'V4_5ALL',
callBackUrl: 'https://api.example.com/callback',
prompt: 'A calm and relaxing piano track with soft melodies',
style: 'Classical',
title: 'Peaceful Piano Meditation',
personaId: 'persona_123',
personaModel: 'style_persona',
duration: 60,
negativeTags: 'Heavy Metal, Upbeat Drums',
vocalGender: 'm',
styleWeight: 0.65,
weirdnessConstraint: 0.65,
audioWeight: 0.65
})
};
fetch('https://api.sunoapi.org/api/v1/generate', 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",
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([
'customMode' => true,
'instrumental' => true,
'model' => 'V4_5ALL',
'callBackUrl' => 'https://api.example.com/callback',
'prompt' => 'A calm and relaxing piano track with soft melodies',
'style' => 'Classical',
'title' => 'Peaceful Piano Meditation',
'personaId' => 'persona_123',
'personaModel' => 'style_persona',
'duration' => 60,
'negativeTags' => 'Heavy Metal, Upbeat Drums',
'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"
payload := strings.NewReader("{\n \"customMode\": true,\n \"instrumental\": true,\n \"model\": \"V4_5ALL\",\n \"callBackUrl\": \"https://api.example.com/callback\",\n \"prompt\": \"A calm and relaxing piano track with soft melodies\",\n \"style\": \"Classical\",\n \"title\": \"Peaceful Piano Meditation\",\n \"personaId\": \"persona_123\",\n \"personaModel\": \"style_persona\",\n \"duration\": 60,\n \"negativeTags\": \"Heavy Metal, Upbeat Drums\",\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")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"customMode\": true,\n \"instrumental\": true,\n \"model\": \"V4_5ALL\",\n \"callBackUrl\": \"https://api.example.com/callback\",\n \"prompt\": \"A calm and relaxing piano track with soft melodies\",\n \"style\": \"Classical\",\n \"title\": \"Peaceful Piano Meditation\",\n \"personaId\": \"persona_123\",\n \"personaModel\": \"style_persona\",\n \"duration\": 60,\n \"negativeTags\": \"Heavy Metal, Upbeat Drums\",\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")
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 \"customMode\": true,\n \"instrumental\": true,\n \"model\": \"V4_5ALL\",\n \"callBackUrl\": \"https://api.example.com/callback\",\n \"prompt\": \"A calm and relaxing piano track with soft melodies\",\n \"style\": \"Classical\",\n \"title\": \"Peaceful Piano Meditation\",\n \"personaId\": \"persona_123\",\n \"personaModel\": \"style_persona\",\n \"duration\": 60,\n \"negativeTags\": \"Heavy Metal, Upbeat Drums\",\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"
}
}Generate Suno AI Music
curl --request POST \
--url https://api.sunoapi.org/api/v1/generate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"customMode": true,
"instrumental": true,
"model": "V4_5ALL",
"callBackUrl": "https://api.example.com/callback",
"prompt": "A calm and relaxing piano track with soft melodies",
"style": "Classical",
"title": "Peaceful Piano Meditation",
"personaId": "persona_123",
"personaModel": "style_persona",
"duration": 60,
"negativeTags": "Heavy Metal, Upbeat Drums",
"vocalGender": "m",
"styleWeight": 0.65,
"weirdnessConstraint": 0.65,
"audioWeight": 0.65
}
'import requests
url = "https://api.sunoapi.org/api/v1/generate"
payload = {
"customMode": True,
"instrumental": True,
"model": "V4_5ALL",
"callBackUrl": "https://api.example.com/callback",
"prompt": "A calm and relaxing piano track with soft melodies",
"style": "Classical",
"title": "Peaceful Piano Meditation",
"personaId": "persona_123",
"personaModel": "style_persona",
"duration": 60,
"negativeTags": "Heavy Metal, Upbeat Drums",
"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({
customMode: true,
instrumental: true,
model: 'V4_5ALL',
callBackUrl: 'https://api.example.com/callback',
prompt: 'A calm and relaxing piano track with soft melodies',
style: 'Classical',
title: 'Peaceful Piano Meditation',
personaId: 'persona_123',
personaModel: 'style_persona',
duration: 60,
negativeTags: 'Heavy Metal, Upbeat Drums',
vocalGender: 'm',
styleWeight: 0.65,
weirdnessConstraint: 0.65,
audioWeight: 0.65
})
};
fetch('https://api.sunoapi.org/api/v1/generate', 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",
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([
'customMode' => true,
'instrumental' => true,
'model' => 'V4_5ALL',
'callBackUrl' => 'https://api.example.com/callback',
'prompt' => 'A calm and relaxing piano track with soft melodies',
'style' => 'Classical',
'title' => 'Peaceful Piano Meditation',
'personaId' => 'persona_123',
'personaModel' => 'style_persona',
'duration' => 60,
'negativeTags' => 'Heavy Metal, Upbeat Drums',
'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"
payload := strings.NewReader("{\n \"customMode\": true,\n \"instrumental\": true,\n \"model\": \"V4_5ALL\",\n \"callBackUrl\": \"https://api.example.com/callback\",\n \"prompt\": \"A calm and relaxing piano track with soft melodies\",\n \"style\": \"Classical\",\n \"title\": \"Peaceful Piano Meditation\",\n \"personaId\": \"persona_123\",\n \"personaModel\": \"style_persona\",\n \"duration\": 60,\n \"negativeTags\": \"Heavy Metal, Upbeat Drums\",\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")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"customMode\": true,\n \"instrumental\": true,\n \"model\": \"V4_5ALL\",\n \"callBackUrl\": \"https://api.example.com/callback\",\n \"prompt\": \"A calm and relaxing piano track with soft melodies\",\n \"style\": \"Classical\",\n \"title\": \"Peaceful Piano Meditation\",\n \"personaId\": \"persona_123\",\n \"personaModel\": \"style_persona\",\n \"duration\": 60,\n \"negativeTags\": \"Heavy Metal, Upbeat Drums\",\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")
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 \"customMode\": true,\n \"instrumental\": true,\n \"model\": \"V4_5ALL\",\n \"callBackUrl\": \"https://api.example.com/callback\",\n \"prompt\": \"A calm and relaxing piano track with soft melodies\",\n \"style\": \"Classical\",\n \"title\": \"Peaceful Piano Meditation\",\n \"personaId\": \"persona_123\",\n \"personaModel\": \"style_persona\",\n \"duration\": 60,\n \"negativeTags\": \"Heavy Metal, Upbeat Drums\",\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"
}
}- Stream URL: Available in 30-40 seconds.
- Downloadable song URL: Ready in 2-3 minutes.
Parameter Usage Guide
- When customMode is true (Custom Mode):
- If instrumental is true: style and title are required
- If instrumental is false: style, prompt, and title are required
- Prompt length limit:
- For V4 model: 3000 characters
- For V4_5, V4_5PLUS, V4_5ALL, V5 and V5_5 models: 5000 characters
- Style length limit:
- For V4 model: 200 characters
- For V4_5, V4_5PLUS, V4_5ALL, V5 and V5_5 models: 1000 characters
- Title length limit:
- For V4 and V4_5ALL model: 80 characters
- For V4_5, V4_5PLUS, V5 and V5_5 models: 100 characters
- When customMode is false (Non-custom Mode):
- Only prompt is required regardless of instrumental setting
- prompt length limit: 3000 characters
- Other parameters should be left empty
Optional Parameters
- personaId (string): Persona ID or Suno Voice
voiceIdto apply in Custom Mode. If you use a Voice-generated ID, setpersonaModeltovoice_persona. - personaModel (string): Persona type. Use
style_personafor Generate Persona IDs, orvoice_personafor Suno Voice IDs.
Developer Notes
- Recommendation for First-Time Users: Start with customMode: false and instrumental: false, and only provide a prompt. This is the simplest setup to quickly test the API and experience the results.
- Generated files are retained for 15 days before being deleted
- Ensure all required fields are provided based on the customMode and instrumental settings to avoid errors
- Respect the character limits for prompt, style, and title to ensure successful processing
- Callback process has three stages: text (text generation), first (first track complete), complete (all tracks complete)
- You can use the Get Music Generation Details endpoint to actively check task status instead of waiting for callbacks
Authorizations
🔑 API Authentication
All endpoints require authentication using Bearer Token.
Get API Key
- Visit the API Key Management Page to obtain your API Key
Usage
Add to request headers:
Authorization: Bearer YOUR_API_KEY
⚠️ Note:
- Keep your API Key secure and do not share it with others
- If you suspect your API Key has been compromised, reset it immediately from the management page
Body
Enables Custom Mode for advanced audio generation settings.
- Set to
trueto use Custom Mode (requiresstyleandtitle;promptrequired ifinstrumentalisfalse). The prompt will be strictly used as lyrics ifinstrumentalisfalse. - Set to
falsefor Non-custom Mode (onlypromptis required). Lyrics will be auto-generated based on the prompt.
true
Determines if the audio should be instrumental (no lyrics).
- In Custom Mode (
customMode: true):- If
true: Onlystyleandtitleare required. - If
false:style,title, andpromptare required (withpromptused as the exact lyrics).
- If
- In Non-custom Mode (
customMode: false): No impact on required fields (promptonly). Lyrics are auto-generated ifinstrumentalisfalse.
true
The model version to use for audio generation.
- Available options:
V5_5: Unleash Your Voice: Custom Models Tailored to Your Unique Taste.V5: Superior musical expression, faster generation.V4_5PLUS: V4.5+ is richer sound, new ways to create, max 8 min.V4_5ALL: V4.5-all is better song structure, max 8 min.V4_5: Superior genre blending with smarter prompts and faster output, up to 8 minutes.V4: Best audio quality with refined song structure, up to 4 minutes.
V4, V4_5, V4_5PLUS, V4_5ALL, V5, V5_5 "V4_5ALL"
The URL to receive task completion notifications when music generation is complete.
- For detailed callback format and implementation guide, see Music Generation Callbacks
- Alternatively, you can use the get music generation details endpoint to poll task status
"https://api.example.com/callback"
A description of the desired audio content.
- In Custom Mode (
customMode: true): Required ifinstrumentalisfalse. The prompt will be strictly used as the lyrics and sung in the generated track. Character limits by model:- V4: Maximum 3000 characters
- V4_5, V4_5PLUS, V4_5ALL, V5 & V5_5: Maximum 5000 characters
Example: "A calm and relaxing piano track with soft melodies"
- In Non-custom Mode (
customMode: false): Always required. The prompt serves as the core idea, and lyrics will be automatically generated based on it (not strictly matching the input). Maximum 3000 characters.
Example: "A short relaxing piano tune"
"A calm and relaxing piano track with soft melodies"
The music style or genre for the audio.
- Required in Custom Mode (
customMode: true). Examples: "Jazz", "Classical", "Electronic".- For V4 model: Max length: 200 characters.
- For V4_5, V4_5PLUS, V4_5ALL, V5 and V5_5 models: Max length: 1000 characters.
Example: "Classical"
- In Non-custom Mode (
customMode: false): Leave empty.
"Classical"
The title of the generated music track.
- Required in Custom Mode (
customMode: true). Character limits by model:- V4 & V4_5ALL: Maximum 80 characters
- V4_5, V4_5PLUS, V5 & V5_5: Maximum 100 characters
Example: "Peaceful Piano Meditation"
- In Non-custom Mode (
customMode: false): Leave empty.
"Peaceful Piano Meditation"
Only available when custom parameters are enabled. Persona ID to apply to the generated music. Optional. You can use either:
- A Persona ID generated by the Generate Persona endpoint. Use
personaModel: style_personaor omitpersonaModelto use the default. - A
voiceIdgenerated by the Suno Voice workflow. When using a voice-generated ID, you must setpersonaModel: voice_persona.
"persona_123"
Persona model type to apply when using personaId. Optional.
style_persona(default): Use this for Persona IDs generated by the Generate Persona endpoint.voice_persona: Use this whenpersonaIdis avoiceIdgenerated by Suno Voice. This option is only available with V5 and V5_5 models.
style_persona, voice_persona "style_persona"
Audio duration in seconds. Optional. Only supported when model is V5_5 and customMode is true. Range: 10–360 seconds. Must be an integer.
10 <= x <= 360Must be a multiple of 160
Music styles or traits to exclude from the generated audio.
- Optional. Use to avoid specific styles.
Example: "Heavy Metal, Upbeat Drums"
"Heavy Metal, Upbeat Drums"
Preferred vocal gender for generated vocals. Optional.
m, f "m"
Weight of the provided style guidance. Range 0.00–1.00.
0 <= x <= 1Must be a multiple of 0.010.65
Constraint on creative deviation/novelty. Range 0.00–1.00.
0 <= x <= 1Must be a multiple of 0.010.65
Weight of the input audio influence (where applicable). Range 0.00–1.00.
0 <= x <= 1Must be a multiple of 0.010.65
Callbacks
Response
Request successful
Status Codes
- ✅ 200 - Request successful
- ⚠️ 400 - Invalid parameters
- ⚠️ 401 - Unauthorized access
- ⚠️ 404 - Invalid request method or path
- ⚠️ 405 - Rate limit exceeded
- ⚠️ 413 - Theme or prompt too long
- ⚠️ 429 - Insufficient credits
- ⚠️ 430 - Your call frequency is too high. Please try again later.
- ⚠️ 455 - System maintenance
- ❌ 500 - Server error
200, 400, 401, 404, 405, 413, 429, 430, 455, 500 200
Error message when code != 200
"success"
Show child attributes
Show child attributes
