Producer Audios 生成 API 集成指南

6 阅读5分钟

在这篇文章中,我们将介绍如何集成 Producer Audios 生成 API。该 API 允许用户通过输入自定义参数,生成官方音乐作品。这为开发者和音乐创作者提供了一个强大的工具,能够快速生成独特的音乐内容。

背景

Ace Data Cloud 是一个提供数据解决方案的平台,旨在通过 API 提供各种数据服务。Producer Audios 生成 API 是其核心功能之一,适用于需要快速生成音乐的场景,例如为视频、游戏或广告生成背景音乐,或者为创作者提供灵感。

申请使用 API

要使用此 API,您需要先在 Producer Audios Generation API 页面申请相应的服务。进入页面后,点击“Acquire”按钮,如下图所示:

申请按钮

如果您尚未登录或注册,会自动重定向到登录页面。登录或注册后,您将自动返回当前页面。首次申请用户将获得免费配额,可免费使用该 API。

基本使用方法

用户可以通过输入任意文本生成歌曲。例如,如果我想生成一首关于圣诞节的歌曲,我可以输入 a song for Christmas,如下图所示:

在请求头中,我们需要设置以下内容:

  • accept: 希望接收的响应格式,填写为 application/json,表示以 JSON 格式接收。
  • authorization: 调用 API 的密钥,可以在申请后直接选择。

此外,在请求体中,您可以设置以下参数:

  • action: 此音乐生成任务的操作,生成歌曲时填写为 generate
  • model: 用于创建歌曲的模型,目前主要包括 FUZZ-2.0 ProFUZZ-2.0 等。
  • lyric: 歌词内容。
  • custom: 是否以自定义方式生成歌曲。
  • prompt: 灵感模式下的提示词。
  • title: 歌曲的标题信息。
  • audio_id: 用于续写/修订操作的参考歌曲 ID。
  • continue_at: 从指定的秒数继续写作。
  • replace_section_start/replace_section_end: 替换部分的开始和结束时间(以秒为单位)。
  • lyrics_strength: 歌词强度,介于 0-1 之间,默认值为 0.7。
  • sound_strength: 声音提示的强度,介于 0.2-1 之间,默认值为 0.7。
  • cover_strength: 介于 0.2-1 之间的覆盖强度,默认值为 1。
  • weirdness: 风格独特性,介于 0-1 之间,默认值为 0.5。
  • callback_url: 用于接收回调结果的 URL。
  • instrumental: 是否为无歌词模式。

设置完成后,您可以看到右侧生成的代码,如下图所示:

点击“Try”按钮进行测试,结果如下:

{
  "success": true,
  "task_id": "82fd443a-903a-4f18-8028-12d2f8a0a4be",
  "trace_id": "d85839fa-0bb1-42da-a9fc-cd582c29027d",
  "data": [
    {
      "id": "6c947f13-a3c5-4b9c-8609-5639c37cdc2d",
      "title": "Untitled",
      "image_url": "https://storage.googleapis.com/corpusant-app-public/riffs/a853673e-615c-42ae-bdff-16b1add94861/image/6c947f13-a3c5-4b9c-8609-5639c37cdc2d.jpg",
      "lyric": "[Instrumental]",
      "audio_url": "https://storage.googleapis.com/corpusant-app-public/riffs/a853673e-615c-42ae-bdff-16b1add94861/audio/6c947f13-a3c5-4b9c-8609-5639c37cdc2d.m4a",
      "video_url": null,
      "image_id": "6c947f13-a3c5-4b9c-8609-5639c37cdc2d",
      "topic": null,
      "seed": "2450882164",
      "sound": "A song for Christmas",
      "created_at": "2025-12-30T17:18:23.232911Z",
      "model": "FUZZ-2.0 Pro",
      "progress": "100%",
      "state": "succeeded",
      "duration": "181.3014058956916"
    }
  ]
}

返回结果包含多个字段,描述如下:

  • success: 当前音乐生成任务的状态。
  • data: 此音乐任务的结果
    • id: 当前音乐生成任务的 ID。
    • sound: 当前音乐生成任务的提示词。
    • seed: 当前音乐生成任务的种子值。
    • audio_url: 当前音乐生成任务的音频链接。
    • image_url: 当前音乐生成任务的封面链接。
    • image_id: 当前音乐生成任务的封面 ID。
    • state: 当前音乐生成任务的状态。
    • duration: 当前音乐的时长信息。
    • progress: 当前音乐任务的进度值。
    • model: 当前音乐生成任务使用的模型信息。
    • lyric: 当前音乐生成任务的歌词信息。

我们可以看到,我们已获得所需的音乐信息,只需从 data 结果中获取生成的音乐链接即可。

自定义生成

如果您想自定义歌词,可以输入歌词文本:

此时,lyric 字段可以接受类似以下内容:

[Verse]Woke up with the sun in my eyesNo clouds above just blue in the skiesShoes on my feet I’m ready to runEvery step feels like a loaded gun[Chorus]Happy days are rolling inLet the joy beneath my skinNo more shadows no more liesJust the truth that lifts me high

接下来,我们需要根据歌词、标题和风格自定义歌曲生成,指定以下内容:

  • lyric: 歌词文本
  • custom: 设置为 true,表示自定义生成;此参数默认值为 false,表示使用 prompt 生成。
  • title: 歌曲标题。

填写示例如下:

完成填写后,生成的代码如下:

对应的代码:

curl -X POST 'https://api.acedata.cloud/producer/audios' \
-H 'accept: application/json' \
-H 'authorization: Bearer {token}' \
-H 'content-type: application/json' \
-d '{
  "action": "generate",
  "model": "FUZZ-2.0 Pro",
  "instrumental": false,
  "lyric": "[Verse]\nWoke up with the sun in my eyes\nNo clouds above just blue in the skies\nShoes on my feet I’m ready to run\nEvery step feels like a loaded gun\n[Chorus]\nHappy days are rolling in\nLet the joy beneath my skin\nNo more shadows no more lies\nJust the truth that lifts me high\n[Verse 2]\nDancing through the city streets\nA rhythm pounding in my heartbeat\nStrangers smile it’s catching on\nThis world’s a stage we’re all a song\n[Chorus]\nHappy days are rolling in\nLet the joy beneath my skin\nNo more shadows no more lies\nJust the truth that lifts me high\n[Bridge]\nThrow your worries out the door\nLet them sink to the ocean floor\nWe’re alive and it’s enough\nLife is messy but it’s love\n[Chorus]\nHappy days are rolling in\nLet the joy beneath my skin\nNo more shadows no more lies\nJust the truth that lifts me high",
  "custom": true
}'

测试后生成效果类似。

{
  "success": true,
  "task_id": "9f58bbd4-855a-4233-ac45-b63bf9168e02",
  "trace_id": "145ad117-6ce7-42dd-af12-70751c5284fc",
  "data": [
    {
      "id": "38d3b9e2-0dfb-4338-b2a