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

# ElevenLabs Music v2.5

> - 提示词或分段计划生成音乐，二选一
- 3–600秒，时长使用整数毫秒
- auto输出MP3，可选C2PA签名
- 异步处理模式，使用返回的任务ID [进行查询](/pages/zh/api-manual/task-management/get-task-detail)
- 完成后从 `results[0].url` 下载音频，请及时保存；链接保留时间取决于文件存储服务。


`prompt` 与 `composition_plan` 必须且只能提供一个。prompt最多4100字符；prompt模式的 `music_length_ms` 为3000–600000整数毫秒，可省略让模型决定长度；`force_instrumental` 默认false，仅用于prompt。

计划使用1–30个 `chunks`，总长3000–600000毫秒。每段必填text（可空）、duration\_ms（3000–120000）与positive\_styles；negative\_styles、context\_adherence可选。歌词每段最多30行、每行200字符。`seed`仅用于计划，不保证完全复现。

`output_format`默认auto，解析为mp3\_48000\_192；`sign_with_c2pa`默认false，仅允许MP3（含auto），不会改变指定编码。详细格式见参数。音频参考、显式timestamps（包括false）和安全控制保持完整请求语义；无法执行时明确报错，不静默降为普通音频。

按实际完整输出时长向上整分钟，基准价 **\$0.6/分钟**；3秒和60秒均计1分钟，超过60秒计2分钟。请求长度用于已有预扣估计，最终采用实际解码时长及提交时价格、分组倍率多退少补。

