> ## 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-generate.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: '`custom_mode: false`，一句描述生成歌曲，歌词由模型自动创作。'
                summary: 简单模式
                value:
                  model: ai-music-api/generate
                  input:
                    prompt: 一首轻快的原声吉他歌曲，讲述夏日公路旅行
                    custom_mode: false
                    instrumental: false
                    model: V6
              自定义歌词与风格:
                description: '`custom_mode: true`，指定歌名、风格、歌词、女声和约 2 分钟时长，完成后回调。'
                summary: 自定义歌词与风格
                value:
                  model: ai-music-api/generate
                  callBackUrl: https://your-domain.com/api/callback
                  input:
                    lyrics: |-
                      [Verse]
                      霓虹在雨夜里闪烁
                      街角的灯为谁而亮
                      [Chorus]
                      带我穿过这座城
                      直到黎明点亮天空
                    style: 合成器流行, 80 年代复古, 梦幻女声
                    title: 霓虹之城
                    custom_mode: true
                    instrumental: false
                    model: V6
                    negative_tags: heavy metal
                    vocal_gender: f
                    style_weight: 0.65
                    duration: 120
              纯音乐:
                description: >-
                  `instrumental: true` 生成无人声的纯音乐；`V6_MINI` 速度更快，`variety: 2`
                  让两首结果风格差异更明显。
                summary: 纯音乐
                value:
                  model: ai-music-api/generate
                  input:
                    style: lo-fi hip hop, mellow piano, vinyl crackle
                    title: 午后咖啡馆
                    custom_mode: true
                    instrumental: true
                    model: V6_MINI
                    negative_tags: vocals, heavy drums
                    weirdness_constraint: 0.3
                    variety: 2
              参考素材（简单模式）:
                description: 简单模式可附加图片、视频、音频、MIDI 作为灵感参考；MIDI 仅 `V6_WILD` 支持。
                summary: 参考素材（简单模式）
                value:
                  model: ai-music-api/generate
                  input:
                    prompt: 根据这张海边日落照片的氛围，写一首温暖的独立民谣
                    image_urls:
                      - https://your-cdn.example.com/sunset.jpg
                    midi_urls:
                      - https://your-cdn.example.com/melody.mid
                    style: indie folk
                    custom_mode: false
                    instrumental: false
                    model: V6_WILD
            schema:
              $ref: '#/components/schemas/SunoCreateTaskRequestSunoGenerateInput'
        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.title is required.
                    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:
    SunoCreateTaskRequestSunoGenerateInput:
      additionalProperties: false
      description: 创建任务的请求体。
      properties:
        model:
          default: ai-music-api/generate
          description: |-
            接口名称，决定 `input` 的字段。

            **可选值：**
            - `ai-music-api/generate`：Suno 生成音乐
          enum:
            - ai-music-api/generate
          type: string
        callBackUrl:
          description: >-
            可选，任务完成（成功或失败）后接收回调的地址，须为公网可访问的 `http` / `https`
            地址；推荐生产环境使用，也可以只轮询查询任务接口。回调格式和签名见“任务完成回调”。
          type: string
        input:
          $ref: '#/components/schemas/SunoGenerateInput'
          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
    SunoGenerateInput:
      additionalProperties: false
      description: >-
        `ai-music-api/generate` 的参数。`custom_mode`、`instrumental`、`model`
        必填，其他字段按模式使用。
      properties:
        prompt:
          description: >-
            可选，歌曲描述。简单模式下作为核心创意，歌词由模型据此自动创作（不会逐字使用），最多 3000
            个字符；自定义模式下作为歌词逐字演唱（同时传 `lyrics` 时以 `lyrics` 为准），最多 5000 个字符。
          maxLength: 5000
          type: string
        lyrics:
          description: >-
            可选，歌词，最多 5000 个字符。自定义模式下优先作为歌词（未传时使用 `prompt`）；简单模式下作为歌词附件，与
            `prompt` 的描述一起使用。可用 `[Verse]`、`[Chorus]` 等标记段落。
          maxLength: 5000
          type: string
        image_urls:
          description: >-
            可选，参考图片，仅简单模式可用，1 ~ 5 张，单张不超过 10 MB，支持 jpeg、png、webp、bmp，须为公网可访问的
            `http` / `https` 地址。
          items:
            type: string
          maxItems: 5
          minItems: 1
          type: array
        video_urls:
          description: >-
            可选，参考视频，仅简单模式可用，最多 1 个，不超过 100 MB、时长不超过 241 秒，支持
            mp4、mov、webm，须为公网可访问的 `http` / `https` 地址。
          items:
            type: string
          maxItems: 1
          minItems: 1
          type: array
        audio_urls:
          description: >-
            可选，参考音频，仅简单模式可用，时长 6 秒 ~ 30 分钟，单个不超过 500 MB，须为公网可访问的 `http` /
            `https` 地址。
          items:
            type: string
          minItems: 1
          type: array
        midi_urls:
          description: >-
            可选，参考 MIDI，仅简单模式可用，最多 1 个，支持 mid、midi，不超过 256 KB 且以标准 `MThd`
            文件头开头，须为公网可访问的 `http` / `https` 地址。仅 `V6_WILD` 支持，传其他版本时自动使用
            `V6_WILD`。
          items:
            type: string
          maxItems: 1
          minItems: 1
          type: array
        style:
          description: >-
            可选，音乐风格，最多 1000 个字符，如
            `Jazz`、`Classical`、`Electronic`、`Pop`、`Rock`、`Hip-hop`。简单模式下计入参考素材数量。
          maxLength: 1000
          type: string
        title:
          description: 歌名，自定义模式必填，最多 80 个字符，显示在播放器和文件名中。
          maxLength: 80
          type: string
        custom_mode:
          description: >-
            必填，是否使用自定义模式。`true`：自己指定歌名、风格、歌词等并可调节细节参数，`title` 必填，且
            `style`、`lyrics`、`negative_tags`
            至少填一个；`false`：简单模式，`prompt`、`style`、`lyrics` 或参考素材至少填一个。
          type: boolean
        instrumental:
          description: 必填，是否生成纯音乐（无人声）。`false` 时按歌词演唱（自定义模式使用 `lyrics`，未传时使用 `prompt`）。
          type: boolean
        model:
          description: |-
            必填，Suno 模型版本：`V6`、`V6_MINI` 或 `V6_WILD`。已下线的 V4 ~ V5_5 不再支持。

            **可选值：**
            - `V6`：Suno V6：音乐表现力更强，人声更自然，细节更丰富
            - `V6_MINI`：Suno V6 Mini：轻量快速，兼顾质量与速度
            - `V6_WILD`：Suno V6 Wild：突破创作边界，表达更大胆、更有个性
          enum:
            - V6
            - V6_MINI
            - V6_WILD
          type: string
        negative_tags:
          description: 可选，要排除的音乐风格或特征，如 `Heavy Metal, Upbeat Drums`。
          type: string
        vocal_gender:
          description: |-
            可选，人声性别偏好。只提高对应性别出现的概率，不保证一定生效。仅自定义模式可用。

            **可选值：**
            - `m`：男声
            - `f`：女声
          enum:
            - m
            - f
          type: string
        style_weight:
          description: 可选，对 `style` 的遵循强度，`0` ~ `1`，最多 2 位小数。仅自定义模式可用。
          format: double
          maximum: 1
          minimum: 0
          multipleOf: 0.01
          type: number
        weirdness_constraint:
          description: 可选，创意 / 实验性偏离程度，`0` ~ `1`，最多 2 位小数；越大越大胆。仅自定义模式可用。
          format: double
          maximum: 1
          minimum: 0
          multipleOf: 0.01
          type: number
        audio_weight:
          description: >-
            可选，音频特征的相对权重，`0` ~ `1`，最多 2 位小数。仅自定义模式可用，纯音乐（`instrumental:
            true`）不支持。
          format: double
          maximum: 1
          minimum: 0
          multipleOf: 0.01
          type: number
        variety:
          default: 1
          description: >-
            可选，结果的多样性，`0` ~ `4` 的整数，默认 `1`，仅自定义模式可用：`0` 关闭（严格保持风格）、`1`
            正常（兼顾稳定与多样）、`2` 高（风格明显不同）、`3` 更高（大胆探索）、`4` 最大（差异可能非常大）。
          format: double
          maximum: 4
          minimum: 0
          multipleOf: 1
          type: number
        persona_id:
          description: >-
            可选，Persona ID 或 Voice ID，让生成的音乐沿用该 Persona 的风格或该自定义音色。Persona 由“生成
            Persona”接口创建，Voice 由“自定义音色”接口创建。
          type: string
        persona_model:
          description: |-
            可选，`persona_id` 的类型。

            **可选值：**
            - `style_persona`：风格 Persona：沿用 Persona 的整体音乐风格
            - `voice_persona`：音色 Persona：沿用 Persona 或自定义音色的声音
          enum:
            - style_persona
            - voice_persona
          type: string
        duration:
          description: 可选，目标时长（秒），`10` ~ `360`，仅自定义模式可用；不传时由模型决定。
          format: double
          maximum: 360
          minimum: 10
          type: number
      required:
        - custom_mode
        - instrumental
        - model
      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.