Yanyutin753 / Suno2openai

以openai格式调用suno api,并将cookie保存为数据库,实现cookie池调用 📈已接入newapi、oneapi中转站,适配chat-next-web等前端项目 || Call suno api in openai format, and save the cookie as a database to realize the cookie pool call to access newapi, oneapi relay station, adapting chat-next-web and other front-end projects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

中文 English

Suno2openai

Integrated based on SunoSongsCreator and Suno-API projects, offering standardized service interfaces compliant with OpenAI formats.

Changelog

  • 2024.6.05 Separate database names from user names
  • 2024.6.03 Added suno-v3.5 model call and cdn link fetch.
  • 2024.4.14 Support for non-streaming output with stream=False docker version 0.1.1 No need to update if you don't need this feature.
  • 2024.4.14 Updated a script to automatically retrieve cookies from registered Outlook emails and write them into the database.
  • 2024.4.12 Completed integration of new-api and one-api, select OpenAI calls, and input the project deployment address (no need for /v1/); the key can be left empty.
  • 2024.4.10 Due to Suno's official updates, some project features were inoperable, now modified. Please re-pull the projects pulled before 2024/4/10 15:04; Docker to be updated later (already updated, be mindful of the version number when pulling).

✨ Project Highlights

  • OpenAI Format Calls: Supports streaming output.
  • Front-end Compatibility: Compatible with front-end projects like chat-next-web.
  • Docker Deployment: Simplifies deployment process, supports docker-compose, docker.
  • Multiple Cookie Management: Implements rotation of multiple cookies.

🚀 Future Plans

  • Introduce request queueing optimizations.
  • Support for custom parameters (such as tags, prompt, style, and song continuation).
  • Explore development of official-like frontend pages.
  • Welcome valuable suggestions! 📧 Email: 1544007699@qq.com

🫙 Docker Deployment

This tutorial provides step-by-step guidance on running a Docker container with specific environment variables and port mappings. For the purpose of this guide, sensitive information such as SQL names, passwords, and IP addresses will be replaced with placeholders.

Prerequisites

  • Docker is installed on your machine.
  • Basic knowledge of Docker CLI.

Steps

  1. Pull Docker Image

    Ensure the Docker image wlhtea/suno2openai:latest is available on your machine. If not, you can pull it from the Docker repository using:

    docker pull wlhtea/suno2openai:latest
  2. Run Docker Container

    Run the Docker container using necessary environment variables and port mappings. Replace <SQL_NAME>, <SQL_PASSWORD>, and <SQL_IP> with your actual SQL database connection values. These should be kept confidential and not shared publicly.

       docker run -d --name wsunoapi \
       -p 8000:8000 \
       -e USER_NAME='<USER_NAME>'
       -e SQL_NAME='<SQL_NAME>' \
       -e SQL_PASSWORD='<SQL_PASSWORD>' \
       -e SQL_IP='<SQL_IP>' \
       -e SQL_DK=3306 \
       --restart=always \
       wlhtea/suno2openai:latest

    example

    docker run -d --name wsunoapi \
          -p 8000:8000 \
          -e USER_NAME=suno2openaiUsername
          -e SQL_NAME=suno2openaiSQLname \
          -e SQL_PASSWORD=12345678 \
          -e SQL_IP=100.101.102.103 \
          -e SQL_DK=3306 \
          --restart=always \
          wlhtea/suno2openai:latest
    

Parameter Explanation:

  • -d: Run the container in detached mode and logger.info the container ID.
  • --name wsunoapi: Name your container wsunoapi for easy reference.
  • -p 8000:8000: Map the container's 8000 port to the host machine's 8000 port.
  • -e: Set environment variables for your container.
  • --restart=always: Ensure the container always restarts, unless manually stopped.

Add Cookie to Database Simply open the database and add cookies with the remaining count (an automatic import feature will be added later).

   id = int
   cookie = Cookie
   count = int
   working = 0

Database may report error: 'NoneType' object has no attribute ' items', check here if correct

  1. Access the Application

    Once the container is running, the application inside should be accessible via http://localhost:8000 or the 8000 port of your Docker host machine's IP address.

Note

Before running the Docker container, make sure you replace placeholders like <SQL_NAME>, <SQL_PASSWORD>, <SQL_IP>, and <your-session-id> with actual values.

📦 Docker-Compose Deployment

Update Time: 2024/4/7 18:18

Clone the Project to Your Server

git clone https://github.com/wlhtea/Suno2openai.git

Create a Database

Create a database (name it as you wish), remember to save the password, and ensure the database permissions are set correctly (allow connections from all IPs or only from Docker container IPs).

Configure Environment Variables

Rename the env.example file to .env and fill in the corresponding details:

SQL_NAME=<Database Name>
SQL_PASSWORD=<Database Password>
SQL_IP=<Database Host IP>
SQL_DK=3306 # Database port
USER_NAME=<Database Username>

Enter the Project Directory

cd Suno2openai

Update Cookie

Start Docker

docker compose build && docker compose up

Notes:

  • Security Group Configuration: Ensure the port 8000 is open.
  • HTTPS Support: If the frontend project uses HTTPS, the proxy URL of this project should also use HTTPS.

🍪 Obtaining Cookies

For Personal Use

Edit the update_cookie_to_sql.py file and insert your cookies into the array below:

cookies = ['cookie1', 'cookie2']

cookie位置示例

🔌 Integrating new-api(one-api)

In the channel's proxy settings, enter the project address as http://<server IP>:8000. HTTPS and a domain name are recommended.

🎉 Effect Display

效果图

💌 Internship Opportunities

If interested in welcoming a third-year student with experience in data analysis and front-end/back-end development for an internship, please contact:

Support Us: If you find this project helpful, please do not hesitate to star it ⭐! We welcome any form of support and suggestions, let’s progress together!

About

以openai格式调用suno api,并将cookie保存为数据库,实现cookie池调用 📈已接入newapi、oneapi中转站,适配chat-next-web等前端项目 || Call suno api in openai format, and save the cookie as a database to realize the cookie pool call to access newapi, oneapi relay station, adapting chat-next-web and other front-end projects

License:MIT License


Languages

Language:Python 99.8%Language:Dockerfile 0.2%