ACE Music Song Generation API Integration Guide
ACE Music can generate songs from a creative prompt or custom lyrics. It also supports importing reference audio, covering existing works, and blending two references. Starting with obtaining an API Token, this guide covers the complete process of submitting a request, querying a task, previewing, and downloading.
Generation, covers, and blending each deliver a set of two candidates, while each reference upload imports one audio track. You can first use inspiration mode for your initial call, then choose other creation methods as needed.
¶ Prepare Song Generation Credentials
Log in to the application list, open General Application, and click the copy button next to API KEY (marked 1 in the image). Save the Key on the server for use as YOUR_API_TOKEN in the examples below.

The examples first submit a song, then query the generation result. If you use a restricted key, grant it access to the song generation and task query endpoints, and confirm that the application has sufficient generation quota.
ACE Music Song Generation API Parameters and Online Testing
¶ Basic Usage
The first call only requires a song description in prompt. The example below uses “a warm folk song about taking the last bus home” to generate two candidates with the default model, acemusic-v1.1.
¶ Set the Request Headers and Body
The request URL is POST https://api.acedata.cloud/acemusic/audios. Set the request headers as follows:
| Request Header | Value | Description |
|---|---|---|
Authorization |
Bearer YOUR_API_TOKEN |
Use the Token obtained in the previous step, keeping the space after Bearer |
Content-Type |
application/json |
Use JSON for the request body |
Accept |
application/json |
Receive JSON results |
This request uses the following parameters:
| Parameter | Value in This Request | Description |
|---|---|---|
action |
generate |
Generate a new song; this action is also used when omitted |
model |
acemusic-v1.1 |
Default model; acemusic-v1 is also available |
custom |
false |
Inspiration mode, in which the model creates from the description |
prompt |
Song description | Can describe the language, theme, style, instruments, and mood |
async |
true |
Obtain a task ID after submission, then query the result |
¶ cURL Example
curl --request POST 'https://api.acedata.cloud/acemusic/audios' \
--header 'Authorization: Bearer YOUR_API_TOKEN' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data '{
"action": "generate",
"model": "acemusic-v1.1",
"custom": false,
"prompt": "一首关于坐末班车回家的中文民谣,木吉他伴奏,温暖而充满希望",
"async": true
}'
¶ Python Example
First install requests (pip install requests) and save the Token as the environment variable ACEDATACLOUD_API_TOKEN, then run the following code:
import os
import requests
response = requests.post(
"https://api.acedata.cloud/acemusic/audios",
headers={"Authorization": f"Bearer {os.environ['ACEDATACLOUD_API_TOKEN']}"},
json={
"action": "generate",
"model": "acemusic-v1.1",
"custom": False,
"prompt": "一首关于坐末班车回家的中文民谣,木吉他伴奏,温暖而充满希望",
"async": True,
},
timeout=30,
)
response.raise_for_status()
submitted = response.json()
print("请保存任务 ID:", submitted["task_id"])
The cURL and Python examples demonstrate two ways to perform the same operation; choose either one. Each new submission creates a song task, so do not repeatedly run the submission code while waiting for the result.
¶ Submission Response
An accepted asynchronous request returns HTTP 202. Below is the response from an actual request:
{
"task_id": "ae17781e-b4cd-4ad9-869a-34b8cf96b057",
"trace_id": "3102971e-7f6a-473c-8255-ba1e8eace89e",
"status": "created"
}
task_id: The unique ID for this task, which is needed for subsequent queries.trace_id: The trace ID to provide to support staff when troubleshooting.status: The current task status; it is usuallycreatedwhen accepted.
The song is still being processed at this point, and the response contains no playable audio. Save the task_id returned by your own request and proceed to the next step.
¶ Query Results and Download Songs
Use the same Token to call POST /acemusic/tasks, replacing id with the task_id you just saved:
curl --request POST 'https://api.acedata.cloud/acemusic/tasks' \
--header 'Authorization: Bearer YOUR_API_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"action": "retrieve",
"id": "YOUR_TASK_ID"
}'
The query endpoint returns the task record directly. Song results are in response.data, with each element representing one audio track. Below is an excerpt from an actual response for a completed task, retaining only the task status and audio delivery fields:
{
"id": "ae17781e-b4cd-4ad9-869a-34b8cf96b057",
"type": "audios",
"state": "succeeded",
"response": {
"success": true,
"status": "succeeded",
"data": [
{
"id": "3966103b-b0e3-4799-aa6d-b90dfc3e30ee",
"model": "acemusic-v1.1",
"title": "末班车的温热",
"state": "succeeded",
"duration": 182,
"audio_url": "https://cdn.acedata2.cloud/acemusic/ae17781e-b4cd-4ad9-869a-34b8cf96b057-3966103b-b0e3-4799-aa6d-b90dfc3e30ee.mp3"
},
{
"id": "51b08e57-a990-4aaf-9418-fe3750a833f1",
"model": "acemusic-v1.1",
"title": "末班车的温热",
"state": "succeeded",
"duration": 174,
"audio_url": "https://cdn.acedata2.cloud/acemusic/ae17781e-b4cd-4ad9-869a-34b8cf96b057-51b08e57-a990-4aaf-9418-fe3750a833f1.mp3"
}
]
}
}
| Field | Description |
|---|---|
id / state |
Task ID and task status of the queried record |
response.success / response.status |
Whether the creation was fully successful, and the final status |
response.data |
Track list; contains two tracks when generation, cover, or mashup is fully successful, and one track when upload is successful |
response.data[].id |
Platform track ID, which can be used for subsequent covers or mashups |
response.data[].audio_url |
Playback and download URL for the delivered audio |
response.data[].image_url |
Optional cover image URL; its absence does not affect audio playback |
response.data[].title / lyric / style |
Title, lyrics, and musical style |
response.data[].model / state |
Model used for this track and its delivery status; an uploaded reference may not include model |
response.data[].duration |
Actual audio duration, in seconds |
When the task is succeeded, you can use audio_url to preview or download the audio. When the task is partial_failed, completed tracks can still be retained and played, and no generation fee is charged for the group. When the task is failed, read response.error to investigate the cause. For other statuses, continue querying; an interval of several seconds with gradual backoff is recommended.
After a browser refresh or network interruption, continue querying the original task. A cover image not yet being returned does not mean the audio is unavailable; if a track does not yet have an audio_url, delivery is still incomplete. For batch queries, history, and polling code, see the Task Query Guide.
¶ Generate a Song with Custom Lyrics
If you already have lyrics, change custom to true and provide title, lyric, and style. The request URL and Token are the same as in the basic example; simply replace the request body with the following:
{
"action": "generate",
"model": "acemusic-v1.1",
"custom": true,
"title": "回家的路",
"lyric": "[Verse]\n晚风吹过熟悉的街道\n[Chorus]\n灯火等我回到家",
"style": "中文民谣,木吉他,温暖人声",
"async": true
}
Lyrics can include section tags such as [Verse] and [Chorus]. In custom mode, do not also pass the inspiration-mode prompt. If you do not yet have lyrics, you can first generate a draft using the Lyrics Generation Guide, then edit it and put the text from the lyrics result into the song request’s lyric.
¶ Use MIDI, Image, or Video References
First import materials of enabled types through the Reference Materials API. Pass the data.id and data.type of the same material as a pair of asset_id and asset_type to inspiration generation. The default model is acemusic-v1.1. In the first release, each request uses one imported material, and the output remains two candidate songs. Materials can be selected as midi, image, or video; the types actually available depend on what is enabled for your account.
{
"action": "generate",
"prompt": "根据画面中的光线与风景写一首歌。",
"asset_id": "YOUR_ASSET_ID",
"asset_type": "image",
"async": true
}
¶ Upload Reference Audio
Use the same song API, set action to upload, and enter the HTTPS URL of the MP3 in audio_url. name is an optional display name. Publicly downloadable HTTPS MP3 links can be submitted directly. Keep the link accessible until the task delivers the preview and download URLs. External link delivery supports MP3 files up to 32 MiB and a maximum of 5 public HTTPS redirects; the file format is determined by the actual audio content.
If the file is local, the external link requires login, or the file exceeds the external import limit, you can use your platform account token to submit the file to POST https://platform.acedata.cloud/api/v1/files/. Use the form field file to upload the MP3 file. The file size limit for importing reference audio this way is 64 MiB. Replace the example URL below with the complete file_url from the response.
{
"action": "upload",
"audio_url": "https://cdn.acedata.cloud/uploads/00000000-0000-4000-8000-000000000000.mp3",
"name": "我的参考旋律",
"async": true
}
This operation does not require model, custom, or lyrics fields, and it does not automatically generate a new song. After submission, likewise save the task_id and query the task. The successful result’s response.data contains one track; save its id as the reference track ID for subsequent operations.
If you want to use the new reference together with an existing work, you can pass that work’s platform audio_id when uploading. A separate upload fee is charged after the reference is successfully imported. If the original task returns submission_unknown, retain the task_id and trace_id and give them to support staff for verification before deciding whether to resubmit.
¶ Cover an Existing Song
Set action to cover, use the audio_id of a platform track you can access, and enter the new lyrics and musical style:
{
"action": "cover",
"model": "acemusic-v1.1",
"audio_id": "YOUR_TRACK_ID",
"title": "回家的路·民谣版",
"lyric": "[Verse]\n晚风吹过熟悉的街道",
"style": "温暖民谣,木吉他",
"audio_influence": 60,
"async": true
}
The audio_id comes from response.data[].id in a previous successful task and is different from the generation task’s task_id. Covers use acemusic-v1.1; the title is optional, while lyrics and style are required. audio_influence controls the degree of audio reference, with a range of 1–100 and a default of 60. Existing platform tracks can be reused directly without paying to upload them again.
¶ Mash Up Two Reference Songs
Set action to mashup and enter exactly two different platform track IDs in mashup_audio_ids:
{
"action": "mashup",
"model": "acemusic-v1.1",
"mashup_audio_ids": ["YOUR_FIRST_TRACK_ID", "YOUR_SECOND_TRACK_ID"],
"lyric": "[Verse]\n把两段旅程写成一首歌",
"style": "中文流行,融合两首参考的旋律与节奏",
"audio_influence": 60,
"async": true
}
The two reference tracks can come from completed uploads or song tasks and must be works you can access that are compatible with each other; incompatible combinations will be rejected. Mashups also use acemusic-v1.1; lyrics and style are required, and the title is optional.
Covers and mashups do not use custom or the inspiration prompt. The current song API does not provide style intensity, instrumental, continuation, stem separation, or voice parameters; do not directly apply fields from other music services.
¶ Parameter Quick Reference
| Parameter | Type | When to provide | Description |
|---|---|---|---|
action |
string | Optional | generate (default), upload, cover, or mashup |
model |
string | Generate, cover, mashup | Defaults to acemusic-v1.1; generation also supports acemusic-v1; omit for uploads |
custom |
boolean | Generation only | Defaults to false for inspiration mode; true for custom lyrics mode |
prompt |
string | Required for inspiration generation | Creative description of the song |
title / lyric / style |
string | Required for custom generation | Title, lyrics, and style; covers and mashups require only lyrics and style, with the title optional |
audio_url / name |
string | Upload | Publicly downloadable HTTPS MP3 URL, or an MP3 URL returned by the platform file upload. Display name is optional |
audio_id |
string | Required for covers; optional for uploads | Platform track ID; can be used to associate an existing reference when uploading |
mashup_audio_ids |
string[] | Required for mashups | Exactly two distinct and compatible platform track IDs |
audio_influence |
number | Optional for covers and mashups | Reference influence from 1–100, defaulting to 60 |
async |
boolean | Optional | Defaults to true; setting it to false waits for the result, but returns 202 and the original task ID if the wait time is exceeded |
callback_url |
string | Optional | HTTPS completion callback URL; providing it enables asynchronous execution |
Each operation accepts only its corresponding fields; construct requests according to the separate examples above.
¶ Completion Callbacks and Duplicate Requests
¶ Using a Completion Callback
If you do not want to poll continuously, you can add your own HTTPS callback_url to the song request. Upon completion, the platform will push the final result to that address. The recipient should deduplicate by task_id and return a success status; callbacks may be redelivered.
A failure to receive the callback will not trigger regeneration, reimport, or additional charges. You can still use the task API to obtain the original task result.
¶ Using an Idempotency Key
When submitting a request, you can add an Idempotency-Key request header to specify a unique key for the same creation. The same key and the same content will return the original task; the same key with different content will result in a conflict. Use a new key for each intentionally initiated new creation, and retain the original key and content when retrying the same submission.
Please save the key before sending and save the task_id after acceptance. If a network timeout occurs and the acceptance status is unclear, do not automatically resend with a different key; query the original task first and, if necessary, retain the idempotency key and contact support.
¶ Pricing
| Operation | Billing unit | When charged |
|---|---|---|
| Generation, cover, mashup | A complete set of two candidates | Charged once upon complete success; no generation fee for final failure or partial failure |
| Reference upload | One successfully imported reference | Charged once upon successful import; no charge for failure |
| Lyrics generation | One successful lyrics task | Charged separately; song operations do not implicitly incur an additional lyrics assistant fee |
| Task query | Free | Requires a valid Token and the corresponding API permissions |
For specific unit prices and balances, see ACE Music Service and the Console. The console measures usage in Credits; actual amounts are converted according to the plan, discounts, site pricing, and exchange rates used.
¶ Frequently Asked Questions
¶ What should I do if I still receive an authentication or permission error after obtaining a Token?
Check whether the Token was copied in full, whether there is a space after Bearer, and whether the key has been disabled or restricted from accessing the ACE Music API. Do not use an application ID or task ID as a Token.
¶ Why is there no audio URL when the request returns 202?
202 means the task has been accepted. Use the returned task_id to query it, and obtain the audio from response.data[].audio_url after completion. Do not repeatedly submit generation requests while waiting for the song.
¶ Does a successful query mean both songs are complete?
A successful HTTP query means the task was read successfully; you still need to check the task's state and each track's state. The task is succeeded when both candidates are fully delivered; it is partial_failed when only partial delivery is ultimately achieved.
¶ How do I troubleshoot a failed call?
| HTTP status code | Recommended action |
|---|---|
400 |
Check required fields, parameters corresponding to the operation, reference tracks, and compatibility |
401 / 403 |
Check the Token, credential status, and API access permissions |
402 |
Check the balance and credential quota limits |
404 |
Check whether the reference track exists and whether the current account can access it |
409 |
The request content differs for the same idempotency key; check the original request |
429 |
Reduce the call frequency and retry according to a backoff strategy |
500 / 503 |
Retain any existing task ID and query the task before deciding on the next step |
Asynchronous execution failures are recorded in the task's final state and response.error. When contacting support, provide the task_id and trace_id; do not provide the full API Token.
