Skip to navigation

Audio API

View as Markdown

Create one asynchronous music task with a stable BeatAPI model ID. One endpoint carries every music model: write a song, then work on it by naming the task that made it. A call is billed at one fixed price, whatever the song’s length.

POST https://api.beatapi.io/v1/audios/tasks

POST /v1/audios/generations is the same route under a second name, so a client written for another gateway’s /v1/audios/generations only needs its base URL and API key changed. The reply is 201 with {"data": task}; save data.id and poll GET /v1/tasks/{task_id} until status is succeeded or failed, as for images and videos. GET /v1/media/models?media_type=audio lists the models.

Beta. The music models are served through third-party routes, not the model makers’ own APIs. A model may be briefly unavailable or queue longer than usual, and its options may change. A task that fails is not billed.

Models

ModelFamilyWhat it isPage
suno-v6SunoThe default Suno model: natural vocals and rich detail. Eighteen actions, from songs to stems, WAV, MIDI and personas.Suno v6
suno-v6-miniSunoLighter and faster.Suno v6
suno-v6-wildSunoBolder, more distinctive styles.Suno v6
lyria-3.5Google LyriaGoogle’s flagship music model: full songs with vocals up to four minutes, with length and tempo you set.Lyria
lyria-3-proGoogle LyriaThe previous Lyria generation, at the same price.Lyria

Every model takes model and action (default generate); each family has its own actions and fields, listed on its page. A field the model and action do not read is refused with 400 bad_request, never ignored, so a call is not billed for a song that is not the one you asked for.

Make a song

curl https://api.beatapi.io/v1/audios/tasks \
-H "Authorization: Bearer $BEATAPI_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: song-001" \
-d '{
"model": "suno-v6",
"prompt": "A warm acoustic folk song about driving home at dusk"
}'
{
"data": {
"id": "task_9Fh2Lq",
"object": "task",
"task_kind": "audio",
"media_type": "audio",
"model": "suno-v6",
"status": "queued",
"created_at": 1782210000,
"output": null
}
}

(The task object also carries usage, request_id, poll_after_seconds and the other fields every task has; they are left out here.)

Work on a song you made

A follow-up names the task that made the song in source_task_id and, when the task made more than one song, the song in audio_id. audio_id is one of output.tracks[].id; leave it out for the first song. source_task_id must be one of your own tasks, otherwise the call returns 400 bad_request (source_task_id does not name a task of yours). Do not send audio_id without source_task_id.

A follow-up uses a model of the same family as the song: a Suno song is extended with a Suno model and a Lyria song with a Lyria model. Naming a song of the other family returns 400 bad_request with source_task_id was made by suno-v6, which lyria-3.5 cannot work on; use a suno model for this follow-up.

Each follow-up is a new task with its own id, its own price and its own result.

The result

When the task succeeds, output carries the files in media, the primary file in url, and two audio-only fields:

{
"data": {
"id": "task_9Fh2Lq",
"status": "succeeded",
"task_kind": "audio",
"media_type": "audio",
"model": "suno-v6",
"output": {
"media": [
{ "type": "audio", "url": "https://media.beatapi.io/outputs/task_9Fh2Lq/0.mp3", "mime_type": "audio/mpeg" }
],
"url": "https://media.beatapi.io/outputs/task_9Fh2Lq/0.mp3",
"r2_url": "https://media.beatapi.io/outputs/task_9Fh2Lq/0.mp3",
"tracks": [
{
"id": "6b0f8f4e-2c1a-4f52-9a53-1d8d3f0c7a11",
"title": "Driving Home",
"tags": "warm acoustic folk, male vocal",
"lyrics": "[Verse]\nThe road is gold and the dashboard hums\n...",
"duration": 148.4,
"audio_url": "https://media.beatapi.io/outputs/task_9Fh2Lq/0.mp3",
"image_url": "<signed cover image URL>"
}
]
}
}
}

The ids and URLs above are illustrative; read the ids from your own task. tracks and data appear only on audio tasks.

FieldMeaning
output.tracks[]One entry per song or stem the call made. Suno’s song actions return one or two songs, Lyria’s one, for the one price.
tracks[].idThe id a follow-up sends as audio_id.
tracks[].title, tags, lyrics, durationThe song’s title, style tags, lyrics and length in seconds. Present when the action produces them.
tracks[].nameThe stem’s name, on Suno separate results.
tracks[].audio_url, image_urlThe song’s file and its cover art.
output.dataWhat an action returns that is not a file, such as the lyrics from lyrics. Absent on the others.
output.media[]The files of the result, each with its type and mime_type; songs, stems and WAV files are audio.

Completion callback

Any request may carry callback_url, the same optional field the image and video endpoints take. It is not part of the action tables on the model pages because every action accepts it. It is not available in the web playground.

callback_url
string

An address to notify when this task succeeds or fails: a public HTTPS URL on the same scheme, host and port as one of your enabled webhook endpoints, which signs the delivery with its secret.

Length: ≤ 2048 characters

  • Register the endpoint first with POST /v1/webhooks. BeatAPI sends task.succeeded or task.failed with the same body, headers and retries as an account webhook; an account endpoint subscribed to the event receives it too, and an address identical to that endpoint’s is notified once.
  • The callback stops when the signing endpoint is deleted, disabled or moved to another host.

If the value is wrong

  • The value is not a string: "callback_url" must be a string.
  • The address is longer than 2048 characters: "callback_url" must be at most 2048 characters.
  • It is not a URL, or has no host or no http or https scheme: "callback_url" must be a valid https URL.
  • It uses http, or points to a private or otherwise non-public address: "callback_url" must be a public HTTPS URL.
  • No enabled webhook endpoint has the same scheme, host and port: "callback_url" must be on the host of one of your active webhook endpoints, whose secret signs it; register one with POST /v1/webhooks.

Errors

A request the gateway refuses returns an error envelope and is not billed:

{
"error": {
"code": "bad_request",
"message": "style is read only in custom mode; send custom_mode true with it",
"retryable": false,
"request_id": "202611260307541272151438268d9d6mNDNwzi9"
}
}

Each model page lists the messages you will meet most often. Terminal task failures follow the error codes of every other task; a failed task is refunded.

Files and expiry

Songs, stems and WAV files are hosted on BeatAPI’s media storage and stay available for at least 72 hours after the task finishes. Download and keep what you need within that time; the link stops working afterwards. Your webhook endpoints receive the same output when a task finishes; callback_url adds a one-off address for a single task.

Prices

Every call costs one fixed price per action, the same for a 30-second and a four-minute song. Each model page has its price list; GET /v1/pricing shows one row per action.