wlhtea/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
웹 및 앱 개발What you can do
- 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.
측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- -1
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
Original中文 English
Suno2openai
Integrated based on SunoSongsCreator and Suno-API projects, offering standardized service interfaces compliant with OpenAI formats.
✨ 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: [email protected]
🐳 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.
- MySQL version >= 5.7
How to get cookie
copy all content about the cookie
Steps
Pull Docker Image
Ensure the Docker image
wlhtea/suno2openai:latestis available on your machine. If not, you can pull it from the Docker repository using:docker pull wlhtea/suno2openai:latestRun 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 \ -p 8501:8501 \ -e BASE_URL='<BASE_URL>' \ -e SESSION_ID='<SESSION_ID>' \ -e USER_NAME='<USER_NAME>' \ -e SQL_NAME='<SQL_NAME>' \ -e SQL_PASSWORD='<SQL_PASSWORD>' \ -e SQL_IP='127.0.0.1' \ -e SQL_DK=3306 \ -e COOKIES_PREFIX='your_cookies_prefix' \ -e AUTH_KEY='<AUTH_KEY>' \ -e RETRIES=5 \ -e BATCH_SIZE=10 \ -e MAX_TIME=5 \ --restart=always \ wlhtea/suno2openai:latestExample
docker run -d --name wsunoapi \ -p 8000:8000 \ -p 8501:8501 \ -e BASE_URL='https://studio-api.suno.ai' \ -e SESSION_ID='your-session-id' \ -e USER_NAME='suno2openaiUsername' \ -e SQL_NAME='suno2openaiSQLname' \ -e SQL_PASSWORD='12345678' \ -e SQL_IP='127.0.0.1' \ -e SQL_DK=3306 \ -e COOKIES_PREFIX='your_cookies_prefix' \ -e AUTH_KEY='your-auth-key' \ -e RETRIES=5 \ -e BATCH_SIZE=10 \ -e MAX_TIME=5 \ --restart=always \ wlhtea/suno2openai:latest
Parameter Explanation:
-d: Run the container in detached mode and log the container ID.--name wsunoapi: Name your containerwsunoapifor 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.
Access the Application
Once the container is running, the application inside should be accessible via
http://localhost:8000or 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:
BASE_URL=https://studio-api.suno.ai
SESSION_ID=your-session-id
USER_NAME=your-username
SQL_NAME=your-database-name
SQL_PASSWORD=your-database-password
SQL_IP=127.0.0.1
SQL_DK=3306
COOKIES_PREFIX=your_cookies_prefix
AUTH_KEY=your-auth-key
RETRIES=5
BATCH_SIZE=10
MAX_TIME=5
Enter the Project Directory
cd Suno2openai
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.
📋 API Requests
API Overview
- Add Cookie: Use the
/your_cookies_prefix/cookiesendpoint to add cookies. - Get All Cookies: Use the
/your_cookies_prefix/cookiesendpoint to retrieve all cookies. - Delete Cookie: Use the
/your_cookies_prefix/cookiesendpoint to delete specific cookies. - Refresh Cookie: Use the
/your_cookies_prefix/refresh/cookiesendpoint to refresh cookies. - Generate Chat Completion: Use the
/v1/chat/completionsendpoint to generate chat responses.
Add Cookie Example
You can add cookies using the /your_cookies_prefix/cookies endpoint. Here is an example request using requests library in Python:
import requests
url = "http://localhost:8000/your_cookies_prefix/cookies"
headers = {
"Authorization": "Bearer your-auth-key",
"Content-Type": "application/json"
}
data = {
"cookies": ["cookie1", "cookie2"]
}
response = requests.put(url, headers=headers, json=data)
print(response.text)
Get All Cookies Example
You can retrieve all cookies using the /your_cookies_prefix/cookies endpoint. Here is an example request:
import requests
url = "http://localhost:8000/your_cookies_prefix/cookies"
headers = {
"Authorization": "Bearer your-auth-key",
"Content-Type": "application/json"
}
response = requests.post(url, headers=headers)
print(response.text)
Delete Cookie Example
You can delete specific cookies using the /your_cookies_prefix/cookies endpoint. Here is an example request:
import requests
url = "http://localhost:8000/your_cookies_prefix/cookies"
headers = {
"Authorization": "Bearer your-auth-key",
"Content-Type": "application/json"
}
data = {
"cookies": ["cookie1", "cookie2"]
}
response = requests.delete(url, headers=headers, json=data)
print(response.text)
Refresh Cookies Example
You can refresh cookies using the /your_cookies_prefix/refresh/cookies endpoint. Here is an example request:
import requests
url = "http://localhost:8000/your_cookies_prefix/refresh/cookies"
headers = {
"Authorization": "Bearer your-auth-key",
"Content-Type": "application/json"
}
response = requests.get(url, headers=headers)
print(response.text)
Generate Chat Completion Example
You can use the /v1/chat/completions endpoint to generate chat responses. Here is an example request:
import requests
url = "http://localhost:8000/v1/chat/completions"
headers = {
"Authorization": "Bearer your-auth-key",
"Content-Type": "application/json"
}
data = {
"model": "gpt-3.5-turbo",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Tell me a joke."}
]
# "stream": true # Uncomment to enable streaming output
}
response = requests.post(url, headers=headers, json=data)
print(response.text)
Parameter Explanation
BASE_URL: Default API base URL, defaults tohttps://studio-api.suno.aiif not set.SESSION_ID: The session ID.USER_NAME: Database username.SQL_NAME: Database name.SQL_PASSWORD: Database password.SQL_IP: Database IP address.SQL_DK: Database port, default is 3306.COOKIES_PREFIX: Prefix for cookies, remember/to begin with.AUTH_KEY: Authorization key, default is the current timestamp.RETRIES: Number of retries, default is 5.BATCH_SIZE: Batch size, default is 10.MAX_TIME: Maximum request time (min), default is 5.
BATCH_SIZE`: Batch size, default is 10.
🎉 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:
- 📧 Email: [email protected]
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!
관련 프로젝트 살펴보기
불러오는 중…