# Suno AI API
[![GitHub][github_badge]][github_link] [![PyPI][pypi_badge]][pypi_link]
**Suno AI API** is
* An unofficial Python library for [Suno AI](https://www.suno.ai/) API
**Suno AI API** supports to
- [x] Create a Python client for Suno AI
- [x] Utilize Chirp v3 model to make a song by default
- [ ] Continue from a song
- [x] Make a song using CLI
- [x] Deploy a REST API available at [http://http://127.0.0.1/:8000](http://localhost:8000/)
- [ ] Deploy with Docker
- [ ] Deploy on Vercel
## Installation
```bash
pip install suno-api
```
or
```bash
git clone git@github.com:imyizhang/suno-api.git
cd suno-api
poetry install --only main
```
## Quickstart
### Sign in to Suno AI at https://app.suno.ai/, and get your cookie
You can find your cookie from the browser's **Developer Tools** -> **Network** tab

### Create a client for Suno AI with your cookie
```python
import suno
client = suno.Suno(cookie="your-cookie-here")
```
### Create your clips
```python
clips = client.songs.generate(
"your-song-description-here",
instrumental=False,
)
```
or start with **custom mode**
```python
clips = client.songs.generate(
"your-lyrics-here",
cutomized=True,
tags="your-music-style-here",
instrumental=False,
)
```
### Review your newly created clip
```python
clip = client.songs.get("your-clip-id-here")
```
### Review all your created clips in the library
```python
clips = client.songs.list()
```
### Check your remaining credits
```python
credits = client.get_credits()
```
### Download a clip on Suno AI
```python
suno.download("your-clip-id-here")
```
## Documentation
### Python Library
#### `suno.Song`
##### `suno.Song(*args, **kwargs)`
An object representing a song.
**Properties:**
**id** (`str`): Unique ID for the song.
**video_url** (`str`): Video URL for the song.
**audio_url** (`str`): Audio URL for the song.
**image_url** (`str | None`): Image URL for the song.
**image_large_url** (`str | None`): Large image URL for the song.
**major_model_version** (`str`): Major model version used to create the song.
**model_name** (`str`): Model name used to create the song.
**metadata** (`dict`): Metadata of the song.
**is_liked** (`bool`): The song is liked or not.
**user_id** (`str`): Unique ID for a user who created the song.
**is_trashed** (`bool`): The song is trashed or not.
**reaction** (`dict | None`): Reaction to the song.
**created** (`str`): When the song was created.
**status** (`str`): Status for the song.
**title** (`str`): Title for the song.
**play_count** (`int`): Play count for the song.
**upvote_count** (`int`): Upvote count for song.
**is_public** (`bool`): The song is public or not.
#### `suno.Suno`
##### `suno.Suno(cookie: str)`
A object representing a client for Suno AI.
**Parameters:**
- **cookie** (`str`): Cookie stored for the cookie-based authentication.
**Properties:**
**headers** (`dict`): Request headers.
##### `songs.generate(prompt: str, custom: bool, tags: str, instrumental: bool)`
Create songs.
> Each song generation consumes 5 credits, thus a total of 10 credits is necessary for each successful call.
**Parameters:**
- **prompt** (`str`): Prompt used to create the song, song, description, lyrics, or style of music.
- **custom** (`bool`, optional): Whether to create the song in custom mode. Defaults to `False`.
- **tags** (`str`, optional): Tags indicating musical style of the song to be created. Defaults to `""`.
- **instrumental** (`bool`, optional): Whether to create the song without lyrics. Defaults to `False`.
**Returns:**
(`List[suno.Song]`): A list of `suno.Song` objects representing the created songs.
##### `get_songs()`
List all songs (equivalent to `songs.list()`).
**Returns:**
(`List[suno.Song]`): A list of `suno.Song` objects representing the songs in the library of the logged-in account.
##### `get_song(id: str)`
Get a song by its ID (equivalent to `songs.get(id: str)`).
**Parameters:**
- **id** (`str`): ID of the song.
**Returns:**
(`suno.Song`): A `suno.Song` object representing the song.
##### `get_credits()`
Get all credits left.
**Returns:**
(`int`): Remaining credits in the logged-in account.
#### `suno.download`
##### `suno.download(song: str | suno.Song, root: str)`
Download a song.
**Parameters:**
- **song** (`str | suno.Song`): ID indicating a song, URL linked to a song or an `suno.Song` object.
- **root** (`str`): Root directory to store the downloaded songs.
### REST API
#### Set environment variable `SUNO_COOKIE`
##### Check the value of the environment variable `SUNO_COOKIE` on macOS
```bash
echo $SUNO_COOKIE
```
##### Add the environment variable `SUNO_COOKIE` permanently on macOS
Find your current shell.
```bash
echo $0
```
In `zsh`, a environment variable can be permanently added to the configuration file `~/.zshrc`. In `bash`, the configuration file is `~/.bash_profile`.
```bash
vim ~/.zshrc
```
In the configuration file, add the environment variable `SUNO_COOKIE`.
```bash
export SUNO_COOKIE="your-cookie-here"
```
Save the changes to the configuration file and execute it.
```bash
source ~/.zshrc
```
#### Deployment
```bash
git clone git@github.com:imyizhang/suno-api.git
cd suno-api/suno
uvicorn api:app --reload
```
or
```bash
git clone git@github.com:imyizhang/suno-api.git
cd suno-api
poetry run python suno/api.py
```
#### POST `/v1/songs`
Create songs.
##### Request example
**cURL**
```bash
curl -X POST "http://localhost:8000/v1/songs" \
-H "Content-Type: application/json" \
-d '{"prompt": "Make a song about the moon"}'
```
**Suno AI CLI**
```bash
suno songs generate "Make a song about the moon"
```
**Python**
```python
import json
import requests
data = json.dumps({
"prompt": "Make a song about the moon",
})
response = requests.post("http://localhost:8000/v1/songs", data=data)
response.json()
```
#### GET `v1/songs`
List all songs.
##### Request example
**cURL**
```bash
curl -X GET "http://localhost:8000/v1/songs" \
-H "Accept: application/json"
```
**Suno AI CLI**
```bash
suno songs list
```
**Python**
```python
import requests
response = requests.get('http://localhost:8000/v1/songs')
response.json()
```
#### GET `v1/song/{id}`
Get a song by its ID.
##### Request example
**cURL**
```bash
curl -X GET "http://localhost:8000/v1/songs/{id}" \
-H "Accept: application/json"
```
**Suno AI CLI**
```bash
suno songs get ID
```
**Python**
```python
import requests
response = requests.get('http://localhost:8000/v1/songs/{id}')
response.json()
```
##### Response Example
```json
{
"id":"0e42f167-17ab-4004-941b-d549b24dce76",
"video_url":"https://cdn1.suno.ai/0e42f167-17ab-4004-941b-d549b24dce76.mp4",
"audio_url":"https://cdn1.suno.ai/0e42f167-17ab-4004-941b-d549b24dce76.mp3",
"image_url":"https://cdn1.suno.ai/image_75b03116-0aa2-4367-bdf6-8556dde4df9f.png",
"image_large_url":"https://cdn1.suno.ai/image_large_75b03116-0aa2-4367-bdf6-8556dde4df9f.png",
"major_model_version":"v3",
"model_name":"chirp-v3",
"metadata":{
"tags":"Rap\nJapanese rock\nPop\nVocaloid style\nEnergetic\nUpbeat\nCatchy\nCulinary\nCooking\nRecipe-focused",
"prompt":"[Chorus]\nIn der Weihnachtsbäckerei\nGibt es manche Leckerei\nZwischen Mehl und Milch\nMacht so mancher Knilch\nEine riesengroße Kleckerei\nIn der Weihnachtsbäckerei\nIn der Weihnachtsbäckerei\n\n[Verse 1]\nWo ist das Rezept geblieben\nVon den Plätzchen, die wir lieben?\nWer hat das Rezept verschleppt?\n\"Ich nicht\"\n\"Du vielleicht?\"\n\"Ich auch nicht\"\n\nNa, dann müssen wir es packen\nEinfach frei nach Schnauze backen\nSchmeißt den Ofen an (oh ja)\nUnd ran\n\n[Chorus]\nIn der Weihnachtsbäckerei\nGibt es manche Leckerei\nZwischen Mehl und Milch\nMacht so mancher Knilch\nEine riesengroße Kleckerei\nIn der Weihnachtsbäckerei\nIn der Weihnachtsbäckerei\n\n[Verse 2]\nBrauchen wir nicht Schokolade\nHoni
没有合适的资源?快使用搜索试试~ 我知道了~
Suno AI的非官方API :使用v3与Suno制作歌曲-suno AI

共10个文件
py:5个
gitignore:1个
toml:1个

需积分: 2 4 下载量 190 浏览量
2024-04-23
21:24:10
上传
评论
收藏 1.35MB ZIP 举报
温馨提示
Suno AI的非官方API :使用v3与Suno制作歌曲-suno AI 计算机技术是指评价计算机系统的各种知识和技能的总称。它涵盖了计算机硬件、软件、网络和信息安全等方面。计算机技术的发展使我们能够进行高效的数据处理、信息存储和传输。现代计算机技术包括操作系统、数据库管理、编程语言、算法设计等。同时,人工智能、云计算和大数据等新兴技术也在不断推动计算机技术的进步。计算机技术的应用广泛,涵盖了各个领域,如商业、医疗、教育和娱乐等。随着计算机技术的不断革新,我们可以更加高效地实现预期自动化、标准化
资源推荐
资源详情
资源评论


























收起资源包目录













共 10 条
- 1
资源评论


若明天不见
- 粉丝: 2w+
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 奥运工程建设项目管理全面提升.doc
- XX网络科技有限公司营销中心工作手册.doc
- 2023年数据挖掘实验报告.doc
- java实训心得体会(精选4篇)参考.doc
- 2023年系统集成项目管理工程师考试大纲复习知识点.doc
- 2022通信工程的求职信.docx
- IBM高级策略销售(5页).ppt
- TCL网络设备有限公司[1].ppt
- Excel表格通用模板:报价单模板.xls
- 2023年电大数据结构期末综合练习.doc
- 2022网络工程专业个人简历.docx
- 大数据技术和应用案例讲义.ppt
- Intel的电子商务简单介绍.doc
- java远程通讯技术及简单实现.docx
- AI和大数据在水环境中的应用案例.ppt
- cad打印怎么把彩色变黑白参考.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
