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 Name | Type | Required | Description |
|---|---|---|---|
| prompt | string | Yes | Describe the background music you want. Up to 500 characters. Leading and trailing whitespace is trimmed |
Response
Success Response (200 OK):
{
"audio_id": "uuid-string"
}
| Field | Type | Description |
|---|---|---|
| audio_id | string | Unique 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
| Condition | HTTP Status | Error Message |
|---|---|---|
| prompt is empty after trimming | 400 | "prompt must not be empty" |
| prompt is longer than 500 characters | 400 | "prompt must be at most 500 characters" |
| Invalid API key | 401 | "Invalid API key" |
| Not enough credits | 429 | "You do not have enough remaining tokens to use this feature." |
| Missing field | 422 | Validation 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:
- Save the
audio_idreceived in the response - Poll
GET /public/v1/audio/{audio_id}every 5 to 10 seconds - When status becomes
Succeed, download the file inaudio_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"