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

# 上传 Voice 样本

> 先上传音色样本并选择片段，再获取验证短句、朗读验证，最后检查 Voice 可用性。

> 能力按服务端配置逐项启用。未启用操作返回 503 且不创建任务；音乐积分扣除当前未启用。

## 调用步骤

先上传音色样本并选择片段，再获取验证短句、朗读验证，最后检查 Voice 可用性。

* 1. 按下方示例准备输入，将占位地址和 ID 换成你有权使用的资源。
* 2. 将 model 设为 suno\_voice\_upload，参数放在 input 内。提交一次并保存返回的 task\_id。
* 3. 查询已保存的任务，或接收回调。任务仍在处理中时继续等待，不重新提交同一操作。
* result.ready 为 true 后，将 result.voice\_upload\_task\_id 传给验证短句接口。

## 创建任务

将model和input发送到统一任务入口；可在顶层传公开HTTPS callback\_url。资源ID均为本账户的本站ID。当前音乐积分扣除未启用。

```json theme={null}
{
  "model": "suno_voice_upload",
  "input": {
    "voice_url": "https://example.com/voice.wav",
    "vocal_start_s": 0,
    "vocal_end_s": 20
  }
}
```

## 受理响应

HTTP 200仅表示受理。查询GET /api/v1/tasks/\{task\_id}，直到data.status为succeeded或failed。成功后读取data.result；失败原因位于data.message。

```json theme={null}
{
  "code": 200,
  "msg": "success",
  "data": {
    "task_id": "YOUR_TASK_ID"
  }
}
```

## 参数速查

| 字段 | 类型 | 必填 | 说明与限制 |
| - | - | - | - |
| voice\_url | string | 是 | 原始声音录音的公开HTTPS URL：MP3/WAV/FLAC/OGG/M4A/AAC，最多500 MiB，时长大于零。 |
| vocal\_start\_s | number | 是 | 选中人声开始位置（秒），最多两位小数。Voice上传使用原始录音时间轴，歌曲Persona使用预处理人声时间轴。 min: 0 |
| vocal\_end\_s | number | 是 | 选中人声结束位置（秒），最多两位小数；须大于开始位置且不超出音频时长。歌曲声音Persona需选择10–30秒。 min: 0 |
| name | string | 否 / 依条件 | Voice 或 Persona 展示名称。 maxLength: 100 |
| description | string | 否 / 依条件 | Voice 或 Persona 描述。 maxLength: 1000 |

## 输入与限制

下方Schema列出支持字段、类型和基础限制；还须遵守“重要条件”，跨字段与来源资源校验不完全体现在JSON Schema中。未知参数会被拒绝。URL 参数仅接受公开 HTTPS 地址，不接受文件对象。

```json theme={null}
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "voice_url": {
      "type": "string",
      "format": "uri",
      "description": "原始声音录音的公开HTTPS URL：MP3/WAV/FLAC/OGG/M4A/AAC，最多500 MiB，时长大于零。"
    },
    "vocal_start_s": {
      "type": "number",
      "minimum": 0,
      "description": "选中人声开始位置（秒），最多两位小数。Voice上传使用原始录音时间轴，歌曲Persona使用预处理人声时间轴。"
    },
    "vocal_end_s": {
      "type": "number",
      "minimum": 0,
      "description": "选中人声结束位置（秒），最多两位小数；须大于开始位置且不超出音频时长。歌曲声音Persona需选择10–30秒。"
    },
    "name": {
      "type": "string",
      "maxLength": 100,
      "description": "Voice 或 Persona 展示名称。"
    },
    "description": {
      "type": "string",
      "maxLength": 1000,
      "description": "Voice 或 Persona 描述。"
    }
  },
  "required": [
    "voice_url",
    "vocal_start_s",
    "vocal_end_s"
  ],
  "additionalProperties": false
}
```

## 重要条件

* 选段须满足0 ≤ vocal\_start\_s \< vocal\_end\_s ≤录音实际时长，最多两位小数。等待ready:true后再取得短句；成功准备的样本会话有效24小时。
* 此步骤的name/description不会自动复制到最终Voice；需要时请在suno\_voice\_create中重新填写。
* 音频URL必须包含可读且时长大于零的MP3/WAV/FLAC/OGG/M4A/AAC音轨，每个文件最多500 MiB。URL须为可公开读取的HTTPS地址、端口443，不含用户名密码或私网地址，且应持续可访问直到任务结束。
* 上传文件保留24小时，生成文件保留14天，任务详情保留30天；复用文件沿用原到期时间。有效Voice/Persona身份映射与任务日志清理分开处理，请及时下载需长期保存的文件。

