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 URL
https://generatesongs.ai/api/v1

Authentication

All API requests require a valid API key passed in the Authorization header.

Header format
Authorization: Bearer gs_your_api_key

Create API keys from the API Keys page. Keep your keys secret — do not share them or expose them in client-side code.

Rate Limits

API requests are rate-limited to ensure fair usage. Current limits:

EndpointLimit
Song generation10 requests/minute
Song queries60 requests/minute
AI features (optimize, generate, tags)20 requests/minute
File uploads10 requests/minute

Rate limit headers (X-RateLimit-Remaining) are included in responses.

Error Handling

The API returns standard HTTP status codes. Error responses include a JSON body with an error field.

StatusMeaning
400Bad Request — invalid parameters
401Unauthorized — invalid or missing API key
402Payment Required — insufficient credits
404Not Found — resource doesn't exist
429Too Many Requests — rate limit exceeded
500Internal Server Error
Error response
{
  "error": "'style' is required and must be a non-empty string"
}
POST/songs/generate

Generate a new song. Consumes 1 credit per song (or n credits when generating multiple).

ParameterTypeRequiredDescription
stylestringYesMusic style, genre, mood (1-1024 chars)
lyricsstringNoSong lyrics (max 3000 chars). Omit for AI-generated.
instrumentalbooleanNoGenerate instrumental only (default: false)
titlestringNoSong title (max 50 chars)
vocalGenderstringNo'male' or 'female' — auto if omitted
referenceFileIdstringNoReference audio file ID from upload
vocalFileIdstringNoVocal reference file ID from upload
melodyFileIdstringNoMelody idea file ID (standalone only)
nintegerNoNumber of songs (1-3, default 1)
Request
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"}'
Response (201)
{
  "songId": "abc123def456",
  "status": "processing"
}

File reference rules: melodyFileId cannot be combined with referenceFileId or vocalFileId. referenceFileId can be combined with vocalFileId only.

GET/songs/:songId

Get the status and details of a generated song. Poll this endpoint to check if generation is complete.

ParameterTypeRequiredDescription
songIdstringYesSong ID (URL parameter)
Request
curl https://generatesongs.ai/api/v1/songs/abc123 \
  -H "Authorization: Bearer gs_your_api_key"
Response (200)
{
  "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",
  "isInstrumental": false,
  "createdAt": "2026-02-28T12:00:00Z"
}
GET/songs/:songId/download

Download the generated audio file (MP3). Only available for completed songs.

Request
curl -O https://generatesongs.ai/api/v1/songs/abc123/download \
  -H "Authorization: Bearer gs_your_api_key"
GET/songs

List all songs associated with your account, ordered by creation date.

Response (200)
[
  {
    "id": "abc123",
    "status": "completed",
    "title": "Summer Vibes",
    "duration": 187
  },
  ...
]
GET/credits

Check your current credit balance.

Response (200)
{
  "credits": 42
}
POST/files/upload

Upload an audio file for use as a reference, vocal sample, or melody idea in song generation.

ParameterTypeRequiredDescription
filebinaryYesAudio file (mp3, m4a, mid). Max 20MB.
purposestringYesreference, vocal, melody, or instrumental
Request (multipart form)
curl -X POST https://generatesongs.ai/api/v1/files/upload \
  -H "Authorization: Bearer gs_your_api_key" \
  -F "file=@reference.mp3" \
  -F "purpose=reference"
Response (200)
{
  "id": "file_abc123",
  "filename": "reference.mp3",
  "purpose": "reference"
}
POST/ai/optimize

Improve existing lyrics using AI — fix rhythm, rhyme, flow, and emotional impact. Does not consume credits.

ParameterTypeRequiredDescription
lyricsstringYesLyrics to optimize (max 5000 chars)
stylestringNoStyle hint for optimization context
Response (200)
{
  "lyrics": "[Verse 1]\\nImproved lyrics here..."
}
POST/ai/generate-lyrics

Generate original song lyrics using AI based on a style description. Does not consume credits.

ParameterTypeRequiredDescription
stylestringYesMusic style to write lyrics for
topicstringNoOptional topic or theme
Response (200)
{
  "lyrics": "[Verse 1]\\nGenerated lyrics here..."
}
POST/ai/suggest-tags

Get AI-suggested style tags that complement your current input. Does not consume credits.

ParameterTypeRequiredDescription
inputstringYesCurrent style description
Response (200)
{
  "tags": ["Acoustic", "Dreamy", "Reverb", "Indie"]
}

Code Examples

cURL

Generate and poll
# 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
curl -O https://generatesongs.ai/api/v1/songs/$SONG_ID/download \
  -H "Authorization: Bearer $API_KEY"

JavaScript

Node.js / Bun
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

Python 3
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

Coming Soon

Webhook support for real-time generation status updates is in development. Currently, use polling to check song status.

SDKs

Coming Soon

Official SDKs for JavaScript/TypeScript, Python, and Go are planned. In the meantime, use the REST API directly with any HTTP client.