Welcome to Suno API
Suno API is powered by advanced AI models to provide comprehensive music generation and audio processing services. Whether you need music creation, lyrics generation, audio editing, or vocal separation, our API meets all your creative needs.
Authentication
All API requests require authentication using a Bearer token. Please obtain your API key from the API Key Management page .
Keep your API key secure and never share it publicly. If you suspect your key has been compromised, reset it immediately.
API Base URL
Authorization : Bearer YOUR_API_KEY
Quick Start Guide
Step 1: Generate Your First Song
Start with a simple music generation request:
curl -X POST "https://api.sunoapi.org/api/v1/generate" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A peaceful acoustic guitar melody with soft vocals, folk style",
"customMode": false,
"instrumental": false,
"model": "V3_5",
"callBackUrl": "https://your-server.com/callback"
}'
Step 2: Check Task Status
Use the returned task ID to check generation status:
curl -X GET "https://api.sunoapi.org/api/v1/generate/record-info?taskId=YOUR_TASK_ID" \
-H "Authorization: Bearer YOUR_API_KEY"
Success Response:
{
"code" : 200 ,
"msg" : "success" ,
"data" : {
"taskId" : "suno_task_abc123"
}
}
Task Status Response:
{
"code" : 200 ,
"msg" : "success" ,
"data" : {
"taskId" : "suno_task_abc123" ,
"status" : "SUCCESS" ,
"response" : {
"data" : [
{
"id" : "audio_123" ,
"audio_url" : "https://example.com/generated-music.mp3" ,
"title" : "Generated Song" ,
"tags" : "folk, acoustic" ,
"duration" : 180.5
}
]
}
}
}
Core Features
Music Generation
Create complete songs from text descriptions:
{
"prompt" : "An upbeat electronic dance track with synth leads" ,
"customMode" : true ,
"style" : "Electronic Dance" ,
"title" : "Digital Dreams" ,
"instrumental" : false ,
"model" : "V4_5"
}
Lyrics Creation
Generate AI-powered lyrics independently:
{
"prompt" : "A song about overcoming challenges and finding inner strength" ,
"callBackUrl" : "https://your-server.com/lyrics-callback"
}
Audio Extension
Extend existing music tracks:
{
"audioId" : "e231****-****-****-****-****8cadc7dc" ,
"defaultParamFlag" : true ,
"prompt" : "Continue with a guitar solo" ,
"continueAt" : 120 ,
"model" : "V3_5"
}
Upload and Cover
Transform existing audio with new styles:
{
"uploadUrl" : "https://example.com/original-audio.mp3" ,
"customMode" : true ,
"style" : "Jazz" ,
"title" : "Jazz Version" ,
"prompt" : "Transform into smooth jazz style"
}
Model Versions
Choose the right model for your needs:
V3_5 Balanced Solid arrangements with creative diversity, up to 4 minutes
V4 High Quality Best audio quality with refined song structure, up to 4 minutes
V4_5 Advanced Superior genre blending with smarter prompts, up to 8 minutes
Key Parameters
Text description for music generation. Provide detailed, specific descriptions for better results. Prompt Tips:
Describe musical style and genre
Include mood and atmosphere
Specify instruments and vocals
Add tempo and energy descriptions
Model version to use:
V3_5
- Creative diversity, up to 4 minutes
V4
- Best audio quality, up to 4 minutes
V4_5
- Advanced features, up to 8 minutes
Enable custom parameter mode for advanced control. When true
, requires additional parameters like style
and title
.
Generate instrumental-only music without vocals. Default is false
.
Music style or genre (required in custom mode). Examples: “Jazz”, “Rock”, “Classical”, “Electronic”
Song title (required in custom mode). Maximum 80 characters.
URL to receive completion notifications. See callback documentation for details.
Complete Workflow Example
Here’s a complete music generation and processing example:
class SunoAPI {
constructor ( apiKey ) {
this . apiKey = apiKey ;
this . baseUrl = 'https://api.sunoapi.org/api/v1' ;
}
async generateMusic ( options ) {
const response = await fetch ( ` ${ this . baseUrl } /generate` , {
method: 'POST' ,
headers: {
'Authorization' : `Bearer ${ this . apiKey } ` ,
'Content-Type' : 'application/json'
},
body: JSON . stringify ( options )
});
const result = await response . json ();
if ( result . code !== 200 ) {
throw new Error ( `Generation failed: ${ result . msg } ` );
}
return result . data . taskId ;
}
async generateLyrics ( prompt ) {
const response = await fetch ( ` ${ this . baseUrl } /lyrics` , {
method: 'POST' ,
headers: {
'Authorization' : `Bearer ${ this . apiKey } ` ,
'Content-Type' : 'application/json'
},
body: JSON . stringify ({
prompt ,
callBackUrl: 'https://your-server.com/lyrics-callback'
})
});
const result = await response . json ();
return result . data . taskId ;
}
async waitForCompletion ( taskId , maxWaitTime = 600000 ) { // 10 minutes max
const startTime = Date . now ();
while ( Date . now () - startTime < maxWaitTime ) {
const status = await this . getTaskStatus ( taskId );
if ( status . status === 'SUCCESS' ) {
return status . response ;
} else if ( status . status === 'FAILED' ) {
throw new Error ( `Generation failed: ${ status . errorMessage } ` );
}
// Wait 30 seconds before checking again
await new Promise ( resolve => setTimeout ( resolve , 30000 ));
}
throw new Error ( 'Generation timeout' );
}
async getTaskStatus ( taskId ) {
const response = await fetch ( ` ${ this . baseUrl } /generate/record-info?taskId= ${ taskId } ` , {
headers: {
'Authorization' : `Bearer ${ this . apiKey } `
}
});
const result = await response . json ();
return result . data ;
}
async extendMusic ( audioId , options ) {
const response = await fetch ( ` ${ this . baseUrl } /generate/extend` , {
method: 'POST' ,
headers: {
'Authorization' : `Bearer ${ this . apiKey } ` ,
'Content-Type' : 'application/json'
},
body: JSON . stringify ({
audioId ,
... options
})
});
const result = await response . json ();
return result . data . taskId ;
}
async separateVocals ( taskId , audioId ) {
const response = await fetch ( ` ${ this . baseUrl } /vocal-removal/generate` , {
method: 'POST' ,
headers: {
'Authorization' : `Bearer ${ this . apiKey } ` ,
'Content-Type' : 'application/json'
},
body: JSON . stringify ({
taskId ,
audioId ,
callBackUrl: 'https://your-server.com/vocal-callback'
})
});
const result = await response . json ();
return result . data . taskId ;
}
async getRemainingCredits () {
const response = await fetch ( ` ${ this . baseUrl } /get-credits` , {
headers: {
'Authorization' : `Bearer ${ this . apiKey } `
}
});
const result = await response . json ();
return result . data . credits ;
}
}
// Usage example
async function main () {
const api = new SunoAPI ( 'YOUR_API_KEY' );
try {
// Check remaining credits
const credits = await api . getRemainingCredits ();
console . log ( `Remaining credits: ${ credits } ` );
// Generate lyrics first
console . log ( 'Generating lyrics...' );
const lyricsTaskId = await api . generateLyrics (
'A song about adventure and discovery, uplifting and inspiring'
);
const lyricsResult = await api . waitForCompletion ( lyricsTaskId );
console . log ( 'Lyrics generated:' , lyricsResult . data [ 0 ]. text );
// Generate music with custom parameters
console . log ( 'Generating music...' );
const musicTaskId = await api . generateMusic ({
prompt: lyricsResult . data [ 0 ]. text ,
customMode: true ,
style: 'Folk Pop' ,
title: 'Adventure Song' ,
instrumental: false ,
model: 'V4_5' ,
callBackUrl: 'https://your-server.com/music-callback'
});
// Wait for completion
const musicResult = await api . waitForCompletion ( musicTaskId );
console . log ( 'Music generated successfully!' );
musicResult . data . forEach (( track , index ) => {
console . log ( `Track ${ index + 1 } :` );
console . log ( ` Title: ${ track . title } ` );
console . log ( ` Duration: ${ track . duration } s` );
console . log ( ` Audio URL: ${ track . audio_url } ` );
});
// Extend the first track
const originalTrack = musicResult . data [ 0 ];
console . log ( 'Extending music...' );
const extendTaskId = await api . extendMusic ( originalTrack . id , {
defaultParamFlag: true ,
prompt: 'Continue with a beautiful instrumental outro' ,
continueAt: originalTrack . duration - 30 , // Extend from 30s before end
model: 'V4_5'
});
const extendedResult = await api . waitForCompletion ( extendTaskId );
console . log ( 'Extended version created:' , extendedResult . data [ 0 ]. audio_url );
// Separate vocals
console . log ( 'Separating vocals...' );
const separationTaskId = await api . separateVocals ( musicTaskId , originalTrack . id );
const separationResult = await api . waitForCompletion ( separationTaskId );
console . log ( 'Vocal separation completed:' );
console . log ( ` Instrumental: ${ separationResult . vocal_removal_info . instrumental_url } ` );
console . log ( ` Vocals only: ${ separationResult . vocal_removal_info . vocal_url } ` );
} catch ( error ) {
console . error ( 'Error:' , error . message );
}
}
main ();
Advanced Features
Upload and Extend
Upload your own audio and extend it with AI:
const extendTaskId = await api . generateMusic ({
uploadUrl: 'https://example.com/my-song.mp3' ,
defaultParamFlag: true ,
prompt: 'Add a rock guitar solo section' ,
continueAt: 60 ,
model: 'V4_5'
});
Convert music to high-quality WAV format:
const wavTaskId = await api . convertToWav ({
taskId: 'original_task_id' ,
audioId: 'e231****-****-****-****-****8cadc7dc' ,
callBackUrl: 'https://your-server.com/wav-callback'
});
Music Video Generation
Create visual music videos:
const videoTaskId = await api . createMusicVideo ({
taskId: 'music_task_id' ,
audioId: 'e231****-****-****-****-****8cadc7dc' ,
author: 'Artist Name' ,
domainName: 'your-brand.com' ,
callBackUrl: 'https://your-server.com/video-callback'
});
Using Callbacks
Set up webhook callbacks for automatic notifications:
// Your callback endpoint
app . post ( '/music-callback' , ( req , res ) => {
const { code , data } = req . body ;
if ( code === 200 ) {
console . log ( 'Music ready:' , data . data );
data . data . forEach ( track => {
console . log ( `Title: ${ track . title } ` );
console . log ( `Audio: ${ track . audio_url } ` );
});
} else {
console . log ( 'Generation failed:' , req . body . msg );
}
res . status ( 200 ). json ({ status: 'received' });
});
Learn More About Callbacks Set up webhook callbacks to receive automatic notifications when your music is ready.
Task Status Explanation
Task completed successfully
Task is queued for processing
Best Practices
Use detailed, specific descriptions for music style and mood
Include instrument specifications and vocal requirements
Specify tempo, energy level, and song structure
Avoid conflicting or overly complex descriptions
Use V3_5 for creative and experimental music
Choose V4 for highest audio quality in standard lengths
Select V4_5 for advanced features and longer tracks
Consider your specific use case and quality requirements
Implement appropriate retry logic for transient failures
Monitor task status and handle timeout scenarios
Validate input parameters before making requests
Log errors for debugging and monitoring
File Storage and Access
Generated audio files are stored for 15 days before automatic deletion. Download URLs may have limited validity periods.
Audio files remain accessible for 15 days after generation
Download and save important files to your own storage
Use the API to regenerate content if needed after expiration
Consider implementing local backup strategies for critical content
Next Steps
Support
Need help? Our technical support team is here to assist you.
Ready to start creating amazing AI music? Get your API key and begin composing today!