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

# Suno API：生成音乐

> 使用简单的文本提示词生成 AI 音乐。

### 重要说明

* 支持两种生成模式：`simple` 和 `custom`
* 此接口可基于你的文本提示词（simple 模式）或自定义歌词与风格（custom 模式）生成音乐
* 每次请求最多会生成两种不同的音乐变体
* 你可以通过生成模式和是否仅生成纯音乐来控制生成细节

<Tip>
  对于新用户，建议优先从 simple 模式开始（`mode=simple`）。
</Tip>

### 生成音乐（Simple 模式）

只需一个文本提示词即可生成音乐，无需其他复杂参数。

## 响应示例

<CodeGroup>
  ```json 带歌词 theme={null} theme={null}
  {
  	"model": "suno/music-generate",
  	"callback_url": "",
  	"input": {
          "mode": "simple",
          "model": "v5",
          "instrumental": false,
          "prompt": "一首暗黑且性感的西式 R&B 歌曲，带有丝滑且气声感明显的女声演唱，慢节奏、极简鼓点、深沉低音、忧郁氛围，主题关于心碎与有毒爱情，深夜氛围，亲密且富有情感。"
      }
  }
  ```

  ```json 纯音乐 theme={null} theme={null}
  {
  	"model": "suno/music-generate",
  	"callback_url": "",
  	"input": {
          "mode": "simple",
          "model": "v5",
          "instrumental": true,
          "prompt": "Lo-fi chill 风格的纯音乐 Hip Hop 节拍，带有黑胶噼啪声，氛围放松，适合学习时播放"
      }
  }
  ```
</CodeGroup>

### 生成音乐（Custom 模式）

自定义歌曲生成需要提供歌曲标题、风格和歌词（纯音乐模式除外），同时支持可选的高级参数设置。

<CodeGroup>
  ```json 自定义模式带歌词 theme={null} theme={null}
  {
  	"model": "suno/music-generate",
  	"callback_url": "",
  	"input": {
          "mode": "custom",
          "model": "v5",
          "title": "Midnight Addiction",
          "tags": "Western R&B, female vocal, dark, sensual, slow tempo, moody, emotional",
          "lyrics": "[Verse 1]\nI still taste your words in the dark\nLike a flame leaving invisible scars\nYou pull me close just to let go\nAnd I keep falling into your shadow\n\n[Chorus]\nYou're my midnight addiction\nNo cure for this condition\nEven when it hurts, I stay\nLost in your contradiction\n\n[Verse 2]\nEvery silence feels so loud\nWhen your love ain't around\nI know I should walk away\nBut I'm too deep to escape now",
          "vocal_gender": "f",
          "style_weight": 0.85,
          "weirdness_constraint": 0.2
      }
  }
  ```

  ```json 自定义模式纯音乐 theme={null} theme={null}
  {
  	"model": "suno/music-generate",
  	"callback_url": "",
  	"input": {
          "mode": "custom",
          "model": "v5",
          "instrumental": true,
          "title": "Neon Dreams",
          "tags": "lofi, chill, instrumental, ambient, night, soft piano, relaxing",
          "style_weight": 0.9,
          "weirdness_constraint": 0.2
      }
  }
  ```
</CodeGroup>

### 获取任务结果

提交任务后，可以使用统一查询接口检查任务进度并获取生成结果：

<Card title="获取 Suno 任务信息" icon="magnifying-glass" href="/zh/suno-api/suno-task-info">
  了解如何查询 Suno 任务状态并获取生成结果
</Card>


## OpenAPI

````yaml zh/suno-api/generate-music.json post /api/v1/client/job/CreateTask
openapi: 3.0.0
info:
  title: Crun Suno 音乐生成 API
  description: crun.ai Suno 音乐生成 API 文档
  version: 1.0.0
  contact:
    name: 技术支持
    email: support@crun.ai
servers:
  - url: https://api.crun.ai
    description: API 服务地址
security:
  - ApiKeyAuth: []
paths:
  /api/v1/client/job/CreateTask:
    post:
      summary: Suno 音乐生成
      operationId: suno/music-generate
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - model
                - input
              properties:
                model:
                  type: string
                  enum:
                    - suno/music-generate
                  description: |-
                    用于生成的模型名称。必填字段。

                    - 此接口必须使用 `suno/music-generate`
                callback_url:
                  type: string
                  format: uri
                  description: |-
                    可选。用于接收任务完成通知的回调 URL。

                    - 当生成完成后，系统会向该 URL 发送任务状态和结果
                    - 回调数据结构与任务状态查询接口返回的 `data` 对象一致
                    - 你的回调接口应支持接收包含 JSON 数据的 POST 请求
                    - 成功接收后需返回 HTTP 200 状态码
                  example: https://your-domain.com/api/callback
                input:
                  $ref: '#/components/schemas/SunoMusicGenerateInput'
            example:
              model: suno/music-generate
              callback_url: https://your-domain.com/api/callback
              input:
                mode: custom
                model: v5
                instrumental: false
                title: Midnight Addiction
                tags: Western R&B, female vocal, dark, sensual, slow tempo, moody
                lyrics: |-
                  [Verse 1]
                  I still taste your words in the dark
                  Like a flame leaving invisible scars

                  [Chorus]
                  You're my midnight addiction
                  No cure for this condition
                vocal_gender: f
                style_weight: 0.85
                weirdness_constraint: 0.2
                negative_tags: metal, aggressive
      responses:
        '200':
          description: 请求成功
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ApiResponse'
                  - type: object
                    properties:
                      data:
                        type: object
                        properties:
                          task_id:
                            type: string
                            description: 任务 ID，可用于通过获取任务详情接口查询任务状态
                            example: task_12345678
              example:
                code: 200
                message: success
                data:
                  task_id: task_12345678
        '422':
          description: 参数验证错误
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ApiResponse'
                  - type: object
                    properties:
                      errors:
                        type: array
                        description: 详细的参数验证错误信息
                        items:
                          type: string
                        example:
                          - specific error field message
              example:
                code: 422
                message: Missing Params or Type Error
                errors:
                  - specific error field message
        '500':
          $ref: '#/components/responses/Error'
