Suno Tasks API 的串接和使用

Suno Tasks API 可以透過任務 ID 查詢歌曲生成、音訊匯出等 Suno 請求的執行情況。

申請流程

到 orchats 控制台 取得有任務查詢權限的 API Key。範例使用環境變數 API_KEY。

請使用提交任務時的應用程式身分查詢。查詢不消耗 Credits。

如果你尚未登入或註冊,會自動跳轉到登入頁面邀請你註冊和登入,完成後會自動返回目前頁面。

通用應用程式的 API Key 可用於帳號已開放的服務;專用應用程式的 Key 按該應用程式的服務範圍使用。請檢查 Key 的權限、有效期和限額,並確認應用程式餘額足以支付本次請求。可用試用額度以帳號顯示為準,餘額不足時點擊「儲值」按鈕即可。

📘 完整文件:Suno Audios Generation API →

請求範例

以 Suno Audios Generation API 的非同步歌曲任務為例。提交後儲存返回的 task_id。

以下是一次實測歌曲任務,任務 ID 為 c409f30d-4b2f-4ad9-8ae7-f394e367713d。請在程式碼裡換成自己的任務 ID。

任務範例

用上面的任務 ID 提交 retrieve 查詢。完成時間出現在 finished_at。本次任務的 response.success 為 true,response.data 裡是 Room for One More Chair 和 Always Room for More 兩首候選歌曲。

設定請求標頭和請求本文

Request Headers 包括:

  • accept:指定接收 JSON 格式的回應結果,這裡填寫為 application/json。
  • authorization:呼叫 API 的金鑰,申請之後可以直接下拉選擇。

Request Body 包括:

  • id:上傳的任務 ID。
  • action:對任務的操作方式。

請求本文如下。

{
  "action": "retrieve",
  "id": "c409f30d-4b2f-4ad9-8ae7-f394e367713d"
}

程式碼範例

除錯頁面右側可以產生對應的呼叫程式碼,下面分別給出 cURL 與 Python 範例。

CURL

curl -sS -X POST 'https://api.orchats.repoingest.com/suno/tasks' \
  -H "Authorization: Bearer $API_KEY" \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -d '{
  "action": "retrieve",
  "id": "c409f30d-4b2f-4ad9-8ae7-f394e367713d"
}'

Python

import os

import requests

url = "https://api.orchats.repoingest.com/suno/tasks"
headers = {
    "accept": "application/json",
    "authorization": f"Bearer {os.environ['API_KEY']}",
    "content-type": "application/json",
}
payload = {
    "action": "retrieve",
    "id": "c409f30d-4b2f-4ad9-8ae7-f394e367713d",
}

response = requests.post(url, json=payload, headers=headers, timeout=180)
print(response.text)

回應範例

請求成功後,API 將返回此處歌曲任務的詳細資訊。例如:

