
"Suno Music API Tutorial: Generate AI Music Programmatically in 2026"
What Is Suno Music API?#
Suno is the leading AI music generation platform that creates full songs — vocals, instrumentals, and lyrics — from text prompts. While most people know Suno through its web interface, the real power for developers lies in its API, which lets you programmatically generate music for apps, games, content platforms, and creative tools.
With the Suno API, you can:
- Generate complete songs with vocals and lyrics from a text description
- Create instrumental tracks for background music
- Generate lyrics separately for review before music creation
- Control style, genre, mood, and duration
- Build music generation into any application
How to Access the Suno API#
Suno doesn't offer a public API directly to all users. However, you can access Suno's music generation capabilities through API aggregators like Crazyrouter, which provides an OpenAI-compatible endpoint for Suno and 300+ other AI models.
Setup#
pip install openai requests
Generate a Song with Python#
import requests
import time
API_KEY = "your-crazyrouter-key"
BASE_URL = "https://api.crazyrouter.com"
# Step 1: Submit a music generation request
response = requests.post(
f"{BASE_URL}/suno/submit/music",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
},
json={
"prompt": "A chill lo-fi hip hop beat with soft piano and vinyl crackle, perfect for studying late at night",
"tags": "lo-fi, hip-hop, chill, instrumental",
"mv": "chirp-v4",
"make_instrumental": True
}
)
task_id = response.json()["data"]["task_id"]
print(f"Task submitted: {task_id}")
# Step 2: Poll for completion
while True:
status = requests.get(
f"{BASE_URL}/suno/fetch/{task_id}",
headers={"Authorization": f"Bearer {API_KEY}"}
).json()
if status["data"]["status"] == "completed":
for track in status["data"]["tracks"]:
print(f"Track: {track['title']}")
print(f"Audio URL: {track['audio_url']}")
print(f"Duration: {track['duration']}s")
break
elif status["data"]["status"] == "failed":
print("Generation failed:", status["data"]["error"])
break
time.sleep(10) # Check every 10 seconds
Generate a Song with Lyrics#
# Generate a complete song with AI-written lyrics
response = requests.post(
f"{BASE_URL}/suno/submit/music",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
},
json={
"prompt": "An upbeat pop song about a developer who finally fixed a production bug at 3am",
"tags": "pop, upbeat, fun, electronic",
"mv": "chirp-v4",
"make_instrumental": False
}
)
Generate Lyrics Only#
If you want to review or edit lyrics before generating music:
response = requests.post(
f"{BASE_URL}/suno/submit/lyrics",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
},
json={
"prompt": "A rock ballad about the open source community"
}
)
lyrics_data = response.json()
print(lyrics_data["data"]["text"])
Custom Lyrics with Music#
custom_lyrics = """
[Verse 1]
Lines of code at midnight glow
Coffee cold but spirits high
Every bug a chance to grow
Every fix a battle cry
[Chorus]
We build the future line by line
Open source, the code is mine and yours
Together we design
A world that runs on what we pour
[Verse 2]
Pull requests at dawn arrive
Reviews sharp but always kind
In this repo we're alive
Leaving legacy behind
"""
response = requests.post(
f"{BASE_URL}/suno/submit/music",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
},
json={
"prompt": custom_lyrics,
"tags": "rock, ballad, anthemic, guitar",
"mv": "chirp-v4",
"make_instrumental": False
}
)
cURL Example#
curl -X POST https://api.crazyrouter.com/suno/submit/music \
-H "Authorization: Bearer your-crazyrouter-key" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A jazzy instrumental with saxophone and soft drums",
"tags": "jazz, saxophone, smooth, instrumental",
"mv": "chirp-v4",
"make_instrumental": true
}'
API Parameters Reference#
| Parameter | Type | Required | Description |
|---|---|---|---|
prompt | string | Yes | Text description or custom lyrics |
tags | string | No | Genre and style tags (comma-separated) |
mv | string | No | Model version (e.g., "chirp-v4") |
make_instrumental | boolean | No | If true, generates without vocals |
title | string | No | Custom title for the track |
Style Tags That Work Well#
| Genre | Example Tags |
|---|---|
| Pop | pop, catchy, upbeat, synth |
| Rock | rock, guitar, drums, energetic |
| Lo-fi | lo-fi, chill, hip-hop, vinyl |
| Jazz | jazz, saxophone, smooth, swing |
| Electronic | EDM, electronic, bass, drop |
| Classical | orchestral, piano, strings, cinematic |
| R&B | r&b, soul, smooth, groove |
Pricing#
| Provider | Cost per Song | Songs per $ | Notes |
|---|---|---|---|
| Suno Pro (subscription) | ~$0.50 | 2 | Monthly plan required |
| Suno Premier | ~$0.25 | 4 | Annual plan |
| Crazyrouter API | ~$0.10 | 10 | Pay-as-you-go |
Through Crazyrouter, you pay per generation with no subscription commitment. This is ideal for developers who need programmatic access without managing a Suno subscription.
Use Cases#
1. Content Creation Platforms#
Automatically generate background music for video editors, podcast intros, or social media content:
def generate_background_music(video_mood, duration_hint):
"""Generate background music matching video mood."""
mood_to_tags = {
"happy": "upbeat, pop, cheerful, bright",
"dramatic": "cinematic, orchestral, epic, intense",
"chill": "lo-fi, ambient, relaxed, soft",
"energetic": "electronic, EDM, fast, powerful"
}
response = requests.post(
f"{BASE_URL}/suno/submit/music",
headers={"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"},
json={
"prompt": f"A {video_mood} instrumental track, approximately {duration_hint}",
"tags": mood_to_tags.get(video_mood, "ambient, background"),
"make_instrumental": True
}
)
return response.json()["data"]["task_id"]
2. Game Development#
Generate dynamic soundtracks based on game state:
# Generate battle music
battle_music = generate_music(
prompt="Intense battle theme with fast drums and electric guitar",
tags="game, battle, intense, fast, orchestral"
)
# Generate exploration music
explore_music = generate_music(
prompt="Peaceful exploration theme with soft flute and ambient pads",
tags="game, ambient, peaceful, exploration, fantasy"
)
3. Personalized Jingles#
Create custom jingles for brands or products:
jingle = generate_music(
prompt="A short catchy jingle for a tech startup, modern and friendly, 15 seconds",
tags="jingle, corporate, modern, short, catchy"
)
Tips for Better Results#
- Be specific with prompts — "upbeat pop song with female vocals about summer road trips" works better than "a happy song"
- Use style tags — they significantly influence the output genre and mood
- Iterate on lyrics — generate lyrics first, edit them, then submit with music
- Specify instruments — mentioning specific instruments (piano, guitar, saxophone) gives more control
- Keep prompts under 200 words — concise descriptions tend to produce better results
FAQ#
Can I use Suno-generated music commercially?#
With Suno's paid plans and API access through Crazyrouter, generated music can be used commercially. Always check the latest terms of service for specific licensing details.
How long does generation take?#
Typically 30-120 seconds per song. Instrumental tracks tend to generate faster than songs with vocals.
What audio format is returned?#
Generated tracks are returned as MP3 files (128-320kbps). The API provides a URL to download the audio file.
Can I control the song duration?#
You can hint at duration in your prompt (e.g., "a 30-second jingle"), but exact duration control is limited. Most generated songs are 1-3 minutes long.
Is there a rate limit?#
Through Crazyrouter, you can submit multiple concurrent generation requests. The practical limit depends on your plan and current server load.
Summary#
The Suno Music API opens up AI music generation for developers building creative tools, content platforms, games, and more. Through Crazyrouter, you get pay-as-you-go access without subscription commitments, alongside 300+ other AI models through a single API key.
Start generating AI music today at crazyrouter.com.


