API Reference
The GenerateSongs API lets you generate AI-powered songs programmatically. Use it to integrate song generation into your apps, workflows, or creative tools.
Base URLhttps://generatesongs.ai/api/v1
Authentication
All API requests require a valid API key passed in the Authorization header.
Authorization: Bearer gs_your_api_keyCreate API keys from the API Keys page. Keep your keys secret — do not share them or expose them in client-side code.
Error Handling
The API returns standard HTTP status codes. Error responses include a JSON body with an error field.
| Status | Meaning |
|---|---|
| 400 | Bad Request — invalid parameters |
| 401 | Unauthorized — invalid or missing API key |
| 402 | Payment Required — insufficient credits |
| 404 | Not Found — resource doesn't exist |
| 500 | Internal Server Error |
{
"error": "'style' is required and must be a non-empty string"
}/songs/generateGenerate a new song. Consumes 1 credit.
| Parameter | Type | Required | Description |
|---|---|---|---|
| style | string | Yes | Music style, genre, mood (1-1024 chars) |
| lyrics | string | No | Song lyrics (max 3000 chars). Omit for AI-generated. |
| instrumental | boolean | No | Generate instrumental only (default: false) |
| title | string | No | Song title (max 50 chars) |
| vocalGender | string | No | 'male' or 'female' — auto if omitted |
| referenceFileId | string | No | Reference audio file ID from upload |
| vocalFileId | string | No | Vocal reference file ID from upload |
| melodyFileId | string | No | Melody idea file ID (standalone only) |
curl -X POST https://generatesongs.ai/api/v1/songs/generate \
-H "Authorization: Bearer gs_your_api_key" \
-H "Content-Type: application/json" \
-d '{"style": "upbeat pop", "title": "Summer Vibes", "vocalGender": "female"}'{
"songId": "abc123def456",
"status": "processing"
}File reference rules: melodyFileId cannot be combined with referenceFileId or vocalFileId. referenceFileId can be combined with vocalFileId only.
/songs/:songIdGet the status and details of a generated song. Poll this endpoint to check if generation is complete.
| Parameter | Type | Required | Description |
|---|---|---|---|
| songId | string | Yes | Song ID (URL parameter) |
curl https://generatesongs.ai/api/v1/songs/abc123 \
-H "Authorization: Bearer gs_your_api_key"{
"id": "abc123def456",
"status": "completed",
"title": "Summer Vibes",
"style": "upbeat pop",
"lyrics": "[Verse 1]\\nSunshine on my face...",
"duration": 187,
"downloadUrl": "https://generatesongs.ai/api/v1/songs/abc123?download",
"flacDownloadUrl": "https://generatesongs.ai/api/v1/songs/abc123?download&format=flac",
"isInstrumental": false,
"createdAt": "2026-02-28T12:00:00Z"
}Status values
| Status | Description |
|---|---|
| pending | Song created, waiting to be picked up by the generation provider |
| processing | Actively being generated — poll again in 5-10 seconds |
| completed | Generation finished — audio is ready to download via downloadUrl |
| failed | Generation failed — credit is automatically refunded |
/songs/:songId?downloadDownload the generated audio file. Available in MP3 (default) and FLAC (lossless) formats. Only available for completed songs. Supports Range headers for streaming.
| Parameter | Type | Required | Description |
|---|---|---|---|
| songId | string | Yes | Song ID (URL parameter) |
| format | string | No | 'mp3' (default) or 'flac' for lossless audio |
curl -OJ 'https://generatesongs.ai/api/v1/songs/abc123?download' \
-H "Authorization: Bearer gs_your_api_key"curl -OJ 'https://generatesongs.ai/api/v1/songs/abc123?download&format=flac' \
-H "Authorization: Bearer gs_your_api_key"/songsList all songs associated with your account, ordered newest first. Supports pagination.
| Parameter | Type | Required | Description |
|---|---|---|---|
| offset | integer | No | Pagination offset (default: 0) |
| limit | integer | No | Results per page (default: 20) |
{
"songs": [{
"id": "abc123",
"status": "completed",
"title": "Summer Vibes",
"style": "upbeat pop",
"lyrics": "[Verse 1]\\n...",
"duration": 187,
"downloadUrl": "...?download",
"flacDownloadUrl": "...?download&format=flac",
"isInstrumental": false,
"createdAt": "2026-02-28T12:00:00Z"
},
...
],
"total": 42,
"hasMore": true
}/creditsCheck your current credit balance.
{
"balance": 42
}/credits/historyGet your credit purchase history, including remaining credits and expiration dates for each purchase.
{
"balance": 42,
"history": [
{
"id": 1,
"amount": 50,
"remaining": 42,
"packName": "Popular",
"purchasedAt": "2026-01-15T10:00:00Z",
"expiresAt": "2026-07-15T10:00:00Z",
"isExpired": false
}
]
}/files/uploadUpload an audio file for use as a reference, vocal sample, or melody idea in song generation.
| Parameter | Type | Required | Description |
|---|---|---|---|
| file | binary | Yes | Audio file (mp3, m4a, mid). Max 10MB. |
| purpose | string | Yes | reference, vocal, melody, or instrumental |
curl -X POST https://generatesongs.ai/api/v1/files/upload \
-H "Authorization: Bearer gs_your_api_key" \
-F "file=@reference.mp3" \
-F "purpose=reference"{
"id": "file_abc123",
"filename": "reference.mp3",
"purpose": "reference"
}/ai/optimizeImprove existing lyrics using AI — fix rhythm, rhyme, flow, and emotional impact. Does not consume credits.
| Parameter | Type | Required | Description |
|---|---|---|---|
| lyrics | string | Yes | Lyrics to optimize (max 5000 chars) |
| style | string | No | Style hint for optimization context |
{
"lyrics": "[Verse 1]\\nImproved lyrics here..."
}/ai/generate-lyricsGenerate original song lyrics using AI based on a style description. Does not consume credits.
| Parameter | Type | Required | Description |
|---|---|---|---|
| style | string | Yes | Music style to write lyrics for |
| topic | string | No | Optional topic or theme |
{
"lyrics": "[Verse 1]\\nGenerated lyrics here..."
}Code Examples
cURL
# Generate a song
RESPONSE=$(curl -s -X POST https://generatesongs.ai/api/v1/songs/generate \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"style": "chill lo-fi hip hop"}')
SONG_ID=$(echo $RESPONSE | jq -r '.songId')
# Poll until complete
while true; do
STATUS=$(curl -s https://generatesongs.ai/api/v1/songs/$SONG_ID \
-H "Authorization: Bearer $API_KEY" | jq -r '.status')
[ "$STATUS" = "completed" ] && break
sleep 10
done
# Download MP3
curl -OJ 'https://generatesongs.ai/api/v1/songs/$SONG_ID?download' \
-H "Authorization: Bearer $API_KEY"
# Download FLAC (lossless)
curl -OJ 'https://generatesongs.ai/api/v1/songs/$SONG_ID?download&format=flac' \
-H "Authorization: Bearer $API_KEY"JavaScript
const API_KEY = process.env.GENERATESONGS_API_KEY;
const BASE = "https://generatesongs.ai/api/v1";
async function generateSong(style) {
const res = await fetch(`${BASE}/songs/generate`, {
method: "POST",
headers: {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ style }),
});
const { songId } = await res.json();
// Poll for completion
while (true) {
const song = await fetch(
`${BASE}/songs/${songId}`,
{ headers: { "Authorization": `Bearer ${API_KEY}` } }
).then(r => r.json());
if (song.status === "completed") return song;
if (song.status === "failed") throw new Error("Generation failed");
await new Promise(r => setTimeout(r, 10000));
}
}
const song = await generateSong("dreamy synthwave");
console.log(song.downloadUrl);Python
import requests, time, os
API_KEY = os.environ["GENERATESONGS_API_KEY"]
BASE = "https://generatesongs.ai/api/v1"
headers = {"Authorization": f"Bearer {API_KEY}"}
# Generate
res = requests.post(
f"{BASE}/songs/generate",
headers=headers,
json={"style": "ambient electronic"}
)
song_id = res.json()["songId"]
# Poll
while True:
song = requests.get(
f"{BASE}/songs/{'{song_id}'}",
headers=headers
).json()
if song["status"] == "completed":
break
time.sleep(10)
# Download
audio = requests.get(song["downloadUrl"], headers=headers)
with open("song.mp3", "wb") as f:
f.write(audio.content)Webhooks
Webhook support for real-time generation status updates is in development. Currently, use polling to check song status.
SDKs
Official SDKs for JavaScript/TypeScript, Python, and Go are planned. In the meantime, use the REST API directly with any HTTP client.