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

# Generate music from text prompt

> Generate music from a text prompt using Sonilo text-to-music AI.
Requires a prompt describing the desired music. Duration is optional and will be inferred if not provided.
Returns a streaming NDJSON response with duration, titles, audio chunks, and completion events.




## OpenAPI

````yaml https://api.comfy.org/openapi post /proxy/sonilo/t2m/generate
openapi: 3.0.2
info:
  title: Comfy API
  version: '1.0'
servers:
  - url: https://api.comfy.org
security: []
paths:
  /proxy/sonilo/t2m/generate:
    post:
      tags:
        - Sonilo
        - Proxy
      summary: Generate music from text prompt
      description: >
        Generate music from a text prompt using Sonilo text-to-music AI.

        Requires a prompt describing the desired music. Duration is optional and
        will be inferred if not provided.

        Returns a streaming NDJSON response with duration, titles, audio chunks,
        and completion events.
      operationId: SoniloTextToMusicGenerate
      requestBody:
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/SoniloTextToMusicRequest'
        required: true
      responses:
        '200':
          content:
            application/x-ndjson:
              schema:
                $ref: '#/components/schemas/SoniloStreamEvent'
          description: OK - Streaming NDJSON response with audio generation events
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SoniloErrorResponse'
          description: Bad Request
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SoniloErrorResponse'
          description: Unauthorized - Invalid or missing API key
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SoniloErrorResponse'
          description: Internal Server Error
      security:
        - BearerAuth: []
components:
  schemas:
    SoniloTextToMusicRequest:
      properties:
        duration:
          description: Target duration in seconds. Will be inferred if not provided.
          exclusiveMinimum: true
          maximum: 360
          minimum: 0
          type: number
        prompt:
          description: Text prompt describing the desired music.
          minLength: 1
          type: string
      required:
        - prompt
      type: object
    SoniloStreamEvent:
      description: A single NDJSON event from the Sonilo streaming response.
      oneOf:
        - properties:
            copy_index:
              minimum: 0
              type: integer
            display_tags:
              items:
                type: string
              type: array
            prompt_index:
              minimum: 0
              type: integer
            stream_index:
              minimum: 0
              type: integer
            title:
              type: string
            type:
              enum:
                - title
              type: string
          required:
            - type
            - stream_index
            - prompt_index
            - copy_index
            - title
            - display_tags
          type: object
        - properties:
            channels:
              type: integer
            data:
              description: >-
                Base64-encoded AAC in fMP4 fragments; concatenate per
                stream_index.
              type: string
            num_streams:
              minimum: 1
              type: integer
            sample_rate:
              type: integer
            stream_index:
              minimum: 0
              type: integer
            type:
              enum:
                - audio_chunk
              type: string
          required:
            - type
            - sample_rate
            - channels
            - stream_index
            - num_streams
            - data
          type: object
        - properties:
            billing:
              type: number
            billing_rate_per_sec:
              type: number
            channels:
              type: integer
            duration_sec_by_stream:
              items:
                type: number
              type: array
            sample_rate:
              type: integer
            type:
              enum:
                - generated_audio
              type: string
          required:
            - type
            - sample_rate
            - channels
            - duration_sec_by_stream
            - billing_rate_per_sec
            - billing
          type: object
        - properties:
            type:
              enum:
                - complete
              type: string
          required:
            - type
          type: object
        - properties:
            code:
              type: string
            message:
              type: string
            type:
              enum:
                - error
              type: string
          required:
            - type
            - message
          type: object
    SoniloErrorResponse:
      properties:
        detail:
          properties:
            code:
              description: Error code
              type: string
            message:
              description: Human-readable error message
              type: string
          type: object
      type: object
  securitySchemes:
    BearerAuth:
      bearerFormat: JWT
      scheme: bearer
      type: http

````