Skip to main content

A lightweight, modern, and fully-typed Python SDK for the Suno AI API (sunoapi.org)

Project description

suno-easy ๐ŸŽต

[!IMPORTANT] Disclaimer: This is an unofficial, community-driven Python SDK wrapper for the Suno API (sunoapi.org). It is not affiliated with, endorsed, sponsored, or supported by Suno, Inc. or the official Suno AI platform.

suno-easy is a lightweight, modern, and fully-typed Python SDK for the Suno AI API (sunoapi.org).

It provides an intuitive, object-oriented interface to generate music, write lyrics, create voice personas, separate audio stems, and generate MIDI notes from audio files.


Features

  • Clean Namespace Organization: Resources are grouped logically (client.music, client.lyrics, client.audio, client.persona).
  • Fully Typed: Rich python dataclasses for responses (Song, Lyrics, SeparatedStems, MIDIData, CoverImage).
  • Smart Polling: Methods can either block and return the processed result (wait=True) or instantly return a taskId for asynchronous workflows (wait=False).
  • Built-in Downloads: Download audio tracks, cover images, and isolated stems with built-in streaming helpers.
  • Robust Error Handling: Distinct exceptions for HTTP failures (SunoAPIError) and generation failures (TaskFailed).

Repository Structure

suno-easy/
โ”œโ”€โ”€ suno_easy/          # Core SDK library source code
โ”‚   โ”œโ”€โ”€ __init__.py     # Exposed client, models, and exceptions
โ”‚   โ”œโ”€โ”€ client.py       # Main SunoClient orchestrator
โ”‚   โ”œโ”€โ”€ models.py       # Strongly typed dataclasses representing API payloads
โ”‚   โ”œโ”€โ”€ audio.py        # Audio processing sub-resource (stems, MIDI, covers)
โ”‚   โ”œโ”€โ”€ music.py        # Music generation and extension sub-resource
โ”‚   โ”œโ”€โ”€ lyrics.py       # Lyrics generation sub-resource
โ”‚   โ”œโ”€โ”€ persona.py      # Voice/style persona sub-resource
โ”‚   โ”œโ”€โ”€ exceptions.py   # SDK custom exception classes
โ”‚   โ””โ”€โ”€ utils.py        # Internal utility and polling helpers
โ”œโ”€โ”€ tests/              # Test suite
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ””โ”€โ”€ test_client.py  # Mocked HTTP interface unit tests
โ”œโ”€โ”€ examples/           # Basic usage examples
โ”‚   โ””โ”€โ”€ quickstart.py   # Quickstart example script
โ”œโ”€โ”€ pyproject.toml      # PEP 621 compliant project packaging configuration
โ”œโ”€โ”€ requirements.txt    # Runtime dependencies
โ”œโ”€โ”€ requirements-dev.txt# Development and testing requirements
โ”œโ”€โ”€ LICENSE             # MIT License file
โ””โ”€โ”€ README.md           # Project documentation

Installation

This SDK requires requests. You can install the package directly from source:

pip install .

Or for development (editable mode):

pip install -e .

Quickstart

1. Initialize the Client

from suno_easy import SunoClient

client = SunoClient(api_key="your_suno_api_key_here")

2. Generate Music

Generate a track in custom mode (requires prompt, style, and title). By default, this blocks until the songs are generated (usually 2-3 minutes) and returns a list containing two song variations.

songs = client.music.generate(
    prompt="A peaceful acoustic guitar melody with soft strings",
    style="Folk, Acoustic",
    title="Morning Breeze",
    instrumental=True
)

for song in songs:
    print(f"Song generated: {song.title} (ID: {song.id})")
    print(f"Audio URL: {song.audio_url}")
    
    # Download the track and its cover image
    song.download(f"{song.title}.mp3")
    song.download_image(f"{song.title}.jpg")

3. Generate Lyrics

Create AI-generated lyrics structure markers like [Verse] or [Chorus].

lyrics_list = client.lyrics.generate(prompt="a song about embarking on a journey to Mars")

for lyrics in lyrics_list:
    print(f"Title Idea: {lyrics.title}")
    print(lyrics.text)