components:
  schemas:
    SunoMusicGenerateInput:
      type: object
      description: |-
        Suno 音乐生成的输入参数。

        规则：
        - `mode=simple`：`prompt` 为必填项。
        - `mode=custom`：`title` 和 `tags` 为必填项。
        - `mode=custom` 且 `instrumental=false`：`lyrics` 为必填项。
        - `model=v4`：`tags` 最大长度为 200，`lyrics` 最大长度为 3000。
      properties:
        mode:
          type: string
          enum:
            - simple
            - custom
          description: 音乐生成模式。
          example: simple
        model:
          type: string
          enum:
            - v5.5
            - v5
            - v4.5plus
            - v4.5
            - v4.5all
            - v4
          description: |-
            Suno 音乐模型版本。

            - **v5.5**：专为匹配你的独特音乐品味而打造的定制模型。
            - **v5**：更优秀的音乐表现力，更快的生成速度。
            - **v4.5plus**：v4.5+ 提供更丰富的音质、全新的创作方式，最长支持 8 分钟。
            - **v4.5**：支持更智能的提示词与更快的生成速度，最长支持 8 分钟。
            - **v4.5all**：支持更智能的提示词与更快的生成速度，最长支持 8 分钟。
            - **v4**：提升人声质量，最长支持 4 分钟。
          example: v5
        instrumental:
          type: boolean
          description: 是否仅生成纯音乐（无歌词）。
          example: false
        title:
          type: string
          maxLength: 100
          description: 音乐标题。在 `custom` 模式下为必填项。
          example: Midnight Addiction
        prompt:
          type: string
          maxLength: 500
          description: 用于 `simple` 模式下引导音乐生成的文本提示词。当 `mode=simple` 时为必填项。
          example: >-
            Lo-fi chill instrumental hip hop beat with vinyl crackle, relaxing
            mood.
        lyrics:
          type: string
          maxLength: 5000
          description: >-
            自定义模式下使用的歌词。当 `mode=custom` 且 `instrumental=false` 时为必填项。对于 `v4`
            模型最大长度为 3000，其他模型为 5000。
          example: |-
            [Verse 1]
            I still taste your words in the dark...
        tags:
          type: string
          maxLength: 1000
          description: 音乐风格标签。在 `custom` 模式下为必填项。对于 `v4` 模型最大长度为 200，其他模型为 1000。
          example: Western R&B, female vocal, dark, sensual, slow tempo
        vocal_gender:
          type: string
          enum:
            - m
            - f
          description: 人声性别偏好：`m` 表示男声，`f` 表示女声。仅在 `custom` 模式下生效。
          example: f
        negative_tags:
          type: string
          maxLength: 1000
          description: 需要排除的音乐风格。
          example: metal, aggressive, harsh vocals
        style_weight:
          type: number
          minimum: 0
          maximum: 1
          description: 风格参考强度，范围为 0.0 到 1.0。
          example: 0.85
        weirdness_constraint:
          type: number
          minimum: 0
          maximum: 1
          description: 控制实验性/创意偏离程度，范围为 0.0 到 1.0。
          example: 0.2
        persona_id:
          type: string
          description: >-
            所选 Persona 模型对应的 Persona ID。可通过 [Suno Persona
            Generate](/zh/suno-api/suno-persona-generate) 创建。
          example: persona_123456
        persona_model:
          type: string
          enum:
            - style_persona
            - voice_persona
          description: |-
            Persona 模型类型。需与 `persona_id` 搭配使用以应用已保存的 Persona。

             - **style_persona**：应用偏向风格的 Persona 特征。
             - **voice_persona**：应用偏向声音的 Persona 特征（仅 v5 模型支持）。
          default: style_persona
          example: style_persona
      required:
        - mode
        - model
        - instrumental
    ApiResponse:
      type: object
      properties:
        code:
          type: integer
          enum:
            - 200
            - 401
            - 402
            - 404
            - 422
            - 429
            - 455
            - 500
            - 501
            - 505
          description: |-
            响应状态码

            - **200**：成功 - 请求已成功处理
            - **401**：未授权 - 缺少认证信息或认证无效
            - **402**：余额不足 - 账户积分不足，无法执行当前操作
            - **404**：未找到 - 请求的资源或接口不存在
            - **422**：参数验证错误 - 请求参数未通过校验
            - **429**：请求过于频繁 - 当前资源已超出请求限制
            - **455**：服务不可用 - 系统正在维护中
            - **500**：服务器错误 - 处理请求时发生未知错误
            - **501**：生成失败 - 内容生成任务失败
            - **505**：功能已禁用 - 当前功能暂不可用
        message:
          type: string
          description: 响应消息，失败时为错误描述
          example: success
  responses:
    Error:
      description: 服务器错误
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: |-
        所有 API 均需通过 API Key 进行身份认证。

        获取 API Key：
        1. 访问 [API Key 管理页面](https://crun.ai/zh/user-api-key) 获取你的 API Key

        使用方式：
        在请求头中添加：

        x-api-key: YOUR_API_KEY

        注意：
        - 请妥善保管你的 API Key，不要泄露给他人
        - 如果怀疑 API Key 已泄露，请立即在管理页面中重置

````