> ## 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.

# Gemini Format - Music Generation

> - Uses the Gemini native format generateContent endpoint to generate music via the Lyria 3 model
- Enable audio output by including `AUDIO` in `generationConfig.responseModalities`; if `TEXT` is also included, the response will additionally return text descriptions (lyrics/structure)
- Supports text prompts and image input (up to 10 images); images are used to inspire visually-driven music creation
- Duration, structure (verse/chorus/bridge), style, etc. are primarily controlled via text prompts
- `lyria-3-clip-preview`: generates fixed 30-second clips, returns MP3 by default (`audio/mpeg`)
- `lyria-3-pro-preview`: generates full songs; you can request `audio/mpeg` or `audio/wav` via `responseMimeType`, but the actual output format should be determined by the `inlineData.mimeType` in the response
- For SSE streaming output, use `/v1beta/models/{model}:streamGenerateContent?alt=sse`
- Music generation is a single-turn process; multi-turn iterative editing is not supported




## OpenAPI

````yaml openapi/en/gemini-format-music-generation.json POST /v1beta/models/{model}:generateContent
openapi: 3.1.0
info:
  title: Gemini Format - Music Generation
  version: '1.0'
servers:
  - url: https://api.aihubmax.com
security:
  - BearerAuth: []
paths:
  /v1beta/models/{model}:generateContent:
    post:
      tags:
        - Text Series > Gemini Format
      summary: Gemini Format - Music Generation
      description: >
        - Uses the Gemini native format generateContent endpoint to generate
        music via the Lyria 3 model

        - Enable audio output by including `AUDIO` in
        `generationConfig.responseModalities`; if `TEXT` is also included, the
        response will additionally return text descriptions (lyrics/structure)

        - Supports text prompts and image input (up to 10 images); images are
        used to inspire visually-driven music creation

        - Duration, structure (verse/chorus/bridge), style, etc. are primarily
        controlled via text prompts

        - `lyria-3-clip-preview`: generates fixed 30-second clips, returns MP3
        by default (`audio/mpeg`)

        - `lyria-3-pro-preview`: generates full songs; you can request
        `audio/mpeg` or `audio/wav` via `responseMimeType`, but the actual
        output format should be determined by the `inlineData.mimeType` in the
        response

        - For SSE streaming output, use
        `/v1beta/models/{model}:streamGenerateContent?alt=sse`

        - Music generation is a single-turn process; multi-turn iterative
        editing is not supported
      operationId: gemini-format-music-generation
      parameters:
        - name: model
          in: path
          required: true
          schema:
            type: string
            example: lyria-3-clip-preview
            enum:
              - lyria-3-clip-preview
              - lyria-3-pro-preview
          description: >-
            Model name. `lyria-3-clip-preview` generates 30-second clips
            (default MP3 / `audio/mpeg`). `lyria-3-pro-preview` generates full
            songs; you can request `audio/mpeg` or `audio/wav`, but the actual
            output format should be determined by the returned
            `inlineData.mimeType`
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MusicGenerationRequest'
            examples:
              text-to-music:
                summary: Text-to-music (basic)
                description: >-
                  Generate a music clip from a text prompt, returns audio + text
                  (lyrics/structure description)
                value:
                  contents:
                    - role: user
                      parts:
                        - text: >-
                            Create a 30-second upbeat folk song using guitar and
                            harmonica.
                  generationConfig:
                    responseModalities:
                      - AUDIO
                      - TEXT
              full-song:
                summary: Full song (with structure)
                description: >-
                  Use Lyria 3 Pro to generate a full song with verse/chorus
                  structure (change the model in the path to
                  lyria-3-pro-preview)
                value:
                  contents:
                    - role: user
                      parts:
                        - text: >-
                            Create a 3-minute indie pop song in C major, 120
                            BPM.


                            [Intro] Soft piano arpeggios

                            [Verse 1] Gentle vocals with acoustic guitar

                            [Chorus] Full band arrangement, drums and bass join
                            in, uplifting melody

                            [Verse 2] Add subtle synth layers

                            [Chorus] Repeat, add harmonies

                            [Outro] Piano fade out
                  generationConfig:
                    responseModalities:
                      - AUDIO
                      - TEXT
              wav-output:
                summary: WAV format output (Pro only)
                description: >-
                  Use Lyria 3 Pro to generate music in WAV format (change the
                  model in the path to lyria-3-pro-preview)
                value:
                  contents:
                    - role: user
                      parts:
                        - text: >-
                            An atmospheric ambient track with ethereal synth
                            pads and gentle rain sounds.
                  generationConfig:
                    responseModalities:
                      - AUDIO
                      - TEXT
                    responseMimeType: audio/wav
              image-to-music:
                summary: Image-driven music (image-to-music)
                description: >-
                  Upload an image + text description; the model generates music
                  based on the image's colors, mood, and atmosphere
                value:
                  contents:
                    - role: user
                      parts:
                        - text: >-
                            Based on the colors and atmosphere of this image,
                            create an atmospheric ambient piece.
                        - inlineData:
                            mimeType: image/jpeg
                            data: BASE64_ENCODED_IMAGE_DATA
                  generationConfig:
                    responseModalities:
                      - AUDIO
                      - TEXT
      responses:
        '200':
          $ref: '#/components/responses/MusicGenerationSuccess'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/PaymentRequired'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  schemas:
    MusicGenerationRequest:
      type: object
      required:
        - contents
        - generationConfig
      properties:
        contents:
          type: array
          description: >-
            Content list. Music generation is a single-turn process; multi-turn
            iterative editing is not supported
          items:
            type: object
            required:
              - role
              - parts
            properties:
              role:
                type: string
                description: Role of the message sender
                enum:
                  - user
                  - model
              parts:
                type: array
                description: >-
                  List of content parts. Supports text and images (up to 10);
                  images are used for visually-inspired music creation
                items:
                  type: object
                  properties:
                    text:
                      type: string
                      description: >-
                        Text content (music generation prompt describing style,
                        instruments, mood, BPM, structure, lyrics, etc.)
                    inlineData:
                      type: object
                      description: >-
                        Image inline data (base64 encoded). The model generates
                        music based on the image's colors, mood, and atmosphere.
                        Supports up to 10 images.
                      required:
                        - mimeType
                        - data
                      properties:
                        mimeType:
                          type: string
                          description: Image MIME type
                          enum:
                            - image/jpeg
                            - image/png
                        data:
                          type: string
                          description: Base64 encoded image data
        systemInstruction:
          type: object
          description: >-
            System instruction. Lyria 3 model support for this field is not
            confirmed by official documentation; it may not take effect
          properties:
            parts:
              type: array
              description: System instruction content parts
              items:
                type: object
                properties:
                  text:
                    type: string
                    description: System instruction text
        generationConfig:
          type: object
          description: >-
            Generation config; `responseModalities` must include `AUDIO` for
            music generation requests
          required:
            - responseModalities
          properties:
            responseModalities:
              type: array
              description: >-
                Response modalities. Must include `AUDIO` for music generation
                requests; if `TEXT` is also included, text descriptions will be
                returned additionally
              items:
                type: string
                enum:
                  - AUDIO
                  - TEXT
              example:
                - AUDIO
                - TEXT
            responseMimeType:
              type: string
              description: >-
                Requested output audio format. Recommended `audio/mpeg` or
                `audio/wav`; currently known that even when `audio/wav` is
                requested, the actual output may be `audio/mpeg` -- please refer
                to the `inlineData.mimeType` in the response
              enum:
                - audio/mpeg
                - audio/mp3
                - audio/wav
            temperature:
              type: number
              description: >-
                Sampling temperature. Not used in official Lyria 3 examples;
                effectiveness not confirmed
              minimum: 0
              maximum: 2
        safetySettings:
          type: array
          description: Content safety filter settings
          items:
            type: object
            properties:
              category:
                type: string
                description: Harm category
                enum:
                  - HARM_CATEGORY_HARASSMENT
                  - HARM_CATEGORY_HATE_SPEECH
                  - HARM_CATEGORY_SEXUALLY_EXPLICIT
                  - HARM_CATEGORY_DANGEROUS_CONTENT
              threshold:
                type: string
                description: Blocking threshold
                enum:
                  - BLOCK_NONE
                  - BLOCK_LOW_AND_ABOVE
                  - BLOCK_MEDIUM_AND_ABOVE
                  - BLOCK_ONLY_HIGH
    MusicGenerationResponse:
      type: object
      properties:
        candidates:
          type: array
          description: List of generation result candidates
          items:
            type: object
            properties:
              content:
                type: object
                description: Generated content
                properties:
                  parts:
                    type: array
                    description: >-
                      Content parts, may contain text (lyrics/structure
                      description) and audio; the actual audio MIME type should
                      be determined by `inlineData.mimeType`
                    items:
                      type: object
                      properties:
                        text:
                          type: string
                          description: >-
                            Generated text content (lyrics, song structure
                            description)
                          example: >-
                            Here is an upbeat folk song featuring guitar and
                            harmonica.
                        inlineData:
                          type: object
                          description: Generated audio data
                          properties:
                            mimeType:
                              type: string
                              description: >-
                                Audio MIME type; actual return is typically
                                `audio/mpeg` or `audio/wav`
                              example: audio/mpeg
                            data:
                              type: string
                              description: Base64 encoded audio data
                              example: SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4...
                  role:
                    type: string
                    description: Response role
                    enum:
                      - model
              finishReason:
                type: string
                description: Reason for generation stop
                enum:
                  - STOP
                  - MAX_TOKENS
                  - SAFETY
                  - RECITATION
                  - OTHER
                example: STOP
              safetyRatings:
                type: array
                description: Safety ratings for the generated content
                items:
                  type: object
                  properties:
                    category:
                      type: string
                      description: Harm category
                    probability:
                      type: string
                      description: Probability level
        usageMetadata:
          type: object
          description: Token usage statistics
          properties:
            promptTokenCount:
              type: integer
              description: Prompt token count
              example: 15
            candidatesTokenCount:
              type: integer
              description: Candidates token count
              example: 200
            totalTokenCount:
              type: integer
              description: Total token count
              example: 215
    ErrorResponse400:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              example: Invalid request parameters
            type:
              type: string
              description: Error type; not all errors return this field
              example: http_error
            code:
              description: Error code; may be an HTTP numeric code or a string error code
              oneOf:
                - type: integer
                  example: 400
                - type: string
                  example: http_400
            status:
              type: string
              description: Gemini-style status code; not all errors return this field
              example: INVALID_ARGUMENT
    ErrorResponse401:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              example: Invalid API Key
            type:
              type: string
              description: Error type; not all errors return this field
              example: authentication_error
            code:
              description: Error code; may be an HTTP numeric code or a string error code
              oneOf:
                - type: integer
                  example: 401
                - type: string
                  example: http_401
            status:
              type: string
              description: Gemini-style status code; not all errors return this field
              example: UNAUTHENTICATED
    ErrorResponse403:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              example: Access denied
            type:
              type: string
              description: Error type; not all errors return this field
              example: permission_error
            code:
              description: Error code; may be an HTTP numeric code or a string error code
              oneOf:
                - type: integer
                  example: 403
                - type: string
                  example: http_403
            status:
              type: string
              description: Gemini-style status code; not all errors return this field
              example: PERMISSION_DENIED
    ErrorResponse429:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              example: Rate limit exceeded
            type:
              type: string
              description: Error type; not all errors return this field
              example: rate_limit_error
            code:
              description: Error code; may be an HTTP numeric code or a string error code
              oneOf:
                - type: integer
                  example: 429
                - type: string
                  example: http_429
            status:
              type: string
              description: Gemini-style status code; not all errors return this field
              example: RESOURCE_EXHAUSTED
    ErrorResponse500:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              example: Internal server error
            type:
              type: string
              description: Error type; not all errors return this field
              example: server_error
            code:
              description: Error code; may be an HTTP numeric code or a string error code
              oneOf:
                - type: integer
                  example: 500
                - type: string
                  example: http_500
            status:
              type: string
              description: Gemini-style status code; not all errors return this field
              example: UNKNOWN
  responses:
    MusicGenerationSuccess:
      description: Music generation response
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/MusicGenerationResponse'
    BadRequest:
      description: Bad request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse400'
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse401'
    PaymentRequired:
      description: Insufficient balance
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse400'
    Forbidden:
      description: Forbidden
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse403'
    TooManyRequests:
      description: Too many requests
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse429'
    InternalServerError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse500'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: |
        ## All endpoints require Bearer Token authentication ##

        Add the following to your request headers:

        `Authorization: Bearer YOUR_API_KEY`

````