4. Separate Vocals (Stem Separation)

Separate an existing song task into vocals and instrumental tracks. Supports 2-stem (separate_vocal) and up to 12-stem (split_stem) separation.

stems = client.audio.separate_vocals(
    task_id="original_music_task_id",
    mode="separate_vocal" # or "split_stem"
)

print(f"Vocal URL: {stems.vocal_url}")
print(f"Instrumental URL: {stems.instrumental_url}")

# Download isolated files
stems.download_vocal("vocals.mp3")
stems.download_instrumental("instrumental.mp3")

5. Convert Audio to MIDI

Convert separated audio tracks into MIDI note structures.

midi_data = client.audio.generate_midi(task_id="vocal_removal_task_id")

print(f"MIDI Generation State: {midi_data.state}")
for instrument in midi_data.instruments:
    print(f"Instrument: {instrument.name}")
    for note in instrument.notes[:5]: # Print first 5 notes
        print(f"  Note pitch: {note.pitch}, start: {note.start}s, end: {note.end}s")

Asynchronous Workflows (Webhooks & Background Tasks)

If you don't want the methods to block your program execution, set wait=False. The client will instantly return the taskId string. You can then poll later or receive webhook callbacks on your server.

# Starts music generation and returns instantly
task_id = client.music.generate(
    prompt="Lo-fi hip hop beat for studying",
    style="Lo-Fi",
    title="Study Session",
    wait=False,
    callback_url="https://yourdomain.com/webhook"
)

print(f"Music generation started. Task ID: {task_id}")

# Manually retrieve info later
task_info = client.music.get_task_info(task_id)
print(f"Status: {task_info.get('status')}")

API Reference

client.music

  • generate(...) -> list[Song] | str: Generates songs from prompts.
  • extend(...) -> list[Song] | str: Extends an existing song from a timestamp.
  • generate_instrumental(...) -> list[Song] | str: Generates instrumentals.
  • remaster(music_id, ...) -> list[Song] | str: Improves the quality of a song.

client.lyrics

  • generate(prompt, ...) -> list[Lyrics] | str: Generates lyrics.
  • get(task_id) -> list[Lyrics]: Retrieves lyrics from a completed task.

client.audio

  • cover(upload_url, style, title, ...) -> list[Song] | str: Applies a style cover to an uploaded audio.
  • extend(upload_url, continue_at, prompt, ...) -> list[Song] | str: Extends an uploaded audio track.
  • separate_vocals(task_id, mode, ...) -> SeparatedStems | str: Split vocals and instrumentation.
  • get_separated_stems(task_id) -> SeparatedStems: Retrieves separated stems.
  • generate_midi(task_id, ...) -> MIDIData | str: Converts audio stems to MIDI notes.
  • get_midi(task_id) -> MIDIData: Retrieves MIDI notes.
  • add_vocals(upload_url, prompt, ...) -> list[Song] | str: Adds vocals to an instrumental track.
  • add_instrumental(upload_url, title, tags, ...) -> list[Song] | str: Adds backing instruments to vocals.

client.persona

  • create(music_id, name) -> dict: Creates a voice/style persona from a track.

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

suno_easy-0.1.0.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

suno_easy-0.1.0-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file suno_easy-0.1.0.tar.gz.

File metadata

  • Download URL: suno_easy-0.1.0.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for suno_easy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 59938f03812e196d86db2dc15800ab8d44417c5a7c9abd172d003161bee83d30
MD5 76e4be723376288c937d52df225dd6d5
BLAKE2b-256 4e6cf9b3cb59af46872833e7c44ae23b567dbc6648f957e8b8895f68f61bb63f

See more details on using hashes here.

File details

Details for the file suno_easy-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: suno_easy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for suno_easy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 05d5194e7cc9b4574fa643a23c52242f9221fd31436ceec8f20cb9dc0c40abf5
MD5 b046b8c0c5b2a34d69399342f6a3065c
BLAKE2b-256 b4cf480e7d32d14117c3a64857bce778184c7eb7271ffda4f77fe4e272412936

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page