You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| <atarget="_blank"href="https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fgcui-art%2Fsuno-api&env=SUNO_COOKIE&project-name=suno-api&repository-name=suno-api">Deploy with Vercel</a>
14
+
| <atarget="_blank"href="https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fgcui-art%2Fsuno-api&env=SUNO_COOKIE,TWOCAPTCHA_KEY,BROWSER,BROWSER_GHOST_CURSOR,BROWSER_LOCALE,BROWSER_HEADLESS&project-name=suno-api&repository-name=suno-api">Deploy with Vercel</a>
Suno.ai v3 is an amazing AI music service. Although the official API is not yet available, we couldn't wait to integrate its capabilities somewhere.
26
+
Suno is an amazing AI music service. Although the official API is not yet available, we couldn't wait to integrate its capabilities somewhere.
26
27
27
28
We discovered that some users have similar needs, so we decided to open-source this project, hoping you'll like it.
28
29
30
+
This implementation uses the paid [2Captcha](https://2captcha.com/about) service (a.k.a. ruCaptcha) to solve the hCaptcha challenges automatically and does not use any already made closed-source paid Suno API implementations.
31
+
29
32
## Demo
30
33
31
34
We have deployed an example bound to a free Suno account, so it has daily usage limits, but you can see how it runs:
32
35
[suno.gcui.ai](https://suno.gcui.ai)
33
36
34
37
## Features
35
38
36
-
- Perfectly implements the creation API from app.suno.ai
39
+
- Perfectly implements the creation API from suno.ai.
37
40
- Automatically keep the account active.
41
+
- Solve CAPTCHAs automatically using [2Captcha](https://2captcha.com) and [Playwright](https://playwright.dev) with [rebrowser-patches](https://github.com/rebrowser/rebrowser-patches).
38
42
- Compatible with the format of OpenAI’s `/v1/chat/completions` API.
39
-
- Supports Custom Mode
40
-
- One-click deployment to Vercel
43
+
- Supports Custom Mode.
44
+
- One-click deployment to [Vercel](#deploy-to-vercel) & [Docker](#docker).
41
45
- In addition to the standard API, it also adapts to the API Schema of Agent platforms like GPTs and Coze, so you can use it as a tool/plugin/Action for LLMs and integrate it into any AI Agent.
42
46
- Permissive open-source license, allowing you to freely integrate and modify.
43
47
44
48
## Getting Started
45
49
46
-
### 1. Obtain the cookie of your app.suno.ai account
50
+
### 1. Obtain the cookie of your Suno account
47
51
48
-
1. Head over to [app.suno.ai](https://app.suno.ai) using your browser.
52
+
1. Head over to [suno.com/create](https://suno.com/create) using your browser.
49
53
2. Open up the browser console: hit `F12` or access the `Developer Tools`.
50
-
3. Navigate to the `Network tab`.
54
+
3. Navigate to the `Network` tab.
51
55
4. Give the page a quick refresh.
52
-
5. Identify the request that includes the keyword `client?_clerk_js_version`.
56
+
5. Identify the latest request that includes the keyword `?__clerk_api_version`.
53
57
6. Click on it and switch over to the `Header` tab.
54
58
7. Locate the `Cookie` section, hover your mouse over it, and copy the value of the Cookie.
### 2. Register on 2Captcha and top up your balance
63
+
[2Captcha](https://2captcha.com/about) is a paid CAPTCHA solving service that uses real workers to solve the CAPTCHA and has high accuracy. It is needed because of Suno constantly requesting hCaptcha solving that currently isn't possible for free by any means.
64
+
65
+
[Create](https://2captcha.com/auth/register?userType=customer) a new 2Captcha account, [top up](https://2captcha.com/pay) your balance and [get your API key](https://2captcha.com/enterpage#recognition).
66
+
67
+
> [!NOTE]
68
+
> If you are located in Russia or Belarus, use the [ruCaptcha](https://rucaptcha.com) interface instead of 2Captcha. It's the same service, but it supports payments from those countries.
69
+
70
+
> [!TIP]
71
+
> If you want as few CAPTCHAs as possible, it is recommended to use a macOS system. macOS systems usually get fewer CAPTCHAs than Linux and Windows—this is due to its unpopularity in the web scraping industry. Running suno-api on Windows and Linux will work, but in some cases, you could get a pretty large number of CAPTCHAs.
72
+
73
+
### 3. Clone and deploy this project
59
74
60
75
You can choose your preferred deployment method:
61
76
62
77
#### Deploy to Vercel
63
78
64
-
[](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fgcui-art%2Fsuno-api&env=SUNO_COOKIE&project-name=suno-api&repository-name=suno-api)
79
+
[](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fgcui-art%2Fsuno-api&env=SUNO_COOKIE,TWOCAPTCHA_KEY,BROWSER,BROWSER_GHOST_CURSOR,BROWSER_LOCALE,BROWSER_HEADLESS&project-name=suno-api&repository-name=suno-api)
> GPU acceleration will be disabled in Docker. If you have a slow CPU, it is recommended to [deploy locally](#run-locally).
73
91
74
-
Alternatively, you can use [Docker Compose](https://docs.docker.com/compose/)
92
+
Alternatively, you can use [Docker Compose](https://docs.docker.com/compose/). However, follow the step below before running.
75
93
76
94
```bash
77
95
docker compose build && docker compose up
78
96
```
79
97
80
-
### 3. Configure suno-api
98
+
### 4. Configure suno-api
81
99
82
-
- If deployed to Vercel, please add an environment variable `SUNO_COOKIE`in the Vercel dashboard, with the value of the cookie obtained in the first step.
100
+
- If deployed to Vercel, please add the environment variables in the Vercel dashboard.
83
101
84
102
- If you’re running this locally, be sure to add the following to your `.env` file:
85
-
103
+
#### Environment variables
104
+
-`SUNO_COOKIE` — the `Cookie` header you obtained in the first step.
105
+
-`TWOCAPTCHA_KEY` — your 2Captcha API key from the second step.
106
+
-`BROWSER` — the name of the browser that is going to be used to solve the CAPTCHA. Only `chromium` and `firefox` supported.
107
+
-`BROWSER_GHOST_CURSOR` — use ghost-cursor-playwright to simulate smooth mouse movements. Please note that it doesn't seem to make any difference in the rate of CAPTCHAs, so you can set it to `false`. Retained for future testing.
108
+
-`BROWSER_LOCALE` — the language of the browser. Using either `en` or `ru` is recommended, since those have the most workers on 2Captcha. [List of supported languages](https://2captcha.com/2captcha-api#language)
109
+
-`BROWSER_HEADLESS` — run the browser without the window. You probably want to set this to `true`.
86
110
```bash
87
-
SUNO_COOKIE=<your-cookie>
111
+
SUNO_COOKIE=<…>
112
+
TWOCAPTCHA_KEY=<…>
113
+
BROWSER=chromium
114
+
BROWSER_GHOST_CURSOR=false
115
+
BROWSER_LOCALE=en
116
+
BROWSER_HEADLESS=true
88
117
```
89
118
90
-
### 4. Run sunoapi
119
+
### 5. Run suno-api
91
120
92
121
- If you’ve deployed to Vercel:
93
122
- Please click on Deploy in the Vercel dashboard and wait for the deployment to be successful.
@@ -108,7 +137,7 @@ SUNO_COOKIE=<your-cookie>
108
137
109
138
it means the program is running normally.
110
139
111
-
### 5. Use Suno API
140
+
### 6. Use Suno API
112
141
113
142
You can check out the detailed API documentation at :
114
143
[suno.gcui.ai/docs](https://suno.gcui.ai/docs)
@@ -132,18 +161,20 @@ Suno API currently mainly implements the following APIs:
132
161
- `/api/concat`: Generate the whole song from extensions
133
162
```
134
163
164
+
You can also specify the cookies in the `Cookie` header of your request, overriding the default cookies in the `SUNO_COOKIE` environment variable. This comes in handy when, for example, you want to use multiple free accounts at the same time.
165
+
135
166
For more detailed documentation, please check out the demo site:
136
167
[suno.gcui.ai/docs](https://suno.gcui.ai/docs)
137
168
138
-
## API Integration Code Example
169
+
## API Integration Code Examples
139
170
140
171
### Python
141
172
142
173
```python
143
174
import time
144
175
import requests
145
176
146
-
# replace your vercel domain
177
+
# replace with your suno-api URL
147
178
base_url = 'http://localhost:3000'
148
179
149
180
@@ -208,7 +239,7 @@ if __name__ == '__main__':
208
239
209
240
```
210
241
211
-
### Js
242
+
### JavaScript
212
243
213
244
```js
214
245
const axios = require("axios");
@@ -304,18 +335,18 @@ You can integrate Suno AI as a tool/plugin/action into your AI agent.
304
335
305
336
There are four ways you can support this project:
306
337
307
-
1. Fork and Submit Pull Requests: We welcome any PRs that enhance the component or editor.
338
+
1. Fork and Submit Pull Requests: We welcome any PRs that enhance the functionality, APIs, response time and availability. You can also help us just by translating this README into your language—any helpfor this project is welcome!
308
339
2. Open Issues: We appreciate reasonable suggestions and bug reports.
309
340
3. Donate: If this project has helped you, consider buying us a coffee using the Sponsor button at the top of the project. Cheers! ☕
310
341
4. Spread the Word: Recommend this project to others, star the repo, or add a backlink after using the project.
311
342
312
343
## Questions, Suggestions, Issues, or Bugs?
313
344
314
-
We use GitHub Issues to manage feedback. Feel free to open an issue, and we'll address it promptly.
345
+
We use [GitHub Issues](https://github.com/gcui-art/suno-api/issues) to manage feedback. Feel free to open an issue, and we'll address it promptly.
315
346
316
347
## License
317
348
318
-
LGPL-3.0 or later
349
+
The license of this project is LGPL-3.0 or later. See [LICENSE](LICENSE) for more information.
0 commit comments