> ## 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 and a caller-specified duration.
Returns a streaming NDJSON response with 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: []
tags:
  - description: Comfy Router's canonical, model-ID-addressed routes.
    name: Comfy Router
  - description: >-
      Signed-in users running Comfy-owned serverless apps with free runs and
      flat or per-second pricing (FE-2737).
    name: App Proxy
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 and a caller-specified
        duration.

        Returns a streaming NDJSON response with 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
        '402':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SoniloErrorResponse'
          description: Payment Required - Insufficient funds
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SoniloErrorResponse'
          description: Unprocessable Entity - Validation error
        '429':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SoniloErrorResponse'
          description: >-
            Too Many Requests - Rate limited. Also answered when the caller's
            in-flight committed partner spend has reached its ceiling; that
            refusal says so in its message and carries the
            `X-Committed-Spend-Limit`, `X-Committed-Spend-Current` and
            `X-Committed-Spend-Remaining` headers (USD cents).
        '502':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SoniloErrorResponse'
          description: Bad Gateway - Upstream generation error
      security:
        - BearerAuth: []
        - ApiKeyAuth: []
components:
  schemas:
    SoniloTextToMusicRequest:
      properties:
        duration:
          description: Desired duration of the output track in seconds.
          maximum: 360
          minimum: 1
          type: integer
        prompt:
          description: >-
            Text prompt describing the desired music. Max length 1000
            characters.
          maxLength: 1000
          minLength: 1
          type: string
      required:
        - prompt
        - duration
      type: object
    SoniloStreamEvent:
      description: >-
        A single NDJSON event from the Sonilo streaming response. Additional
        event types beyond those listed may appear; unknown types should be
        ignored by clients.
      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
            summary:
              description: Short natural-language description of the generated track.
              type: string
            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:
            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
      description: >-
        Bearer token authentication. Normally a Firebase or Cloud JWT. A
        'comfyui-' prefixed API key is also accepted in this header: the prefix
        classifies the value as an API key and it is validated exactly as if it
        had been sent in X-API-Key.

        Accepted on the operations served by the comfyFirebase auth middleware
        (BE-9720, parity with ingest).
      scheme: bearer
      type: http
    ApiKeyAuth:
      description: >-
        API key authentication. Send the key in the X-API-Key header; keys are
        prefixed with 'comfyui-' and are generated from user account settings.
        The same 'comfyui-' key is also accepted in Authorization: Bearer (see
        BearerAuth), and when both headers carry a key, X-API-Key wins.

        The comfyFirebase auth middleware checks this header before falling back
        to the Authorization bearer token, and it backs both the /customers and
        the /proxy authset entries.
      in: header
      name: X-API-Key
      type: apiKey

````

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