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

# 生成音乐

> 通过文字提示词或者自定义歌词生成音乐，**注：每次请求生成一首音乐**



## OpenAPI

````yaml openapi/cn/flowmuisc.json POST /flowmusic/v1/generations
openapi: 3.1.0
info:
  title: Flowmusic API DOCS
  version: 1.0.0
  description: TTAPI Flowmusic API 接口服务，目前集成了市场上最为领先的音乐大模型。
servers:
  - url: https://api.ttapi.io
security: []
paths:
  /flowmusic/v1/generations:
    post:
      description: 通过文字提示词或者自定义歌词生成音乐，**注：每次请求生成一首音乐**
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GenerateRequest1'
      responses:
        '200':
          $ref: '#/components/responses/SuccessResponse'
        '400':
          $ref: '#/components/responses/400Response'
        '401':
          $ref: '#/components/responses/401Response'
      security:
        - CustomApiKey: []
components:
  schemas:
    GenerateRequest1:
      type: object
      properties:
        title:
          type: string
          description: 生成音乐标题
        model:
          type: string
          description: 音乐模型名称,为空时默认使用 Lyria 3 Pro
          default: Lyria 3 Pro
        sound_prompt:
          type: string
          description: 音乐风格或声音描述提示词；和 lyrics 不允许同时为空
        lyrics:
          type: string
          description: 歌词文本；和 sound_prompt 不允许同时为空
        seed:
          type: string
          description: 随机种子
        bpm:
          type: string
          description: BPM，必须大于等于 1
        length:
          type: integer
          description: 生成音乐时长，单位秒；允许为空，范围 1 到 240
          minimum: 1
          maximum: 240
        hook_url:
          type: string
          description: 任务完成后的业务回调地址；为空时不推送回调
      required: []
  responses:
    SuccessResponse:
      description: 请求成功
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                example: SUCCESS
              message:
                type: string
                example: success
              data:
                type: object
                example:
                  jobId: jobId
            required:
              - status
              - message
              - data
    400Response:
      description: 参数错误
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                example: FAILED
              message:
                type: string
                example: '"prompt" cannot be empty.'
              data:
                type: object
            required:
              - status
              - message
    401Response:
      description: 授权失败
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                example: FAILED
              message:
                type: string
                example: Wrong TT-API-KEY or email is not activated.
            required:
              - status
              - message
  securitySchemes:
    CustomApiKey:
      type: apiKey
      in: header
      name: TT-API-KEY
      description: >-
        请前往 <a href='https://dashboard.ttapi.io' target='_blank'>TTAPI 控制台</a>
        获取 API 密钥。

````