## 结果 Schema

创建响应为 \{code:200,msg:"success",data:\{task\_id}}，轮询 GET /api/v1/tasks/\{task\_id}。成功时 data.result 为符合下方 Schema 的对象，其他状态为 null；input 仍为 JSON 字符串。

```json theme={null}
{
  "type": "object",
  "required": [
    "voice_upload_task_id",
    "ready"
  ],
  "properties": {
    "voice_upload_task_id": {
      "type": "string"
    },
    "ready": {
      "const": true
    }
  },
  "additionalProperties": false
}
```

## 相关流程

[Voice 完整四步](https://docs.apistable.com/zh/suno-voice-workflow.md)
[文件上传](https://docs.apistable.com/zh/file-upload.md)
[回调](https://docs.apistable.com/zh/webhooks.md)


## OpenAPI

````yaml openapi-suno-voice-upload-zh.json POST /api/v1/tasks/create_task
openapi: 3.1.0
info:
  title: APIstable API
  version: 1.0.0-preview
  description: >-
    Public /api/v1 protocol. Valid API keys have the same account-scoped access.
    No client submission idempotency or max_credits. Enabled Suno operations use
    PayAPI and durable task processing. Media uses R2: uploads 24 hours,
    generated files 14 days, task logs 30 days. Music credit deduction is
    disabled. Unconfigured operations and LLM return 503.
servers:
  - url: https://apistable.com
    description: APIstable API
security: []
paths:
  /api/v1/tasks/create_task:
    post:
      summary: 上传 Voice 样本
      description: 先上传音色样本并选择片段，再获取验证短句、朗读验证，最后检查 Voice 可用性。
      operationId: suno_voice_upload
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - model
                - input
              additionalProperties: false
              properties:
                model:
                  type: string
                  enum:
                    - suno_voice_upload
                  example: suno_voice_upload
                input:
                  $schema: https://json-schema.org/draft/2020-12/schema
                  type: object
                  properties:
                    voice_url:
                      type: string
                      format: uri
                      description: >-
                        原始声音录音的公开HTTPS URL：MP3/WAV/FLAC/OGG/M4A/AAC，最多500
                        MiB，时长大于零。
                    vocal_start_s:
                      type: number
                      minimum: 0
                      description: 选中人声开始位置（秒），最多两位小数。Voice上传使用原始录音时间轴，歌曲Persona使用预处理人声时间轴。
                    vocal_end_s:
                      type: number
                      minimum: 0
                      description: 选中人声结束位置（秒），最多两位小数；须大于开始位置且不超出音频时长。歌曲声音Persona需选择10–30秒。
                    name:
                      type: string
                      maxLength: 100
                      description: Voice 或 Persona 展示名称。
                    description:
                      type: string
                      maxLength: 1000
                      description: Voice 或 Persona 描述。
                  required:
                    - voice_url
                    - vocal_start_s
                    - vocal_end_s
                  additionalProperties: false
                callback_url:
                  type: string
                  format: uri
                  description: >-
                    Optional public HTTPS endpoint for signed completion
                    callbacks; no redirects or private IPs.
            example:
              model: suno_voice_upload
              input:
                voice_url: https://example.com/voice.wav
                vocal_start_s: 0
                vocal_end_s: 20
      responses:
        '200':
          description: Accepted task. Poll the common task endpoint or use callback_url.
          content:
            application/json:
              schema:
                type: object
                required:
                  - code
                  - msg
                  - data
                additionalProperties: false
                properties:
                  code:
                    const: 200
                  msg:
                    const: success
                  data:
                    type: object
                    required:
                      - task_id
                    additionalProperties: false
                    properties:
                      task_id:
                        type: string
        '400':
          description: >-
            40001 invalid JSON, 40002 invalid input/callback, 40003 unsupported
            parameter.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Invalid or revoked API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '402':
          description: '40201: Insufficient credits (live acceptance).'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: '40401: Unknown model or resource not found in this account.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: '40901: Resource belongs to a different provider account.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '410':
          description: '41001: Source audio or temporary resource has expired.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '413':
          description: '41301: Request too large.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: '42201: Requested music combination is not enabled.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: '42901: Rate/concurrency limit (live acceptance).'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: '50301: Service/provider unavailable. No live submission or charge.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth: []
components:
  schemas:
    Error:
      type: object
      required:
        - code
        - msg
        - data
      properties:
        code:
          type: integer
        msg:
          type: string
        data:
          type: 'null'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Every valid key can submit and query its own account. Revoked keys are
        rejected.

````

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