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

# 生成语音：创建任务

> 创建 Suno 任务：`model` 选择接口，参数放在 `input` 中，可选 `callBackUrl` 接收完成回调。成功后返回 `data.taskId`，任务在后台异步执行，用查询任务接口轮询结果。所有响应的 HTTP 状态码都是 200，以 `code` 判断结果。



## OpenAPI

````yaml /openapi/zh/suno-speech.json post /api/v1/jobs/createTask
openapi: 3.1.0
info:
  description: 生成带语气、节奏、情绪和可选背景音乐的语音：简单模式只需一句场景描述，高级模式提供要朗读的台词并可调节语气、多样性、人声性别和背景音乐；每次生成两段。
  title: Suno 生成语音
  version: v1
servers:
  - url: https://api.dreamto.ai
security:
  - bearerAuth: []
tags:
  - name: Suno 生成语音
paths:
  /api/v1/jobs/createTask:
    post:
      tags:
        - Suno 生成语音
      summary: 创建任务
      description: >-
        创建 Suno 任务：`model` 选择接口，参数放在 `input` 中，可选 `callBackUrl` 接收完成回调。成功后返回
        `data.taskId`，任务在后台异步执行，用查询任务接口轮询结果。所有响应的 HTTP 状态码都是 200，以 `code` 判断结果。
      operationId: sunoCreateTask
      requestBody:
        content:
          application/json:
            examples:
              简单模式:
                description: '`customMode: false`，一句场景描述，台词由模型自动创作。'
                summary: 简单模式
                value:
                  model: ai-music-api/speech
                  input:
                    customMode: false
                    prompt: 一段关于晴朗天气的简短早间新闻开场
              高级模式:
                description: '`customMode: true`，提供台词并指定语气、多样性、女声和背景音乐，完成后回调。'
                summary: 高级模式
                value:
                  model: ai-music-api/speech
                  callBackUrl: https://your-domain.com/api/callback
                  input:
                    customMode: true
                    script: 欢迎收看今天的简报。天气晴朗，城市已经醒来。
                    tone: 温暖、平静的女声旁白，略带微笑
                    variety: 1
                    vocalGender: f
                    backgroundMusic: true
              高级模式：仅台词:
                description: 只传必填的 `script`，多行台词用 `\n` 换行，其余由模型决定。
                summary: 高级模式：仅台词
                value:
                  model: ai-music-api/speech
                  input:
                    customMode: true
                    script: |-
                      各位旅客请注意。
                      开往海滨的列车即将进站。
            schema:
              $ref: '#/components/schemas/SunoCreateTaskRequestSunoSpeechInput'
        required: true
      responses:
        '200':
          content:
            application/json:
              examples:
                创建成功:
                  description: '`data.taskId` 为任务 ID。'
                  summary: 创建成功
                  value:
                    code: 200
                    msg: success
                    data:
                      taskId: 7d3f0a9c41e85b2f6a1c9e04b8d27f53
                参数错误（422）:
                  description: 参数不合法，不建任务、不扣费。
                  summary: 参数错误（422）
                  value:
                    code: 422
                    msg: >-
                      input.variety is only supported when input.customMode is
                      true.
                    data: null
                未授权（401）:
                  description: API Key 缺失或无效。
                  summary: 未授权（401）
                  value:
                    code: 401
                    msg: >-
                      Unauthorized - Authentication credentials are missing or
                      invalid
                    data: null
                余额不足（402）:
                  description: 余额不足以支付本次任务。
                  summary: 余额不足（402）
                  value:
                    code: 402
                    msg: >-
                      Insufficient Credits - Account does not have enough
                      credits to perform the operation
                    data: null
                请求过于频繁（429）:
                  description: 超过频率限制，请稍后重试。
                  summary: 请求过于频繁（429）
                  value:
                    code: 429
                    msg: >-
                      Rate Limited - Request limit has been exceeded for this
                      resource
                    data: null
                服务器错误（500）:
                  description: 服务暂时不可用，可稍后重试，不扣费。
                  summary: 服务器错误（500）
                  value:
                    code: 500
                    msg: >-
                      Server Error - An unexpected error occurred while
                      processing the request
                    data: null
              schema:
                $ref: '#/components/schemas/SunoCreateTaskResponse'
          description: >-
            HTTP 状态码始终为 200。`code` 为 `200` 时创建成功，`data.taskId` 为任务 ID；其他 `code`
            为错误，`msg` 为原因，`data` 为 `null`。
          headers:
            X-Request-Id:
              description: 本次请求的 ID，排查问题时请提供。
              schema:
                type: string
