Generate Music
Generate AI music from text prompts with full control over genre, mood, tempo, and vocals. Supports custom mode with tags and lyrics, or simple mode with natural language descriptions. Returns high-quality stereo audio tracks.
Usage Guide
- This endpoint creates music based on your text prompt.
- Multiple variations will be generated for each request.
- You can control detail level with custom mode and instrumental settings.
Supported AI Models
3 Official ModelsPowerful and versatile, Refined.
Best for experimental ideas.
More efficient version of V6.
Parameter Details & Mode Rules
Always Required Fields:
custom_mode, instrumental, model
In Custom Mode (custom_mode: true):
titleis required, maximum 80 characters.promptis optional; when provided, it is used strictly as lyrics and sung in the generated track. Iflyricsis also provided, lyrics takes priority.- At least one of
style,lyrics, ornegative_tagsmust be provided; generation is rejected if all are empty. - If
instrumental: true: generate instrumental music (no vocals). - If
instrumental: false: use lyrics as singing vocals.
In Non-Custom Mode (custom_mode: false):
promptserves as the core musical idea (lyrics generated automatically, max 3000 characters).- Reference media attachments:
image_urls,video_urls, andaudio_urlsare only valid in this mode. - Total attachments must not exceed 10 (
style+lyrics+ media URLs).
Developer Notes
- Recommendation for new users: Start with
custom_mode: falsefor simpler usage. - File Retention: Generated audio and cover files are permanently retained for 14 days on edge storage.
- Callback Process: Three-stage lifecycle:
text(lyric plan ready),first(first variation track synthesized), andcomplete(all variations ready).
Authentication & Headers
| Header | Requirement | Description |
|---|---|---|
| Authorization | required | Bearer YOUR_API_KEY Secret API Key obtained from dashboard. |
| Content-Type | required | application/json Request payload format. |
Request Body Schema
20 fieldsmodelstringrequiredAI model to use for music generation. V6 is the refined default, V6_WILD for experimental ideas, and V6_MINI for rapid lightweight generation.
"V6""V6_WILD""V6_MINI"custom_modebooleanrequiredDetermines whether custom mode is enabled. If true, allows detailed control over style, title, and lyrics.
instrumentalbooleanrequiredWhether the generated track should be purely instrumental without vocals.
promptstringoptionalDescription of the desired audio content. Used as lyrics in custom mode; used as core idea in non-custom mode (maximum 3000 characters).
titlestringoptionalTitle for the generated track (maximum 80 characters, required when custom_mode is true).
stylestringoptionalMusic genre, mood, or instrument style tags. Maximum 1000 characters for V6 models.
lyricsstringoptionalExplicit lyrics text. Maximum 5000 characters for V6 models. In custom mode, takes priority over prompt.
negative_tagsstringoptionalGenres, instruments, or acoustic traits to exclude from the generated audio.
durationnumberoptionalAudio duration in seconds. Range: 10–360 seconds (default: 20s).
vocal_genderstringoptionalPreferred vocal timbre: 'm' for male, 'f' for female. Only effective when custom_mode is true.
"m""f"style_weightnumberoptionalStrength of adherence to the specified style. Range 0–1, up to 2 decimal places. Only effective when custom_mode is true.
weirdness_constraintnumberoptionalCreative/experimental deviation. Range 0–1, up to 2 decimal places. Only effective when custom_mode is true.
audio_weightnumberoptionalRelative weight of audio features. Range 0–1, up to 2 decimal places. Only effective when custom_mode is true.
varietynumberoptionalDiversity of generated results: 0 (off, exact style), 1 (normal default, balanced), 2 (high, distinct styles), 3 (extra, bold exploration), 4 (max, maximum variation).
"0""1""2""3""4"persona_idstringoptionalPersona ID or Voice ID to apply consistent vocal character.
persona_modelstringoptionalPersona model type: style_persona or voice_persona. Supported in V6 models.
"style_persona""voice_persona"image_urlsarrayoptionalImage references. Only effective when custom_mode is false. Up to 5 images, max 10MB each (jpeg, png, webp, bmp).
video_urlsarrayoptionalVideo references. Only effective when custom_mode is false. Up to 1 file, max 100MB, duration <= 241s (mp4, mov, webm).
audio_urlsarrayoptionalAudio references. Only effective when custom_mode is false. Duration between 6s and 30m, max 500MB.
callBackUrlstringoptionalPublic Webhook URL to receive task completion notifications when audio generation is finished.
When Callbacks Are Sent
The SongMesh API automatically triggers an HTTP POST request to your designated callBackUrl under these events:
- Stage 1 (text): Lyrics and musical arrangement plan generated
- Stage 2 (first): First audio variation synthesis complete and ready for streaming
- Stage 3 (complete): All variation tracks generated and uploaded to high-speed CDN
Webhook Payload Format
{
"code": 200,
"msg": "success",
"data": {
"callbackType": "complete",
"task_id": "5c79****be8e",
"data": [
{
"id": "track_a1b2c3d4",
"audio_url": "https://cdn.sunoapi.top/audio/track_a1b2c3d4.mp3",
"image_url": "https://cdn.sunoapi.top/covers/track_a1b2c3d4.jpg",
"title": "Peaceful Piano Meditation",
"duration": 185.4,
"model_name": "V6"
},
{
"id": "track_e5f6g7h8",
"audio_url": "https://cdn.sunoapi.top/audio/track_e5f6g7h8.mp3",
"image_url": "https://cdn.sunoapi.top/covers/track_e5f6g7h8.jpg",
"title": "Peaceful Piano Meditation",
"duration": 192.1,
"model_name": "V6"
}
]
}
}Callback Payload Fields
| Field | Type | Description |
|---|---|---|
data.callbackType | string | Callback stage: "text", "first", or "complete" |
data.task_id | string | Unique task identifier assigned at submission |
data.data | array | Array of generated tracks with URLs, duration, and metadata |
Receiver Implementation Example
// Next.js App Router Webhook Receiver (/api/webhook/suno/route.ts)
import { NextRequest, NextResponse } from 'next/server';
export async function POST(req: NextRequest) {
const payload = await req.json();
const { callbackType, task_id, data } = payload.data || {};
if (callbackType === 'complete') {
console.log(`Task ${task_id} completed with ${data?.length} tracks`);
// Save generated tracks to database...
}
return NextResponse.json({ received: true });
}Webhook Security Recommendation
Always verify incoming webhook payloads on your server. Respond with a 200 OK immediately after parsing the payload to prevent redundant delivery retries from the webhook dispatcher.
curl -X POST "https://api.sunoapi.top/api/v1/createTask" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "V6",
"custom_mode": true,
"instrumental": false,
"title": "Peaceful Piano Meditation",
"style": "Classical, Piano, Calming",
"prompt": "Soft piano chords flowing gently in a quiet sanctuary...",
"callBackUrl": "https://api.yourdomain.com/webhook/suno"
}'{
"code": 200,
"msg": "success",
"data": {
"taskId": "5c79****be8e"
}
}Ready to integrate Generate Music API?
Create your free account, obtain your API key, and get 5 free generation credits.