Skip to main content

Generate Background Music

Purpose​

Generates one background music track, about 2 minutes 30 seconds long and led by melody and instruments, asynchronously from a text prompt. This is the same feature as the BGM (Background music) tab of the web app's "Generate Sounds" page. The length is fixed, so the prompt is the only input.

Credit cost: 2

Method and Path​

POST /public/v1/generate/sound/bgm

Authentication​

See the Authentication page. Bearer token is required.

Required Headers:

Authorization: Bearer {your_api_key}

Request Fields​

Send the request as multipart/form-data.

Field NameTypeRequiredDescription
promptstringYesDescribe the background music you want. Up to 500 characters. Leading and trailing whitespace is trimmed

Response​

Success Response (200 OK):

{
"audio_id": "uuid-string"
}
FieldTypeDescription
audio_idstringUnique identifier for the created sound. Use Get Audio Status to retrieve results

The audio_id is not a job_id. Get Job Status does not return sound results.

Error / Validation Rules​

ConditionHTTP StatusError Message
prompt is empty after trimming400"prompt must not be empty"
prompt is longer than 500 characters400"prompt must be at most 500 characters"
Invalid API key401"Invalid API key"
Not enough credits429"You do not have enough remaining tokens to use this feature."
Missing field422Validation error

Async Job Behavior​

This endpoint starts generation in the background. It immediately returns an audio_id, and the track is generated in the background. Background music usually takes a few minutes.

Polling Method:

  1. Save the audio_id received in the response
  2. Poll GET /public/v1/audio/{audio_id} every 5 to 10 seconds
  3. When status becomes Succeed, download the file in audio_urls (one track, MP3 or WAV)

Status Flow: Pending → Succeed or Failed

If generation fails, the credits are refunded.

Example Request​

cURL:

curl -X POST "https://api.aetherforgeai.com/public/v1/generate/sound/bgm" \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "prompt=peaceful fantasy RPG music for a forest village, led by harp and flute"