Skip to content

SunoApi/SunoApi

Repository files navigation

简体中文 | 繁體中文 | Русский | 한국어 | 日本語 | Français | Deutsch

GitHub release GitHub last commit GitHub commit activity GitHub Issues or Pull Requests SunoApi GitHub Downloads (all assets, all releases) License

SunoAPI is an unofficial Suno AI client

Congratulations on this open source project's being selected for this week's weekly

Introduction

  • This is an unofficial SunoAPI client based on Python and Streamlit currently supports functions such as generating music and obtaining music information. It comes with built-in maintenance and activation functions for tokens, so there is no need to worry about token expiration. You can set up multiple account information to be saved for use.

  • GitHub sometimes cannot be accessed. If it cannot be accessed, please move to Gitee address: https://gitee.com/SunoApi/SunoApi

Features

  • Set account information and automatically maintain and keep the program active
  • Multiple account information can be set to be saved and used
  • Music Sharing Square showcases all publicly available songs
  • Enter the music feed ID to directly obtain song information
  • Support to upload pictures, according to the content of the image analysis to generate songs
  • Support multiple languages such as Chinese, English, Korean, Japanese, etc

Debug

Python local debug running

  • Clone source code
git clone https://github.com/SunoApi/SunoApi.git
  • Installation dependencies
cd SunoApi
pip3 install -r requirements.txt
  • .env environment variable, Image recognition requires the use of the gpt-4-vision review model, which can use OpenAI interfaces or replace them with other commonly used interfaces
OPENAI_BASE_URL = https://chatplusapi.cn
OPENAI_API_KEY = sk-xxxxxxxxxxxxxxxxxxxx
WEB_SITE_URL = http://localhost:8501
  • Start the project, please refer to the Streamlit documentation for details on Streamlit
streamlit run main.py --server.maxUploadSize=2

Deploy

Docker local one-click deployment

docker run -d \
  --name sunoapi \
  --restart always \
  -p 8501:8501 \
  -v ./sunoapi.db:/app/sunoapi.db \
  -v ./images/upload:/app/images/upload \
  -e OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxx \
  -e OPENAI_BASE_URL=https://api.openai.com  \
  -e WEB_SITE_URL=http://localhost:8501  \
  sunoapi/sunoapi:latest
Attention: It is necessary to http://localhost:8501 Replace with the actual address you can access, and the final uploaded image file will pass through http://domain.com/images/upload/xxxxxx.jpg The format can be accessed, otherwise OpenAI cannot access the image you uploaded and cannot recognize its content. Therefore, the function of uploading images to generate music will not be available.

Docker local compilation and deployment

docker compose build && docker compose up

Dockerfile

FROM python:3.10-slim-buster

WORKDIR /app

COPY requirements.txt ./
RUN --mount=type=cache,target=/root/.cache/pip \
    pip install -r requirements.txt --no-cache-dir

COPY . .

EXPOSE 8501
CMD [ "nohup", "streamlit", "run", "main.py", "--server.maxUploadSize=2" ]

Docker pull image deployment

docker-compose pull && docker-compose up -d

docker-compose.yml

version: '3.2'

services:
  sunoapi:
    image: sunoapi/sunoapi:latest
    container_name: sunoapi
    ports:
      - "8501:8501"
    volumes:
      - ./sunoapi.db:/app/sunoapi.db
      - ./images/upload:/app/images/upload
    environment:
      - TZ=Asia/Shanghai
      - OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxx
      - OPENAI_BASE_URL=https://api.openai.com
      - WEB_SITE_URL=http://localhost:8501
    restart: always
Note: To pull image deployment, you need to download sunoapi.db from the project and transfer it to your docker-compose.yml file directory. Otherwise, Docker startup will prompt that the file cannot be mounted.

Streamlit remote repositories deployment

Zeabur one-click deployment

Deploy on Zeabur

Configuration

  • First, retrieve your session and cookie from the browser page when logged in.

  • After filling in the setting information, it will automatically keep alive. You can fill in multiple account information.

  • Enter and save the information. You can modify the account information if you enter identity.

Done

Questions

  • If the page promp the message: Please save the information first, and then refresh the page to use it normally! Please first add your own account information and save it, then delete other invalid account information in the sunoapi.db database, including the account information I tested, and then you can use it normally.
  • If the page prompts the message: Suno AI music song generation submission failed: Unauthorized. This indicates that the account login status is not authorized. This situation is usually caused by multiple browser clients logging in to the account and forming a preemption. Exit other logged in browser clients, keep the account logged in on this SunoAPI AI music song generator client, and do not log in on other browser clients.
  • If the page promp the message: "Suno AI Music song generation failed to submit: Insufficient credits." Indicates that the credits of account information are insufficient, please add your account information to save, and then you can use it normally.
  • After the music generation task is successfully submitted, the queue status of the generation task is pulled. When the status is "complete", it returns successfully. At this time, it defaults to waiting for the official generation file for 15 seconds. The official interface service directly returns the URL address of media files, and most of the time the page can display these media files normally. Occasionally, the interface may have returned the Url address of the media file, but the actual file cannot be accessed from the Url address and needs to wait for a while. At this point, the media file may not be able to be loaded on the page. You can right-click on the media player and copy the media file address. Open the address separately in the browser to access it, or right-click to save as download and save.
  • Regarding the security issue of saving account session and cookie information, as long as your account is not recharged, there is no need to worry because you do not know your account password. The session and cookie information you fill in will become invalid if your account logs in to other activities or logs out of the official website, and the session and cookie information you fill in will change the next time you log in to the official website.

Creation

Contact

Participate

  • My personal strength is always limited, any form of contribution is welcome, including but not limited to contributing code, optimizing documents, submitting issues and PR. Due to limited time, we do not accept to submit bugs to developers in wechat or wechat group, please submit issues and PR if you have problems or optimization suggestions!

Reference

Statement

  • SunoApi is an unofficial open source project for study and research only. Users voluntarily enter free account information to generate music. Each account generates five songs per day for free, and we don't use them for other purposes. Please feel free to use! If there are 10,000 users, the system can generate 50,000 songs per day for free. Please try to save your usage as you can only generate five songs per account per day for free. If everyone writes more than five songs a day, it's still not enough. The ultimate goal is to make it free to build whenever you need it.

Buy Me a Coffee

Buy me a Coffee

This project originated from GitHub, based on MIT protocol and free, without any form of payment behavior!
If you think this project is helpful to you, please help me click "Star" and spread, thank you!