Login
Back to Blog
EnglishTutorial

Suno Music API Tutorial: Generate AI Music Programmatically in 2026

"Learn how to use the Suno Music API to generate songs, lyrics, and instrumentals with code. Includes Python examples, pricing, and integration tips."

C
Crazyrouter Team
February 21, 2026 / 1926 views
Share:
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#

bash
pip install openai requests

Generate a Song with Python#

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#

python
# 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:

python
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#

python
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#

bash
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#

ParameterTypeRequiredDescription
promptstringYesText description or custom lyrics
tagsstringNoGenre and style tags (comma-separated)
mvstringNoModel version (e.g., "chirp-v4")
make_instrumentalbooleanNoIf true, generates without vocals
titlestringNoCustom title for the track

Style Tags That Work Well#

GenreExample Tags
Poppop, catchy, upbeat, synth
Rockrock, guitar, drums, energetic
Lo-filo-fi, chill, hip-hop, vinyl
Jazzjazz, saxophone, smooth, swing
ElectronicEDM, electronic, bass, drop
Classicalorchestral, piano, strings, cinematic
R&Br&b, soul, smooth, groove

Pricing#

ProviderCost per SongSongs per $Notes
Suno Pro (subscription)~$0.502Monthly plan required
Suno Premier~$0.254Annual plan
Crazyrouter API~$0.1010Pay-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:

python
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:

python
# 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:

python
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#

  1. Be specific with prompts — "upbeat pop song with female vocals about summer road trips" works better than "a happy song"
  2. Use style tags — they significantly influence the output genre and mood
  3. Iterate on lyrics — generate lyrics first, edit them, then submit with music
  4. Specify instruments — mentioning specific instruments (piano, guitar, saxophone) gives more control
  5. 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.

Implementation Guides

Topics

Tutorial

Related Posts

GLM-4.6 API Guide 2026: Building Chinese-First AI ApplicationsTutorial

GLM-4.6 API Guide 2026: Building Chinese-First AI Applications

"Learn how to use the GLM-4.6 API for Chinese-first AI apps, bilingual assistants, and enterprise workflows. Includes code examples, architecture patterns, and pricing guidance."

Apr 18
Gemini CLI User Guide - Google AI in Your TerminalTutorial

Gemini CLI User Guide - Google AI in Your Terminal

Complete guide to install and configure Gemini CLI, Google's open-source command-line AI tool. Learn how to set up proxy, use built-in tools

Jan 24
AI Agent Memory Patterns: Building Stateful AI Applications with Long-Term Memory in 2026Tutorial

AI Agent Memory Patterns: Building Stateful AI Applications with Long-Term Memory in 2026

"Learn how to implement memory patterns for AI agents. Covers conversation buffers, sliding windows, summary memory, vector-based retrieval, and hybrid approaches using GPT-5, Claude, and open-source tools."

Mar 13
Gemini 2.5 Flash and Flash-Lite for High-RPM APIs: Why Throughput and Low Cost Matter in ProductionTutorial

Gemini 2.5 Flash and Flash-Lite for High-RPM APIs: Why Throughput and Low Cost Matter in Production

A production-oriented guide to using gemini-2.5-flash and gemini-2.5-flash-lite for high-RPM, high-concurrency, cost-sensitive AI workloads through Crazyrouter.

Jul 7
How to Deploy Clawdbot: Build Your Free 24/7 AI Assistant in 5 MinutesTutorial

How to Deploy Clawdbot: Build Your Free 24/7 AI Assistant in 5 Minutes

Want a personal AI assistant that runs 24/7, connects to WhatsApp, Telegram, and Discord, and costs almost nothing to host? Meet Clawdbot - an open-source project that makes this surprisingly easy.

Jan 26
Self-Hosted AI: Run Your Own AI Assistant with Complete PrivacyTutorial

Self-Hosted AI: Run Your Own AI Assistant with Complete Privacy

Concerned about sending sensitive data to cloud AI services? Self-hosting gives you full control over your AI infrastructure. This guide covers how to run your own AI assistant, the trade-offs involve...

Jan 26