{
  "id": "c409f30d-4b2f-4ad9-8ae7-f394e367713d",
  "type": "audios",
  "created_at": 1796115741.863,
  "started_at": 1796115741.863,
  "finished_at": 1796115800.404,
  "elapsed": 58.541,
  "request": {
    "action": "generate",
    "model": "chirp-v6",
    "prompt": "A song for Christmas"
  },
  "trace_id": "f9ff7920-2b74-4c69-867b-183cd41166fa",
  "response": {
    "success": true,
    "task_id": "c409f30d-4b2f-4ad9-8ae7-f394e367713d",
    "trace_id": "f9ff7920-2b74-4c69-867b-183cd41166fa",
    "data": [
      {
        "id": "15b56d7a-1ad1-4dc6-bc74-79b102caceeb",
        "title": "Room for One More Chair",
        "lyric": "[Verse 1]\nThe kettle sings, the window steams\nA paper chain hangs slightly crooked\nYou set the old tin on the shelf\nAnd laugh at how the years have kept it",
        "audio_url": "https://cdn.acedata2.cloud/suno/15b56d7a-1ad1-4dc6-bc74-79b102caceeb.mp3",
        "created_at": "2026-12-01T09:02:22.466Z",
        "model": "chirp-v6",
        "state": "succeeded",
        "prompt": "A song for Christmas",
        "style": "Cinematic Christmas pop with film-score scale, a steady four-on-the-floor pulse, driving syncopated percussion, and a repeating cello ostinato. Begin with intimate piano and close, warm lead vocals; build through layered strings, brass swells, and wordless choir accents into a wide, uplifting final chorus. Polished, spacious mix with clear vocal focus and dynamic section lifts.",
        "duration": 231.96
      },
      {
        "id": "555bf85a-907c-4573-b6f3-e816c04aabb9",
        "title": "Always Room for More",
        "lyric": "[Intro]\n[Wordless vocals]\nOh—ah, oh—ah\n[Verse 1]\nSnow gathers softly on the windowpane",
        "audio_url": "https://cdn.acedata2.cloud/suno/555bf85a-907c-4573-b6f3-e816c04aabb9.mp3",
        "created_at": "2026-12-01T09:02:22.466Z",
        "model": "chirp-v6",
        "state": "succeeded",
        "prompt": "A song for Christmas",
        "style": "Cinematic Christmas pop with marathon-film scale, syncopated rhythmic drive, cello ostinato, four-on-the-floor pulse, and wordless vocal drops. Begin with a restrained cello figure and distant wordless voices; build into a broad, uplifting chorus with layered strings, punchy percussion, and a clear lead vocal. Use a brief countdown-style dropout before the final chorus, then finish with a full, resolved orchestral-pop ending. Polished, spacious mix with strong low-end and crisp rhythmic detail.",
        "duration": 231.2
      }
    ],
    "cost": {
      "amount": 0.504,
      "currency": "credit",
      "list_amount": 0.56
    }
  }
}

返回結果一共有多個欄位,request 欄位就是發起任務時的 request body,同時 response 欄位是任務完成後返回的 response body。欄位介紹如下。

  • id,生成此歌曲任務的 ID,用於唯一識別此次歌曲生成任務。
  • request,查詢歌曲任務中的請求資訊。
  • response,任務完成時返回的結果。新生成歌曲的 response.data[].image_url 是原始封面 URL,提供高畫質封面時可從 image_large_url 讀取。歷史任務返回當時儲存的連結。
  • created_at,任務建立時間,Unix 時間戳記(秒,浮點數)。
  • started_at,任務開始執行時間,Unix 時間戳記(秒,浮點數)。
  • finished_at,任務完成時間,Unix 時間戳記(秒)。任務未完成時缺失或為空。
  • elapsed,任務執行耗時,單位為秒。任務完成後提供。 HTTP 200 表示查詢成功。先等 finished_at 有值,再讀取 response.success。任務成功後取得 response.data,失敗時檢查 response.error。

批次查詢操作

批次查詢多個任務時,將 action 設定為 retrieve_batch。

請求本文 包括:

  • ids:上傳的任務 ID 陣列。
  • action:對任務的操作方式。

請求本文如下。

{
  "action": "retrieve_batch",
  "ids": [
    "c409f30d-4b2f-4ad9-8ae7-f394e367713d",
    "1a01d321-6780-4d8e-8612-02a0fad33102"
  ]
}

程式碼範例

可使用 cURL 或 Python 提交相同的請求本文。

回應範例

請求成功後,API 將傳回此次所有批次歌曲任務的具體詳細資訊。例如:

