logo
icon

SunoApi

Suno API Unofficial Suno AI client, currently supports the generation of music, access to music information and other functions.

template cover
部署次數53
發布者SunoApi
建立於2024-04-29
模板內的服務
service icon
標籤
APIAutomationWebsite

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.