components:
  schemas:
    SunoCreateTaskRequestSunoSpeechInput:
      additionalProperties: false
      description: 创建任务的请求体。
      properties:
        model:
          default: ai-music-api/speech
          description: |-
            接口名称，决定 `input` 的字段。

            **可选值：**
            - `ai-music-api/speech`：Suno 生成语音
          enum:
            - ai-music-api/speech
          type: string
        callBackUrl:
          description: >-
            可选，任务完成（成功或失败）后接收回调的地址，须为公网可访问的 `http` / `https`
            地址；推荐生产环境使用，也可以只轮询查询任务接口。回调格式和签名见“任务完成回调”。
          type: string
        input:
          $ref: '#/components/schemas/SunoSpeechInput'
          description: 任务参数，字段由 `model` 决定。
      required:
        - model
        - input
      type: object
    SunoCreateTaskResponse:
      additionalProperties: false
      description: 创建任务的响应。HTTP 状态码始终为 200。
      properties:
        code:
          description: |-
            结果代码：
            - `200`：成功
            - `401`：API Key 缺失或无效
            - `402`：余额不足
            - `404`：模型不存在或未开通
            - `405`：请求方法错误
            - `422`：参数错误，`msg` 为原因，不建任务、不扣费
            - `429`：请求过于频繁，请稍后重试
            - `455`：服务维护中
            - `500`：服务器错误，可稍后重试
            - `501`：生成失败
            - `505`：功能已停用
          format: int64
          type: integer
        msg:
          description: 结果说明：成功时为 `success`，错误时为英文原因。
          type: string
        data:
          $ref: '#/components/schemas/SunoCreateTaskData'
          description: 成功时为任务信息；错误时为 `null`。
      required:
        - code
        - msg
        - data
      type: object
    SunoSpeechInput:
      additionalProperties: false
      description: >-
        `ai-music-api/speech` 的参数。`customMode` 必填；简单模式只传 `prompt`，高级模式传 `script`
        及可选字段，两种模式的字段互斥。
      properties:
        customMode:
          description: >-
            必填，模式开关。`false`：简单模式，只传 `prompt`；`true`：高级模式，传 `script`，可选
            `tone`、`variety`、`vocalGender`、`backgroundMusic`。
          type: boolean
        prompt:
          description: 场景描述，仅简单模式可用且必填；写一句想要的场景，台词由模型自动创作。去掉首尾空白后 1 ~ 3000 个字符。高级模式不能传。
          maxLength: 3000
          minLength: 1
          type: string
        script:
          description: 要朗读的台词，仅高级模式可用且必填。去掉首尾空白后 1 ~ 5000 个字符，支持多行（JSON 中用 `\n` 换行）。
          maxLength: 5000
          minLength: 1
          type: string
        tone:
          description: 可选，仅高级模式可用。描述语气、节奏、情绪和场景，也可以描述口音和伴奏风格。去掉首尾空白后最多 1000 个字符。
          maxLength: 1000
          type: string
        variety:
          description: >-
            可选，仅高级模式可用，`0` ~ `4` 的整数：`0` 严格风格、`1` 均衡、`2` 风格明显不同、`3` 大胆探索、`4`
            差异可能非常大。
          format: double
          maximum: 4
          minimum: 0
          multipleOf: 1
          type: number
        vocalGender:
          description: |-
            可选，仅高级模式可用，人声性别：`f` 女声、`m` 男声，不区分大小写。不要传 `female` / `male`。

            **可选值：**
            - `m`：男声
            - `f`：女声
          enum:
            - m
            - f
          type: string
        backgroundMusic:
          description: 可选，仅高级模式可用，是否添加背景音乐：`true` 开启、`false` 关闭。
          type: boolean
      required:
        - customMode
      type: object
    SunoCreateTaskData:
      additionalProperties: false
      description: 新建的任务。
      properties:
        taskId:
          description: 任务 ID（32 位十六进制），用于查询任务，也作为后续接口的 `task_id`。
          type: string
      required:
        - taskId
      type: object
  securitySchemes:
    bearerAuth:
      description: 'DreamTo 控制台创建的 API Key，格式 `Authorization: Bearer <API Key>`。'
      scheme: bearer
      type: http

````

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