{
  "items": [
    {
      "id": "c409f30d-4b2f-4ad9-8ae7-f394e367713d",
      "type": "audios",
      "created_at": 1796115741.863,
      "started_at": 1796115741.863,
      "finished_at": 1796115800.404,
      "elapsed": 58.541,
      "request": {
        "action": "generate",
        "model": "chirp-v6",
        "prompt": "A song for Christmas"
      },
      "trace_id": "f9ff7920-2b74-4c69-867b-183cd41166fa",
      "response": {
        "success": true,
        "task_id": "c409f30d-4b2f-4ad9-8ae7-f394e367713d",
        "trace_id": "f9ff7920-2b74-4c69-867b-183cd41166fa",
        "data": [
          {
            "id": "15b56d7a-1ad1-4dc6-bc74-79b102caceeb",
            "title": "Room for One More Chair",
            "lyric": "[Verse 1]\nThe kettle sings, the window steams\nA paper chain hangs slightly crooked\nYou set the old tin on the shelf\nAnd laugh at how the years have kept it",
            "audio_url": "https://cdn.acedata2.cloud/suno/15b56d7a-1ad1-4dc6-bc74-79b102caceeb.mp3",
            "created_at": "2026-12-01T09:02:22.466Z",
            "model": "chirp-v6",
            "state": "succeeded",
            "prompt": "A song for Christmas",
            "style": "Cinematic Christmas pop with film-score scale, a steady four-on-the-floor pulse, driving syncopated percussion, and a repeating cello ostinato. Begin with intimate piano and close, warm lead vocals; build through layered strings, brass swells, and wordless choir accents into a wide, uplifting final chorus. Polished, spacious mix with clear vocal focus and dynamic section lifts.",
            "duration": 231.96
          },
          {
            "id": "555bf85a-907c-4573-b6f3-e816c04aabb9",
            "title": "Always Room for More",
            "lyric": "[Intro]\n[Wordless vocals]\nOh—ah, oh—ah\n[Verse 1]\nSnow gathers softly on the windowpane",
            "audio_url": "https://cdn.acedata2.cloud/suno/555bf85a-907c-4573-b6f3-e816c04aabb9.mp3",
            "created_at": "2026-12-01T09:02:22.466Z",
            "model": "chirp-v6",
            "state": "succeeded",
            "prompt": "A song for Christmas",
            "style": "Cinematic Christmas pop with marathon-film scale, syncopated rhythmic drive, cello ostinato, four-on-the-floor pulse, and wordless vocal drops. Begin with a restrained cello figure and distant wordless voices; build into a broad, uplifting chorus with layered strings, punchy percussion, and a clear lead vocal. Use a brief countdown-style dropout before the final chorus, then finish with a full, resolved orchestral-pop ending. Polished, spacious mix with strong low-end and crisp rhythmic detail.",
            "duration": 231.2
          }
        ],
        "cost": {
          "amount": 0.504,
          "currency": "credit",
          "list_amount": 0.56
        }
      }
    },
    {
      "id": "1a01d321-6780-4d8e-8612-02a0fad33102",
      "type": "audios",
      "created_at": 1796115741.902,
      "started_at": 1796115741.902,
      "finished_at": 1796115778.27,
      "elapsed": 36.368,
      "request": {
        "action": "generate",
        "model": "chirp-v6",
        "title": "Window Lights",
        "style": "Soft acoustic folk, fingerpicked guitar and brushed drums",
        "lyric": "[Verse]\nWindow lights across the bay\nGuide the boats that drift away\n[Chorus]\nBring the morning home to me\nFold the stars into the sea",
        "custom": true,
        "duration": 90,
        "async": true
      },
      "trace_id": "ffddaa23-a3dd-44de-aa4e-58a6e3f1ca2c",
      "response": {
        "success": true,
        "task_id": "1a01d321-6780-4d8e-8612-02a0fad33102",
        "trace_id": "ffddaa23-a3dd-44de-aa4e-58a6e3f1ca2c",
        "data": [
          {
            "id": "8603c0f3-a396-455c-b945-fb48e65bf014",
            "title": "Window Lights",
            "lyric": "[Verse]\nWindow lights across the bay\nGuide the boats that drift away\n[Chorus]\nBring the morning home to me\nFold the stars into the sea",
            "audio_url": "https://cdn.acedata2.cloud/suno/8603c0f3-a396-455c-b945-fb48e65bf014.mp3",
            "created_at": "2026-12-01T09:02:22.389Z",
            "model": "chirp-v6",
            "state": "succeeded",
            "style": "Soft acoustic folk, fingerpicked guitar and brushed drums",
            "duration": 89.48
          },
          {
            "id": "50487a72-bc9c-4511-93d7-e2949dfb00c0",
            "title": "Window Lights",
            "lyric": "[Verse]\nWindow lights across the bay\nGuide the boats that drift away\n[Chorus]\nBring the morning home to me\nFold the stars into the sea",
            "audio_url": "https://cdn.acedata2.cloud/suno/50487a72-bc9c-4511-93d7-e2949dfb00c0.mp3",
            "created_at": "2026-12-01T09:02:22.389Z",
            "model": "chirp-v6",
            "state": "succeeded",
            "style": "Soft acoustic folk, fingerpicked guitar and brushed drums",
            "duration": 89.56
          }
        ],
        "cost": {
          "amount": 0.504,
          "currency": "credit",
          "list_amount": 0.56
        }
      }
    }
  ],
  "count": 2
}

