> ## 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으로 가져와 clip_id를 발급받아 이후 연장 / 교체 / Cover / 분리에 사용합니다

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.apimart.ai/v1/music/generations/uploadAudioFlowMusic \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "flowmusic",
      "audio_url": "https://example.com/audio.mp3"
    }'
  ```

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

  url = "https://api.apimart.ai/v1/music/generations/uploadAudioFlowMusic"

  payload = {
      "model": "flowmusic",
      "audio_url": "https://example.com/audio.mp3"
  }

  headers = {
      "Authorization": "Bearer <token>",
      "Content-Type": "application/json"
  }

  response = requests.post(url, json=payload, headers=headers)

  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const url = "https://api.apimart.ai/v1/music/generations/uploadAudioFlowMusic";

  const payload = {
    model: "flowmusic",
    audio_url: "https://example.com/audio.mp3"
  };

  const headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
  };

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

<ResponseExample>
  ```json 200 theme={null}
  {
    "code": 200,
    "data": [
      {
        "status": "submitted",
        "task_id": "task_01KWXVD2FC61SYZ5103Z4XCCS5"
      }
    ]
  }
  ```

  ```json 400 theme={null}
  {
    "error": {
      "message": "audio_url is required",
      "type": "invalid_request",
      "param": "",
      "code": "invalid_request"
    }
  }
  ```

  ```json 403 theme={null}
  {
    "error": {
      "message": "잔액이 부족합니다",
      "type": "invalid_request",
      "param": "",
      "code": "quota_not_enough"
    }
  }
  ```

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

## 인증

<ParamField header="Authorization" type="string" required>
  모든 API는 Bearer Token 인증이 필요합니다

  API Key 발급:

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

  사용 시 요청 헤더에 다음을 추가하세요:

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

## 요청 파라미터

<ParamField body="model" type="string" required>
  모델 이름, **`"flowmusic"` 고정값**(대소문자 구분 없음)
</ParamField>

<ParamField body="audio_url" type="string" required>
  업로드할 오디오 파일 주소, 공개 네트워크에서 접근 가능해야 합니다

  <Warning>
    일반적인 오디오 파일 확장자(예: `.mp3` / `.wav`)만 지원합니다.
  </Warning>
</ParamField>

## 응답

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

<ResponseField name="data" type="array">
  반환 데이터 배열

  <Expandable title="배열 요소">
    <ResponseField name="status" type="string">
      작업 상태, 최초 제출 시 `submitted`
    </ResponseField>

    <ResponseField name="task_id" type="string">
      작업 고유 식별자, 작업 상태와 결과 조회에 사용됩니다
    </ResponseField>
  </Expandable>
</ResponseField>

## 사용 시나리오

### 시나리오 1: 외부 오디오를 가져와 clip\_id 발급

```json theme={null}
{
  "model": "flowmusic",
  "audio_url": "https://example.com/audio.mp3"
}
```

완료 후 `result.music[0].clip_id`에서 가져온 결과물의 clip\_id를 얻으면 [연장](./extend) / [교체](./replace) / [Cover](./cover) / [분리](./stems)에 사용할 수 있습니다.

<Note>
  **작업 결과 조회**

  오디오 업로드는 비동기 작업으로, 제출 후 `task_id`가 반환됩니다. [작업 상태 조회](./query) API로 생성 진행 상황과 결과를 확인하세요.
</Note>

## 작업 완료 결과 예시

**조회 응답 예시**(`GET /v1/music/tasks/{task_id}`):

```json theme={null}
{
  "code": 200,
  "data": {
    "id": "task_01KWXVD2FC61SYZ5103Z4XCCS5",
    "status": "completed",
    "progress": 100,
    "created": 1783413246,
    "completed": 1783413282,
    "actual_time": 36,
    "cost": 0.008,
    "credits_cost": 0.08,
    "result": {
      "music": [
        {
          "clip_id": "1db3a20f-4ddc-44e8-8c9c-6c9093c16ffe",
          "audio_url": "https://cdn.apimart.ai/audio/flowmusic_1db3a20f_upload_audio.wav",
          "url": "https://cdn.apimart.ai/audio/flowmusic_1db3a20f_upload_audio.wav"
        }
      ]
    }
  }
}
```
