> ## Documentation Index
> Fetch the complete documentation index at: https://docs.toapis.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 取得音樂任務狀態

> 查詢 Suno 音樂任務的狀態和結果

* 查詢異步音樂任務的執行狀態和結果
* 即時狀態更新和進度追蹤
* 任務完成時取得音訊、封面、影片等媒體 URL(已鏡像本站 CDN)
* 任務失敗自動退還費用

所有音樂任務都是異步執行的。提交任務後,請透過本接口輪詢任務狀態和結果。

## Authorizations

<ParamField header="Authorization" type="string" required>
  使用 Bearer Token 認證,取得 API Key:[API Key 管理頁面](https://toapis.com/console/token)
</ParamField>

## Path Parameters

<ParamField path="task_id" type="string" required>
  音樂生成接口返回的任務 ID(`tsk_aud_` 前綴)
</ParamField>

## Response

<ResponseField name="id" type="string">任務 ID</ResponseField>

<ResponseField name="status" type="string">
  任務狀態:`submitted` / `queued` / `in_progress` / `completed` / `failed`
</ResponseField>

<ResponseField name="progress" type="integer">任務進度百分比(0-100)</ResponseField>

<ResponseField name="cost" type="number">實際上游成本(美元)</ResponseField>

<ResponseField name="created" type="integer">建立時間戳(Unix)</ResponseField>

<ResponseField name="completed" type="integer">完成時間戳(Unix)</ResponseField>

<ResponseField name="result" type="object">
  任務結果,結構隨操作不同:

  <Expandable title="result 結構">
    <ResponseField name="music" type="array">
      曲目列表,每項含 `audio_url`、`image_url`、`title`、`tags`、`lyrics`、`duration` 等
    </ResponseField>

    <ResponseField name="instruments" type="array">
      `midi` 操作返回的分軌音符資料(`name`/`program`/`is_drum`/`notes[]`)
    </ResponseField>

    <ResponseField name="files" type="array">
      `download` 操作返回的多格式檔案 URL 列表
    </ResponseField>

    <ResponseField name="videoUrl" type="string">
      `generateMp4` 返回的影片位址
    </ResponseField>

    <ResponseField name="avg_bpm" type="number">
      `bpm` 返回的平均 BPM(另有 `max_bpm`/`min_bpm`)
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="error" type="object">失敗時的錯誤資訊(`code`/`message`)</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl --request GET \
    --url https://toapis.com/v1/music/tasks/tsk_aud_01M3EXAMPLE \
    --header 'Authorization: Bearer <token>'
  ```

  ```python Python theme={null}
  import time
  import requests

  task_id = "tsk_aud_01M3EXAMPLE"
  while True:
      resp = requests.get(
          f"https://toapis.com/v1/music/tasks/{task_id}",
          headers={"Authorization": "Bearer <token>"}
      ).json()["data"]
      if resp["status"] in ("completed", "failed"):
          break
      time.sleep(5)
  print(resp["result"])
  ```
</RequestExample>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.