[查询任务](https://docs.aihubmax.com/pages/zh/api-manual/task-management/get-task-detail.md)后从results\[0].url下载音频。composition\_plan、song\_metadata、words\_timestamps等只在真实返回时保留，普通音频可能没有详细元数据。裸编码按返回的采样率、声道和Content-Type解码，请及时保存。


## OpenAPI

````yaml openapi/zh/elevenlabs-music-v2.5.json POST /v1/audios/generations
openapi: 3.1.0
info:
  title: ElevenLabs Music v2.5
  version: '1.0'
servers:
  - url: https://api.aihubmax.com/e
security:
  - BearerAuth: []
paths:
  /v1/audios/generations:
    post:
      tags:
        - Audio > 音乐生成
      summary: ElevenLabs Music v2.5
      description: >
        - 提示词或分段计划生成音乐，二选一

        - 3–600秒，时长使用整数毫秒

        - auto输出MP3，可选C2PA签名

        - 异步处理模式，使用返回的任务ID
        [进行查询](/pages/zh/api-manual/task-management/get-task-detail)

        - 完成后从 `results[0].url` 下载音频，请及时保存；链接保留时间取决于文件存储服务。
      operationId: elevenlabs-music-v2.5
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ElevenLabsMusicV25Request'
            examples:
              prompt_instrumental_background_music:
                summary: Prompt — instrumental background music
                value:
                  model: elevenlabs-music-v2.5
                  prompt: >-
                    Gentle piano and warm strings for a quiet evening, no
                    vocals.
                  music_length_ms: 30000
                  force_instrumental: true
              composition_plan_a_song_with_two_sections:
                summary: Composition plan — a song with two sections
                value:
                  model: elevenlabs-music-v2.5
                  seed: 42
                  composition_plan:
                    chunks:
                      - text: |-
                          [Verse 1]
                          Neon rain on empty streets
                        duration_ms: 15000
                        positive_styles:
                          - synthwave
                          - female vocal
                      - text: |-
                          [Chorus]
                          We keep dancing through the night
                        duration_ms: 15000
                        positive_styles:
                          - uplifting synthwave
                        context_adherence: high
              composition_plan_audio_style_reference:
                summary: Composition plan — audio style reference
                value:
                  model: elevenlabs-music-v2.5
                  composition_plan:
                    chunks:
                      - text: '[Instrumental]'
                        duration_ms: 15000
                        positive_styles:
                          - cinematic
                          - woodwinds
                        audio_reference:
                          audio_url: >-
                            https://storage.googleapis.com/falserverless/example_outputs/elevenlabs/music_generated.mp3
                          start_ms: 0
                          end_ms: 15000
                          strength: medium
                  output_format: mp3_48000_192
      responses:
        '200':
          $ref: '#/components/responses/TaskCreated'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/PaymentRequired'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
components:
  schemas:
    ElevenLabsMusicV25Request:
      type: object
      required:
        - model
      properties:
        model:
          description: '`elevenlabs-music-v2.5`：提示词或分段计划生成音乐，总长3–600秒；按实际输出时长向上整分钟，每分钟$0.6。'
          examples:
            - elevenlabs-music-v2.5
          type: string
          default: elevenlabs-music-v2.5
        prompt:
          anyOf:
            - maxLength: 4100
              minLength: 1
              type: string
            - type: 'null'
          default: null
          description: 音乐描述，最多 4100 字符。与 composition_plan 必须且只能提供一个。
          example: Mysterious jungle soundtrack with woodwinds and rhythmic percussion.
        composition_plan:
          anyOf:
            - additionalProperties: false
              properties:
                chunks:
                  description: 按播放顺序排列的 1–30 个段落，总时长须为 3000–600000 毫秒。
                  items:
                    additionalProperties: false
                    properties:
                      text:
                        description: >-
                          本段歌词或演奏指示。可用 `[Verse 1]` 等段落名开头，名称 1–100 字符，支持
                          `{scratching}` 等行内指示。最多 30 行，每行最多 200 字符；纯音乐可为空。
                        type: string
                        example: |-
                          [Verse 1]
                          Neon rain on empty streets
                          I keep walking to the beat
                      duration_ms:
                        description: 本段时长，单位毫秒，范围 3000–120000。
                        maximum: 120000
                        minimum: 3000
                        type: integer
                        example: 15000
                      positive_styles:
                        description: 本段应包含的风格与音乐方向，建议使用英文；第一段决定整首歌的主要风格。
                        items:
                          type: string
                        type: array
                        example:
                          - synthwave
                          - analog drum machine
                      negative_styles:
                        anyOf:
                          - items:
                              type: string
                            type: array
                          - type: 'null'
                        default: null
                        description: 本段需避免的风格；无特定要求时可省略或留空。
                        example:
                          - distortion
                      context_adherence:
                        anyOf:
                          - enum:
                              - low
                              - medium
                              - high
                            type: string
                          - type: 'null'
                        default: null
                        description: 与相邻段落的一致性：`low` 更自由，`high` 更连贯。
                        example: medium
                      audio_reference:
                        anyOf:
                          - additionalProperties: false
                            properties:
                              audio_url:
                                description: 用作风格参考的音频 URL，必须为公开可访问的 HTTP/HTTPS 地址。
                                type: string
                                example: >-
                                  https://storage.googleapis.com/falserverless/example_outputs/elevenlabs/music_generated.mp3
                              start_ms:
                                default: 0
                                description: 参考片段的起始偏移，单位毫秒。
                                minimum: 0
                                type: integer
                                example: 0
                              end_ms:
                                anyOf:
                                  - exclusiveMinimum: 0
                                    type: integer
                                  - type: 'null'
                                default: null
                                description: >-
                                  参考片段的结束偏移，单位毫秒。必须大于 start_ms，窗口最长 30000
                                  毫秒；省略时采用 start_ms 后 30 秒或音频结尾，以较早者为准。
                                example: 15000
                              strength:
                                anyOf:
                                  - enum:
                                      - low
                                      - medium
                                      - high
                                      - xhigh
                                    type: string
                                  - type: 'null'
                                default: null
                                description: 参考风格强度：从 `low` 到 `xhigh` 逐渐增强。
                                example: medium
                            required:
                              - audio_url
                            type: object
                          - type: 'null'
                        default: null
                        description: 本段的参考音频；第一段的参考会影响后续所有段落。
                        example:
                          audio_url: >-
                            https://storage.googleapis.com/falserverless/example_outputs/elevenlabs/music_generated.mp3
                          end_ms: 15000
                          start_ms: 0
                    required:
                      - text
                      - duration_ms
                      - positive_styles
                    type: object
                  maxItems: 30
                  minItems: 1
                  type: array
                  example:
                    - duration_ms: 15000
                      positive_styles:
                        - ambient
                      text: '[Intro]'
              required:
                - chunks
              type: object
            - type: 'null'
          default: null
          description: 分段创作计划；与 prompt 互斥。每段可指定歌词、风格和参考音频。
          example:
            chunks:
              - duration_ms: 15000
                positive_styles:
                  - ambient
                text: '[Intro]'
        music_length_ms:
          anyOf:
            - maximum: 600000
              minimum: 3000
              type: integer
            - type: 'null'
          default: null
          description: >-
            歌曲时长，单位毫秒，范围 3000–600000。仅用于 prompt
            模式；省略时由模型决定。费用按实际输出音频时长向上取整到分钟计算。
          example: 30000
        force_instrumental:
          default: false
          description: 仅用于 prompt 模式。true 保证纯音乐；false 由提示词决定是否包含人声。
          type: boolean
          example: true
        seed:
          anyOf:
            - maximum: 2147483647
              minimum: 0
              type: integer
            - type: 'null'
          default: null
          description: 仅用于 composition_plan 模式的随机种子，不保证完全复现。
          example: 42
        output_format:
          default: auto
          description: 音频输出格式；auto 采用 mp3_48000_192，不因签名改变指定格式。
          enum:
            - auto
            - mp3_22050_32
            - mp3_44100_32
            - mp3_44100_64
            - mp3_44100_96
            - mp3_44100_128
            - mp3_44100_192
            - pcm_8000
            - pcm_16000
            - pcm_22050
            - pcm_24000
            - pcm_44100
            - pcm_48000
            - ulaw_8000
            - alaw_8000
            - opus_48000_32
            - opus_48000_64
            - opus_48000_96
            - opus_48000_128
            - opus_48000_192
            - mp3_24000_48
            - mp3_48000_128
            - mp3_48000_192
            - mp3_48000_240
            - mp3_48000_320
            - pcm_32000
          type: string
          example: mp3_48000_192
        enable_safety_checker:
          anyOf:
            - type: boolean
            - type: 'null'
          default: null
          description: 是否检查输入内容安全；关闭需服务账户具备相应权限。
          example: true
        timestamps:
          anyOf:
            - type: boolean
            - type: 'null'
          default: null
          description: |-
            是否请求歌词词级时间戳；省略或 null 不指定该控制。

            > 非必须不要传这个参数。
          x-advanced: true
          example: true
        sign_with_c2pa:
          default: false
          description: 为 MP3 添加内容来源签名，仅限 MP3（含 auto）。
          type: boolean
          example: false
      additionalProperties: false
    TaskResponse:
      type: object
      properties:
        created:
          type: integer
          description: 任务创建时间戳
          example: 1757165031
        id:
          type: string
          description: 任务ID
          example: task-unified-1757165031-uyujaw3d
        model:
          type: string
          description: 实际使用的模型名称
        object:
          type: string
          description: 任务的具体类型
          enum:
            - audio.generation.task
        progress:
          type: integer
          description: 任务进度百分比 (0-100)
          minimum: 0
          maximum: 100
          example: 0
        status:
          type: string
          description: 任务状态
          enum:
            - pending
            - processing
            - completed
            - failed
          example: pending
        task_info:
          type: object
          description: 异步任务信息
          properties:
            can_cancel:
              type: boolean
              description: 任务是否可以取消
              example: true
            estimated_time:
              type: integer
              description: 预计完成时间（秒）
              example: 45
        type:
          type: string
          description: 任务的输出类型
          enum:
            - audio
          example: audio
    ErrorResponse400:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              example: 请求格式错误
            type:
              type: string
              example: invalid_request_error
    ErrorResponse401:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              example: API密钥无效
            type:
              type: string
              example: authentication_error
    ErrorResponse402:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              example: 账户余额不足
            type:
              type: string
              example: insufficient_quota
    ErrorResponse422:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              example: 参数校验失败
            type:
              type: string
              example: validation_error
    ErrorResponse429:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              example: 请求频率超限
            type:
              type: string
              example: rate_limit_error
    ErrorResponse500:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              example: 服务器内部错误
            type:
              type: string
              example: server_error
    ErrorResponse503:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              example: 服务暂不可用，请稍后重试
            type:
              type: string
              example: service_unavailable
  responses:
    TaskCreated:
      description: 任务创建成功
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/TaskResponse'
    BadRequest:
      description: 请求格式错误
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse400'
    Unauthorized:
      description: 未授权
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse401'
    PaymentRequired:
      description: 余额不足
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse402'
    UnprocessableEntity:
      description: 参数校验失败
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse422'
    TooManyRequests:
      description: 请求频率超限
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse429'
    InternalServerError:
      description: 服务器内部错误
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse500'
    ServiceUnavailable:
      description: 服务暂不可用
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse503'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: |
        ## 所有接口均需要使用Bearer Token进行认证 ##

        使用时在请求头中添加：

        `Authorization: Bearer YOUR_API_KEY`

````

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