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

# Download Audio

> Flow Music exports a clip as an audio file in the specified format (wav / mp3)

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://gccai.heqingsong.uk/v1/music/generations/downloadAudioFlowMusic \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "flowmusic",
      "clip_id": "abc123-def456",
      "format": "wav"
    }'
  ```

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

  url = "https://gccai.heqingsong.uk/v1/music/generations/downloadAudioFlowMusic"

  payload = {
      "model": "flowmusic",
      "clip_id": "abc123-def456",
      "format": "wav"
  }

  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://gccai.heqingsong.uk/v1/music/generations/downloadAudioFlowMusic";

  const payload = {
    model: "flowmusic",
    clip_id: "abc123-def456",
    format: "wav"
  };

  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_01KWXVD3FPYYQPJ2N87XXE5NQG"
      }
    ]
  }
  ```

  ```json 400 theme={null}
  {
    "error": {
      "message": "format must be one of: wav, mp3",
      "type": "invalid_request",
      "param": "",
      "code": "invalid_request"
    }
  }
  ```

  ```json 403 theme={null}
  {
    "error": {
      "message": "Insufficient balance",
      "type": "invalid_request",
      "param": "",
      "code": "quota_not_enough"
    }
  }
  ```

  ```json 429 theme={null}
  {
    "error": {
      "message": "Current group capacity is saturated, please retry later",
      "type": "rate_limit_error",
      "param": "",
      "code": "rate_limit_error"
    }
  }
  ```
</ResponseExample>

## Authentication

<ParamField header="Authorization" type="string" required>
  All endpoints require Bearer Token authentication

  Get your API Key:

  Visit the [API Key management page](https://gccai.heqingsong.uk/keys) to get your API Key

  Add it to the request header:

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

## Request Parameters

<ParamField body="model" type="string" required>
  Model name, **must be `"flowmusic"`** (case-insensitive)
</ParamField>

<ParamField body="clip_id" type="string" required>
  clip\_id of the music to download, from a successful task's `result.music[].clip_id`
</ParamField>

<ParamField body="format" type="string" required>
  Download format

  Options:

  * `mp3` - Lossy compression, smaller file size
  * `wav` - Lossless, suitable for post-production
</ParamField>

## Response

<ResponseField name="code" type="integer">
  Response status code, 200 on success
</ResponseField>

<ResponseField name="data" type="array">
  Array of returned data

  <Expandable title="Array elements">
    <ResponseField name="status" type="string">
      Task status, `submitted` upon initial submission
    </ResponseField>

    <ResponseField name="task_id" type="string">
      Unique task identifier, used to query task status and results
    </ResponseField>
  </Expandable>
</ResponseField>

## Use Cases

### Scenario 1: Export lossless wav

```json theme={null}
{
  "model": "flowmusic",
  "clip_id": "abc123-def456",
  "format": "wav"
}
```

<Note>
  **Query Task Results**

  Audio download is an asynchronous task; a `task_id` is returned after submission. Use the [Get Task Status](./query) endpoint to query generation progress and results. The result is always in `result.music[0].audio_url` (`url` has the same value); the `format` / `mime_type` fields indicate the actual format.
</Note>

## Completed Task Result Example

**Query response example** (`GET /v1/music/tasks/{task_id}`):

```json theme={null}
{
  "code": 200,
  "data": {
    "id": "task_01KWXVD3FPYYQPJ2N87XXE5NQG",
    "status": "completed",
    "progress": 100,
    "created": 1783413247,
    "completed": 1783413296,
    "actual_time": 49,
    "cost": 0.016,
    "credits_cost": 0.16,
    "result": {
      "music": [
        {
          "clip_id": "a41aade4-993e-4d28-b56f-d97e7ef7167c",
          "format": "wav",
          "mime_type": "audio/wav",
          "size_bytes": 34900726,
          "audio_url": "https://gccai.heqingsong.uk/_gccai/cdn/audio/flowmusic_a41aade4_download_audio.wav",
          "url": "https://gccai.heqingsong.uk/_gccai/cdn/audio/flowmusic_a41aade4_download_audio.wav"
        }
      ]
    }
  }
}
```
