Unofficial Python API wrapper for Suno music generation service. This API allows you to generate songs and retrieve them programmatically, perfect for integration with automation tools like N8N.
- 🎵 Generate Songs: Create songs using GPT description prompts
- 🔄 Automatic Token Renewal: JWT tokens are automatically renewed before expiration
- 📊 Song Retrieval: Get song/clip information by IDs
- 💳 Credits Info: Check your account credits and billing info
- 🚀 FastAPI: Modern async API built with FastAPI
- 🔌 N8N Ready: Simple HTTP endpoints perfect for N8N workflows
- A Suno account
- Your session credentials from the browser
- Log in to Suno in your browser
- Open Developer Tools (F12)
- Go to Application tab → Cookies →
https://suno.com - Find the
__sessioncookie and copy its value (this is yourSESSION_ID) - Copy all cookies as a cookie string (this is your
COOKIE)- In Chrome DevTools: Right-click on cookies → Copy as cURL → extract cookie header
- Or use a cookie export extension
pip install -r requirements.txtCreate a .env file or set environment variables:
SESSION_ID=your_session_id_here
COOKIE=your_cookie_string_here
DEVICE_ID=optional_device_id # Auto-generated if not provideduvicorn main:app --host 0.0.0.0 --port 8000The API will be available at http://localhost:8000 with documentation at http://localhost:8000/docs
POST /generate
Generate a new song using a description prompt.
Request Body:
{
"gpt_description_prompt": "A happy upbeat song about coding",
"make_instrumental": false,
"mv": "chirp-crow"
}Response:
{
"code": 0,
"msg": "success",
"data": {
"clips": [
{
"id": "clip-id-here",
"status": "complete",
"audio_url": "https://..."
}
]
}
}POST /feed
GET /feed/{clip_id}
Retrieve information about songs/clips by their IDs.
Request Body (POST):
{
"clip_ids": ["clip-id-1", "clip-id-2"]
}GET /download/{clip_id}
Download the audio file directly. The file will be streamed to the client.
Example:
curl -O https://your-api-url/download/clip-id-hereOr in N8N, use HTTP Request node with "Save File" option enabled.
GET /download-url/{clip_id}
Get the direct download URL for a clip (useful for direct downloads or N8N).
Response:
{
"code": 0,
"msg": "success",
"data": {
"audio_url": "https://cdn1.suno.ai/...",
"clip_id": "clip-id-here"
}
}GET /audio-info/{clip_id}
Get complete audio information including URL, metadata, and status.
Response:
{
"code": 0,
"msg": "success",
"data": {
"clip_id": "clip-id-here",
"audio_url": "https://...",
"title": "Song Title",
"status": "complete",
"metadata": {...}
}
}GET /credits
Get your account credits and billing information.
GET /session
Get current session information including available models.
- Add an HTTP Request node
- Method:
POST - URL:
http://your-api-url/generate - Headers:
Content-Type: application/json - Body:
{ "gpt_description_prompt": "A relaxing jazz tune", "make_instrumental": false }
- Add an HTTP Request node
- Method:
GET - URL:
http://your-api-url/feed/{clip_id}- Replace
{clip_id}with the ID from the generate response
- Replace
HTTP Request (Generate)
→ Wait (poll every 30 seconds)
→ HTTP Request (Check Status)
→ If Complete → Continue
→ If Not Complete → Loop back to Wait
The API automatically handles JWT token renewal:
- Tokens are checked before each request
- Tokens are renewed 5 minutes before expiration
- No manual intervention needed
If authentication fails:
- Check that your
SESSION_IDandCOOKIEare still valid - Update them if they've expired
- Restart the API
docker build -t suno-api .
docker run -p 8000:8000 \
-e SESSION_ID=your_session_id \
-e COOKIE=your_cookie_string \
suno-apiversion: '3'
services:
suno-api:
build: .
ports:
- "8000:8000"
environment:
- SESSION_ID=${SESSION_ID}
- COOKIE=${COOKIE}
- DEVICE_ID=${DEVICE_ID}| Variable | Required | Description |
|---|---|---|
SESSION_ID |
Yes | Your Suno session ID from browser cookies |
COOKIE |
Yes | Your Suno cookie string from browser |
DEVICE_ID |
No | Device ID (auto-generated UUID if not provided) |
Available model versions (mv parameter):
chirp-crow- Latest model (default)chirp-v4- Version 4chirp-v3-5- Version 3.5chirp-v3-0- Version 3.0
If you get authentication errors:
- Log out and log back into Suno
- Get fresh
SESSION_IDandCOOKIEvalues - Update environment variables and restart
- Check your credits:
GET /credits - Verify your prompt is not too long
- Check the model version is valid
- Ensure all environment variables are set
- Check port 8000 is not in use
- Review logs for specific errors
This is an unofficial API wrapper. Use at your own risk. The Suno service may change their API at any time.
See LICENSE file.
This is an unofficial API wrapper. It is not affiliated with or endorsed by Suno. Use responsibly and in accordance with Suno's terms of service.