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
Implement hCaptcha solving via 2Captcha & other stuff
- implement hCaptcha solving via paid service 2Captcha and browser automation library Playwright with rebrowser-patches
- implement sunoApi instances caching so sessions won't be constantly updated
- add support for entering cookies not only in SUNO_COOKIE, but also the Cookie HTTP header
- update docs and add Russian docs
| <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
+
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.
68
+
69
+
### 3. Clone and deploy this project
59
70
60
71
You can choose your preferred deployment method:
61
72
62
73
#### Deploy to Vercel
63
74
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)
75
+
[](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)
Alternatively, you can use [Docker Compose](https://docs.docker.com/compose/)
85
+
#### Docker
86
+
Alternatively, you can use [Docker Compose](https://docs.docker.com/compose/). However, follow the step below before running.
75
87
76
88
```bash
77
89
docker compose build && docker compose up
78
90
```
79
91
80
-
### 3. Configure suno-api
92
+
### 4. Configure suno-api
81
93
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.
94
+
- If deployed to Vercel, please add the environment variables in the Vercel dashboard.
83
95
84
96
- If you’re running this locally, be sure to add the following to your `.env` file:
85
-
97
+
#### Environment variables
98
+
-`SUNO_COOKIE` — the `Cookie` header you obtained in the first step.
99
+
-`TWOCAPTCHA_KEY` — your 2Captcha API key from the second step.
100
+
-`BROWSER` — the name of the browser that is going to be used to solve the CAPTCHA. Only `chromium` and `firefox` supported.
101
+
-`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.
102
+
-`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)
103
+
-`BROWSER_HEADLESS` — run the browser without the window. You probably want to set this to `true`.
86
104
```bash
87
-
SUNO_COOKIE=<your-cookie>
105
+
SUNO_COOKIE=<…>
106
+
TWOCAPTCHA_KEY=<…>
107
+
BROWSER=chromium
108
+
BROWSER_GHOST_CURSOR=false
109
+
BROWSER_LOCALE=en
110
+
BROWSER_HEADLESS=true
88
111
```
89
112
90
-
### 4. Run sunoapi
113
+
### 5. Run suno-api
91
114
92
115
- If you’ve deployed to Vercel:
93
116
- Please click on Deploy in the Vercel dashboard and wait for the deployment to be successful.
@@ -108,7 +131,7 @@ SUNO_COOKIE=<your-cookie>
108
131
109
132
it means the program is running normally.
110
133
111
-
### 5. Use Suno API
134
+
### 6. Use Suno API
112
135
113
136
You can check out the detailed API documentation at :
114
137
[suno.gcui.ai/docs](https://suno.gcui.ai/docs)
@@ -132,18 +155,20 @@ Suno API currently mainly implements the following APIs:
132
155
- `/api/concat`: Generate the whole song from extensions
133
156
```
134
157
158
+
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.
159
+
135
160
For more detailed documentation, please check out the demo site:
136
161
[suno.gcui.ai/docs](https://suno.gcui.ai/docs)
137
162
138
-
## API Integration Code Example
163
+
## API Integration Code Examples
139
164
140
165
### Python
141
166
142
167
```python
143
168
import time
144
169
import requests
145
170
146
-
# replace your vercel domain
171
+
# replace with your suno-api URL
147
172
base_url = 'http://localhost:3000'
148
173
149
174
@@ -208,7 +233,7 @@ if __name__ == '__main__':
208
233
209
234
```
210
235
211
-
### Js
236
+
### JavaScript
212
237
213
238
```js
214
239
const axios = require("axios");
@@ -304,18 +329,18 @@ You can integrate Suno AI as a tool/plugin/action into your AI agent.
304
329
305
330
There are four ways you can support this project:
306
331
307
-
1. Fork and Submit Pull Requests: We welcome any PRs that enhance the component or editor.
332
+
1. Fork and Submit Pull Requests: We welcome any PRs that enhances 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
333
2. Open Issues: We appreciate reasonable suggestions and bug reports.
309
334
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
335
4. Spread the Word: Recommend this project to others, star the repo, or add a backlink after using the project.
311
336
312
337
## Questions, Suggestions, Issues, or Bugs?
313
338
314
-
We use GitHub Issues to manage feedback. Feel free to open an issue, and we'll address it promptly.
339
+
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
340
316
341
## License
317
342
318
-
LGPL-3.0 or later
343
+
The license of this project is LGPL-3.0 or later. See [LICENSE](LICENSE) for more information.
0 commit comments