傳回結果共有多個欄位,其中 items 包含批次歌曲任務的具體詳細資訊,每個歌曲任務的具體資訊與上文的欄位相同,欄位資訊如下。

  • items,批次歌曲任務的所有具體詳細資訊。它是一個陣列,陣列中每個元素的格式與上文查詢單一任務的傳回結果相同。
  • count,此處批次查詢歌曲任務的數量。

CURL

curl -sS -X POST 'https://api.orchats.repoingest.com/suno/tasks' \
  -H "Authorization: Bearer $API_KEY" \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -d '{
  "action": "retrieve_batch",
  "ids": [
    "c409f30d-4b2f-4ad9-8ae7-f394e367713d",
    "1a01d321-6780-4d8e-8612-02a0fad33102"
  ]
}'

Python

import os

import requests

url = "https://api.orchats.repoingest.com/suno/tasks"
headers = {
    "accept": "application/json",
    "authorization": f"Bearer {os.environ['API_KEY']}",
    "content-type": "application/json",
}
payload = {
    "action": "retrieve_batch",
    "ids": ["c409f30d-4b2f-4ad9-8ae7-f394e367713d", "1a01d321-6780-4d8e-8612-02a0fad33102"],
}

response = requests.post(url, json=payload, headers=headers, timeout=180)
print(response.text)

錯誤處理

在呼叫 API 時,如果遇到錯誤,API 會回傳相應的錯誤代碼和資訊。例如:

  • 400 token_mismatched:核對任務 ID 和應用程式歸屬。
  • 400 api_not_implemented:檢查查詢操作和參數。
  • 401 invalid_token:檢查 API Key 是否有效。
  • 429 too_many_requests:依照 Retry-After(如有)或退避策略放慢輪詢。
  • 500 api_error:保留 trace_id,並在網路恢復後查詢同一個任務。

錯誤回應範例

{
  "success": false,
  "error": {
    "code": "api_error",
    "message": "fetch failed"
  },
  "trace_id": "2cf86e86-22a4-46e1-ac2f-032c0f2a4e89"
}

任務本身失敗

查詢仍可回傳 HTTP 200。下面是一次重製任務失敗後的查詢結果。

{
  "id": "add2ba31-609e-48ca-9933-5711a88067fe",
  "finished_at": 1796063763.654,
  "response": {
    "success": false,
    "task_id": "add2ba31-609e-48ca-9933-5711a88067fe",
    "trace_id": "47579d6e-185f-462e-83d2-6c827675e58d",
    "error": {
      "code": "timeout",
      "message": "timeout while waiting for audio generation"
    }
  }
}

任務失敗詳情位於 response.error。重試前檢查可選的 retryable 欄位。 歌曲生成的重試規則 透過本文檔,您已經了解了如何使用 Suno Tasks API 查詢單個或批次歌曲任務的所有具體詳細資訊。希望本文檔能幫助您更好地串接和使用該 API。如有任何問題,請隨時聯絡我們的技術支援團隊。