> ## 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.

# 创建自定义模型

> 使用 6–24 条参考音频创建可用于 Suno V6 生成的自定义模型

<Info>
  创建模型是异步任务。提交后先取得训练 `task_id`，轮询任务完成后再从 `data.result.model_id` 读取自定义模型 ID。
</Info>

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.apimart.ai/v1/music/generations/createModel \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "suno",
      "name": "温暖民谣模型",
      "audio_urls": [
        "https://example.com/ref-01.mp3",
        "https://example.com/ref-02.mp3",
        "https://example.com/ref-03.wav",
        "https://example.com/ref-04.m4a",
        "https://example.com/ref-05.mp3",
        "https://example.com/ref-06.mp3"
      ]
    }'
  ```

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

  response = requests.post(
      "https://api.apimart.ai/v1/music/generations/createModel",
      headers={"Authorization": "Bearer <token>"},
      json={
          "model": "suno",
          "name": "温暖民谣模型",
          "audio_urls": [
              "https://example.com/ref-01.mp3",
              "https://example.com/ref-02.mp3",
              "https://example.com/ref-03.wav",
              "https://example.com/ref-04.m4a",
              "https://example.com/ref-05.mp3",
              "https://example.com/ref-06.mp3",
          ],
      },
  )
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("https://api.apimart.ai/v1/music/generations/createModel", {
    method: "POST",
    headers: {
      "Authorization": "Bearer <token>",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      model: "suno",
      name: "温暖民谣模型",
      audio_urls: [
        "https://example.com/ref-01.mp3",
        "https://example.com/ref-02.mp3",
        "https://example.com/ref-03.wav",
        "https://example.com/ref-04.m4a",
        "https://example.com/ref-05.mp3",
        "https://example.com/ref-06.mp3"
      ]
    })
  });
  console.log(await response.json());
  ```
</RequestExample>

## Authorizations

<ParamField header="Authorization" type="string" required>
  Bearer Token。访问 [API Key 管理页面](https://apimart.ai/keys) 获取 API Key。
</ParamField>

## Body

<ParamField body="model" type="string" default="suno">
  固定使用 `suno`。
</ParamField>

<ParamField body="name" type="string" required>
  自定义模型名称。去掉首尾空白后不能为空。
</ParamField>

<ParamField body="audio_urls" type="string[]" required>
  6–24 条公网可访问的 HTTP(S) 音频直链，建议使用 MP3、WAV 或 M4A。每条 URL 都应直接返回音频文件，不能是需要登录的网页。
</ParamField>

<Warning>
  无效素材可能导致整个创建任务失败。本地文件请先使用项目的上传能力获得公网 URL；不要传本地路径或 `blob:` URL。
</Warning>

## Response

<ResponseField name="code" type="integer">响应状态码。</ResponseField>

<ResponseField name="data" type="array">
  提交结果。读取 `data[0].task_id`，再通过 `GET /v1/music/tasks/{task_id}` 查询训练状态。
</ResponseField>

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

  ```json completed theme={null}
  {
    "code": 200,
    "data": {
      "id": "task_01M24YMN4EV04M84R5QYM77R1E",
      "status": "completed",
      "progress": 100,
      "result": {
        "model_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
        "name": "温暖民谣模型"
      }
    }
  }
  ```
</ResponseExample>

## 使用创建的模型

完成后保存 `result.model_id`，后续在支持自定义模型的操作中作为 `custom_model_id` 使用，并省略 `version` 和 `persona_id`：

```json theme={null}
{
  "model": "suno",
  "custom_model_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "custom": true,
  "instrumental": false,
  "prompt": "[Verse]\n旧木吉他弹起新的旅程",
  "style": "acoustic folk, warm vocals",
  "max_mode": true,
  "audio_format": "mp3"
}
```

创建模型可能需要数分钟，最长约 20 分钟。自定义模型的实际可用时间可能变化，界面不应承诺固定的精确到期时间。创建模型与后续每次生成分别计费。
