Chat Mode: Generate Song
Short description: Use the Suno chat API to generate song lyrics text.
Overview
- Method:
POST - Path:
/v1/chat/completions - Content-Type:
application/json
Authentication
- Header:
Authorization: Bearer <token> - Header:
Content-Type: application/json
Request Example
Headers
| Header | Example | Required |
|---|---|---|
| Content-Type | application/json | Yes |
| Authorization | Bearer sk-xxxx | Yes |
Request Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | Model name, choose suno-v3 or suno-v3.5 |
| messages | array | Yes | List of messages containing role and content |
| stream | boolean | No | Whether to enable streaming output, recommended true |
curl Example
bash
curl -X POST "https://api.gpt.ge/v1/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxx" \
-d '{
"model": "suno-v3.5",
"messages": [
{
"role": "user",
"content": "Generate a cheerful Chinese song"
}
],
"stream": true
}'JavaScript (fetch) Example
javascript
fetch('https://api.gpt.ge/v1/chat/completions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer sk-xxxx'
},
body: JSON.stringify({
model: 'suno-v3.5',
messages: [
{ role: 'user', content: 'Generate a cheerful Chinese song' }
],
stream: true
})
}).then(r => r.json()).then(console.log);Python (requests) Example
python
import requests
response = requests.post(
'https://api.gpt.ge/v1/chat/completions',
headers={
'Content-Type': 'application/json',
'Authorization': 'Bearer sk-xxxx'
},
json={
'model': 'suno-v3.5',
'messages': [
{ 'role': 'user', 'content': 'Generate a cheerful Chinese song' }
],
'stream': True
}
)
print(response.json())Response Example (200)
json
{
"id": "chatcmpl-1234567890",
"object": "chat.completion",
"created": 1712345678,
"model": "suno-v3.5",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Here is a cheerful Chinese song lyric...",
"refusal": null
},
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 50,
"completion_tokens": 120,
"total_tokens": 170
},
"system_fingerprint": "abc123xyz"
}Note: This endpoint is designed for Suno music creation scenarios and follows a chat completion format compatible with other chat models.