ACE Music Lyrics Generation API Integration Guide

The ACE Music Lyrics Generation API can generate titles and lyrics based on themes and music styles. You can edit the lyrics first, then create songs through the custom mode of the Song Generation API. This article introduces the complete process of obtaining an API Token, submitting lyric requests, reading results, and using lyrics for song creation.

Application Process

  1. Open the jiasmart Console. If you are not logged in yet, please register or log in first.
  2. In the API Key section of General Applications, select and copy the key; if you do not have a key yet, click Create API Key. The API Token and API Key mentioned in this article refer to the same type of calling credential.
  3. You can also manage keys in Credential Management. When using an ACE Music dedicated application or a key with API restrictions, please confirm that access to the Lyrics API is allowed; subsequent queries and song generation also require the corresponding task and song API permissions.
  4. Before paid creation, please confirm the application balance and key usage limit. If the balance is insufficient, you can go to the Top-up Page.

Replace YOUR_API_TOKEN in the examples with the copied Token, and send it through the Authorization: Bearer YOUR_API_TOKEN request header. Please store the Token on the server side, and do not place it in public webpages or code repositories.

Complete API parameters and online debugging: ACE Music Lyrics API.

Basic Usage

The request URL is POST https://api.acedata.cloud/acemusic/lyrics. For example, if you want to write an original Chinese folk song about taking a train home at night, you can put the theme in prompt and the musical atmosphere in style.

curl --request POST 'https://api.acedata.cloud/acemusic/lyrics' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer YOUR_API_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "prompt": "写一段关于夜晚坐火车回家的原创中文民谣歌词,包含一段主歌和一段副歌。",
    "style": "温暖、木吉他、希望"
  }'

Request Parameters

Parameter Type Required Description
prompt string Yes Lyric theme, language, story, or section requirements, up to 20,000 characters.
style string No Desired style and atmosphere, up to 20,000 characters.

This API synchronously waits for lyric results and does not accept the async or callback_url parameters. If the wait exceeds the processing budget, it returns HTTP 202 and task_id; in this case, save the ID and use the Task API to query the original task.

Response Example

The following is an actual successful response. Generated content will vary by request.

{
  "success": true,
  "task_id": "893deb8e-d6b5-4872-8d3a-07bdcae189e5",
  "trace_id": "a06d171c-ad78-4aeb-aa8e-1cd0834fe19b",
  "status": "succeeded",
  "data": [
    {
      "title": "归途夜车",
      "text": "[verse]\n车窗倒映着疲惫的脸庞\n铁轨在夜色里轻轻摇晃\n路过的站台落满了微霜\n背包里装着一年的行囊\n\n[chorus]\n呜——列车穿过了漫长黑夜\n每一步都在把距离缩短\n车轮声数着心底的期盼\n天亮时就能看见家门前的炊烟"
    }
  ]
}
Field Description
success Whether this lyric generation was successful.
task_id Platform task ID, used for subsequent queries and troubleshooting.
trace_id Request tracking ID; provide it as well when contacting support.
status Task status; succeeded indicates generation is complete. An HTTP 202 acceptance result still needs to be queried further.
data List of lyric results.
data[*].title Generated song title, editable.
data[*].text Lyric body, including line breaks and section tags, editable; this field is not an audio URL.

Using Lyrics for Song Creation

  1. Extract data[0].title and data[0].text from the successful response, and edit them as needed.
  2. Call the Song Generation API, set action=generate and custom=true, fill the title into title, fill the lyric body into lyric, and provide style.
  3. Save the new task_id returned by the song request, and obtain the song result through the Task Query Guide.

Note that the field names of the two APIs are different: the Lyrics API returns text, while the Song API accepts lyric. Lyric tasks and song tasks also each have their own task_id.

The following is an example request body for the Song API; please replace the placeholder content with your confirmed title, complete lyrics, and style, then send the request according to the Song Guide.

{
  "action": "generate",
  "model": "acemusic-v1.1",
  "custom": true,
  "title": "YOUR_SONG_TITLE",
  "lyric": "YOUR_LYRICS_TEXT",
  "style": "温暖的中文民谣,木吉他伴奏",
  "async": true
}

Lyric generation and song generation are two independent paid operations. Calling only the Lyrics API will not generate audio; directly calling the Song API will also not implicitly incur additional lyric assistant charges.

Querying and Exception Handling

If HTTP 202 is returned, fill the task_id in the response into the id of the following request:

curl --request POST 'https://api.acedata.cloud/acemusic/tasks' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer YOUR_API_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "action": "retrieve",
    "id": "YOUR_LYRICS_TASK_ID"
  }'

The task query returns a task record. The completed lyrics are located in response.data, which differs from the data hierarchy when directly calling the Lyrics API successfully. It is recommended to query every few seconds and gradually increase the interval, then stop after reaching a terminal state.

HTTP Status Code Handling Recommendation
400 Check prompt, style, and parameter types; do not pass parameters specific to the song API.
401 / 403 Check whether the Token is valid, and whether the application and key have the corresponding API permissions.
402 Check the balance and key usage limits.
404 When querying, check the task ID and the account currently being used for the call.
429 Reduce the call frequency and retry the query after a delay.
500 / 503 Retain the existing task_id and trace_id; first query the original task or contact support.

After a network interruption or waiting timeout, do not automatically resend the lyric generation request. If a task ID has already been obtained, continue querying the original task; if no task ID has been obtained and the acceptance status is unclear, retain the request information and contact support to avoid duplicate generation and billing.

Fee Description

Each successful lyric generation is charged 0.0157408497024 Credits; final failures are not charged; querying your own tasks is free. The actual monetary amount is affected by the plan used, discounts, site pricing, and exchange rates. Please refer to the console display.