Malith-Rukshan / Suno-API

SunoAI Unofficial Python API Library and REST API for Suno.ai β€” Create Music with Generative AI ! ✨
https://pypi.org/project/SunoAI
MIT License
42 stars 14 forks source link
ai-music fastapi generative-music python-library rest-api suno-ai suno-ai-api

✨ Suno AI API 🎡

[![PyPI Package](https://img.shields.io/badge/PyPi-Library-1cd760?logo=pypi&style=flat)](https://pypi.org/project/SunoAI/) [![Updates Telegram Channel](https://img.shields.io/badge/Updates-@SunoAPI-blue?logo=telegram&style=flat)](https://t.me/SunoAPI) [![Example Usage Bot](https://img.shields.io/badge/Example-Telegram--BOT-0066FF?logo=probot&style=flat)](https://github.com/Malith-Rukshan/Suno-AI-BOT)

✨ Python API Library for Suno AI β€” Create Music with Generative AI ! πŸš€

- Available as Both Python Library and REST API -

Python Library Β· Update Channel


πŸ“š SunoAI API Library is an unofficial Python client for interacting with Suno AI's music generator. This library facilitates generating music using Suno's Chirp v3 model and includes main functions of Suno AI with a built-in music downloader. It can be deployed as a REST API using FastAPI, Local, Docker, on a PaaS provider like Heroku.

✨ Features

🏷 Prerequisites

πŸ“‹ Before using the library or REST API, you must sign up on the suno.ai website and obtain your cookie as shown in this screenshot.

πŸ’‘ You can find cookie from the Web Browser's Developer Tools -> Network Tab

Click to view - Screenshot How to get Cookie from Suno.AI Just right click & open Inspect. Filter : `_clerk_js_version`


Set this cookie as SUNO_COOKIE environment variable or initialize the library as shown below.

from suno import Suno, ModelVersions
client = Suno(
  cookie='YOUR_COOKIE_HERE',
  model_version=ModelVersions.CHIRP_V3_5)

πŸ’Ύ Installation

Install the library using pip:

pip install SunoAI

πŸš€ Deployment - REST API

Deploy on PasS

Set SUNO_COOKIE as an Environmental variable before deploy. - Instructions

Deploy with heroku Deploy to Netlify

Deploy on Railway Deploy to Render

Deploy on Local or VPS

export SUNO_COOKIE="YOUR_COOKIE_HERE"
git clone git@github.com:Malith-Rukshan/Suno-API.git
pip3 install -r requirements.txt
cd Suno-API
fastapi run api.py --port 8080

πŸ”— Available at : http://127.0.0.1:8080

πŸ› οΈ Usage

Example Usage Bot

⚑️ Quick Start :

from suno import Suno, ModelVersions
client = Suno(
  cookie='YOUR_COOKIE_HERE',
  model_version=ModelVersions.CHIRP_V3_5)

# Generate a song
songs = client.generate(prompt="A serene landscape", is_custom=False, wait_audio=True)

# Download generated songs
for song in songs:
    file_path = client.download(song=song)
    print(f"Song downloaded to: {file_path}")

πŸ“š Library Methods

Suno() <- Initializing

generate()

get_songs()

get_credits()

download()

Models provided by Suno AI to Generate music.

πŸ“š Library Responses

🌐 REST API Usage

1. Generate Music

POST /generate

2. Retrieve Songs

POST /songs

3. Get a Specific Song

POST /get_song

POST /set_visibility

4. Retrieve Credit Information

GET /credits

🀝 Contributing

Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

🎯 Credits and Other

All content and music generated through this library are credited to Suno AI. This unofficial API provides a convenient way to interact with Suno AI's services but does not claim any ownership or rights over the music generated. Please respect the terms of service of Suno AI when using their platform ❀️.

This library is intended primarily for educational and development purposes. It aims to enhance and simplify access to Suno AI's music generation capabilities. If you enjoy the music generated, consider supporting Suno AI directly. Logo Credit : @rejaul43

βš–οΈ License

This project is distributed under the MIT License. This license allows everyone to use, modify, and redistribute the code. However, it comes with no warranties regarding its functionality. For more details, see the LICENSE file in the repository.

🌟 Support and Community

If you found this project helpful, don't forget to give it a ⭐ on GitHub. This helps others find and use the project too! 🫢

πŸ’° Support Me

Join our Telegram channels,

πŸ“¬ Contact

If you have any questions, feedback, or just want to say hi, you can reach out to me:

πŸ§‘β€πŸ’» Built with πŸ’– by Single Developers </>