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

# 작업 조회

> Flow Music 비동기 작업의 실행 상태, 진행률 및 생성 결과를 조회합니다

<RequestExample>
  ```bash cURL theme={null}
  curl --request GET \
    --url https://api.apimart.ai/v1/music/tasks/task_01K8AYYM6R03TGZ3Q2P0TZVNPX?language=ko \
    --header 'Authorization: Bearer <token>'
  ```

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

  task_id = "task_01K8AYYM6R03TGZ3Q2P0TZVNPX"
  url = f"https://api.apimart.ai/v1/music/tasks/{task_id}"

  headers = {
      "Authorization": "Bearer <token>"
  }

  params = {
      "language": "ko"
  }

  response = requests.get(url, headers=headers, params=params)

  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const taskId = "task_01K8AYYM6R03TGZ3Q2P0TZVNPX";
  const url = `https://api.apimart.ai/v1/music/tasks/${taskId}?language=ko`;

  const headers = {
    "Authorization": "Bearer <token>"
  };

  fetch(url, {
    method: "GET",
    headers: headers
  })
    .then(response => response.json())
    .then(data => console.log(data))
    .catch(error => console.error("Error:", error));
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "code": 200,
    "data": {
      "id": "task_01K8AYYM6R03TGZ3Q2P0TZVNPX",
      "status": "completed",
      "progress": 100,
      "created": 1783413241,
      "completed": 1783413352,
      "actual_time": 111,
      "cost": 0.06,
      "credits_cost": 0.6,
      "result": {
        "music": [
          {
            "clip_id": "a41aade4-993e-4d28-b56f-d97e7ef7167c",
            "title": "My Song",
            "duration_seconds": "181.70666667",
            "audio_url": "https://cdn.apimart.ai/audio/flowmusic_a41aade4.m4a",
            "wav_url": "https://cdn.apimart.ai/audio/flowmusic_a41aade4.wav"
          }
        ]
      }
    }
  }
  ```

  ```json 404 theme={null}
  {
    "error": {
      "message": "task not found",
      "type": "invalid_request",
      "param": "task_id",
      "code": "task_not_found"
    }
  }
  ```

  ```json 429 theme={null}
  {
    "error": {
      "message": "현재 그룹 용량이 포화 상태입니다. 잠시 후 다시 시도해 주세요",
      "type": "rate_limit_error",
      "param": "",
      "code": "rate_limit_error"
    }
  }
  ```
</ResponseExample>

## 인증

<ParamField header="Authorization" type="string" required>
  모든 Flow Music 엔드포인트는 Bearer Token 인증이 필요합니다

  API Key 발급 방법:

  [API Key 관리 페이지](https://apimart.ai/keys)에 접속하여 API Key를 발급받으세요

  요청 헤더에 추가:

  ```
  Authorization: Bearer YOUR_API_KEY
  ```
</ParamField>

## 경로 파라미터

<ParamField path="task_id" type="string" required>
  Flow Music 작업 제출 후 반환되는 작업 ID

  <Note>
    작업 ID는 제출 응답의 `data[0].task_id`에서 가져옵니다.
  </Note>
</ParamField>

## 쿼리 파라미터

<ParamField query="language" type="string" default="zh">
  오류 메시지 및 일부 안내 문구의 언어

  허용 값: `zh`, `en`, `ja`, `ko`
</ParamField>

## 응답 필드

<ResponseField name="code" type="integer">
  응답 상태 코드, 성공 시 200
</ResponseField>

<ResponseField name="data" type="object">
  작업 상세 정보

  <Expandable title="작업 필드">
    <ResponseField name="id" type="string">
      작업 ID
    </ResponseField>

    <ResponseField name="status" type="string">
      작업 상태: `pending`, `processing`, `completed`, `failed`
    </ResponseField>

    <ResponseField name="progress" type="integer">
      작업 진행률, 범위 0-100
    </ResponseField>

    <ResponseField name="cost" type="number">
      실제 청구 금액; 작업 실패 시 일반적으로 0
    </ResponseField>

    <ResponseField name="credits_cost" type="number">
      실제 소비된 credits
    </ResponseField>

    <ResponseField name="result" type="object">
      작업 완료 후의 생성 결과; Flow Music 기능에 따라 반환되는 필드가 다릅니다
    </ResponseField>
  </Expandable>
</ResponseField>

## 결과 구조

### 음악 작업

음악 생성, 음악 연장, 구간 교체, Cover 편곡, 음원 분리, 오디오 업로드, 오디오 다운로드 및 비디오 렌더링은 일반적으로 `result.music` 배열을 반환합니다.

```json theme={null}
{
  "result": {
    "music": [
      {
        "clip_id": "a41aade4-993e-4d28-b56f-d97e7ef7167c",
        "audio_url": "https://cdn.apimart.ai/audio/flowmusic_a41aade4.m4a",
        "wav_url": "https://cdn.apimart.ai/audio/flowmusic_a41aade4.wav",
        "video_url": "https://cdn.apimart.ai/video/flowmusic_a41aade4.mp4",
        "file_url": "https://cdn.apimart.ai/audio/flowmusic_a41aade4_stems.zip"
      }
    ]
  }
}
```

### 가사 작업

가사 생성은 `result.lyrics` 배열을 반환합니다.

```json theme={null}
{
  "result": {
    "lyrics": [
      {
        "title": "Bleached",
        "lyrics": "[Intro]\n(Check)\n(One two)\n..."
      }
    ]
  }
}
```

## 사용 안내

<Note>
  Flow Music 제출 엔드포인트는 모두 비동기 작업입니다. 제출 성공 후 먼저 `task_id`를 획득한 다음, 본 엔드포인트를 호출하여 작업 상태를 폴링하세요. `status`가 `completed`가 되면 `result`에서 생성 결과를 읽습니다.
</Note>
