Generate Audio Endpoint

Overview

Generates audio from a text prompt using Suno AI. This is the basic generation endpoint that creates music based on a prompt.

🔗 Quick Links

Endpoint

POST /api/generate
POST /[accountId]/api/generate

Request

Headers

Content-Type: application/json

Body (JSON)

prompt (string, required)
Text prompt describing the music to generate

make_instrumental (boolean, optional, default: false)
Whether to generate instrumental music (no vocals)

model (string, optional, default: "chirp-crow")
Model to use for generation

wait_audio (boolean, optional, default: false)
Whether to wait for audio to be fully generated before returning

Example Request

curl -X POST https://your-domain.com/api/generate \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A upbeat pop song about summer",
    "make_instrumental": false,
    "model": "chirp-crow",
    "wait_audio": true
  }'
const response = await fetch('/api/generate', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    prompt: 'A upbeat pop song about summer',
    make_instrumental: false,
    wait_audio: true
  })
});

Response

Success Response (200 OK)

Returns an array of AudioInfo objects:

[
  {
    "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "title": "Summer Vibes",
    "image_url": "https://cdn.suno.ai/image-12345.png",
    "lyric": "A upbeat pop song about summer",
    "audio_url": "https://cdn.suno.ai/audio-12345.mp3",
    "video_url": "https://cdn.suno.ai/video-12345.mp4",
    "created_at": "2025-12-09T14:30:00.000Z",
    "model_name": "chirp-crow",
    "status": "complete",
    "gpt_description_prompt": "A upbeat pop song about summer",
    "prompt": "A upbeat pop song about summer",
    "type": "music",
    "tags": "pop, upbeat",
    "negative_tags": null,
    "duration": "180"
  }
]

Status Code: 200
Content-Type: application/json

Payment Required (402)

When account credits are insufficient:

{
  "error": "Insufficient credits"
}

Status Code: 402
Content-Type: application/json

Internal Server Error (500)

When an error occurs during generation:

{
  "error": "Internal server error: [error details]"
}

Status Code: 500
Content-Type: application/json

Method Not Allowed (405)

When using an unsupported HTTP method:

Status Code: 405
Headers: Allow: POST

Notes

  • If wait_audio is false, the returned audio may have status: "streaming" and audio_url may not be available yet
  • If wait_audio is true, the endpoint waits for audio generation to complete (may take 30-60+ seconds)
  • The default model is "chirp-crow" if not specified
  • All responses include CORS headers