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

# Music Generation (Beta)

> Generates music using the requested model and provider settings.

Creates an asynchronous music generation job.

Poll completion with `GET /music/generate/{music_id}`.

## Request Shape

```json theme={null}
{
  "model": "suno/v4.5plus",
  "prompt": "Warm jazz trio with brushed drums",
  "duration": 8,
  "provider": { "only": ["suno"] },
  "suno": {
    "customMode": false,
    "instrumental": false
  }
}
```

## Suno Options

* `suno.customMode` (boolean, default `false`)
* `suno.instrumental` (boolean, default `false`)
* `suno.prompt` (optional override for top-level `prompt`)
* `suno.style`, `suno.title` (required when `customMode = true`)
* `suno.personaId`, `suno.personaModel`
* `suno.negativeTags`, `suno.vocalGender`
* `suno.styleWeight`, `suno.weirdnessConstraint`, `suno.audioWeight`

## Validation Rules

* When `customMode = false`, `prompt` is required.
* When `customMode = true`, both `style` and `title` are required.
* When `customMode = true` and `instrumental = false`, `prompt` is required.

Validation errors return `400` with:

```json theme={null}
{
  "error": "validation_error",
  "reason": "..."
}
```

## Response

```json theme={null}
{
  "id": "task_123",
  "object": "music",
  "status": "in_progress",
  "provider": "suno",
  "model": "V4_5PLUS",
  "nativeResponseId": "task_123",
  "usage": {
    "requests": 1
  }
}
```

`usage` can include `output_audio_seconds` when `duration` is provided and pricing is computed against seconds.


## OpenAPI

````yaml POST /music/generate
openapi: 3.0.3
info:
  title: AI Stats Gateway API
  description: >-
    A gateway API for accessing various AI models with OpenAI-compatible
    endpoints.
  version: 1.0.0
  contact:
    name: AI Stats
    url: https://docs.ai-stats.phaseo.app
    email: danielbutler500@gmail.com
servers:
  - url: https://api.phaseo.app/v1
security:
  - BearerAuth: []
tags:
  - name: Gateway
    description: Core AI Stats Gateway operations.
paths:
  /music/generate:
    post:
      tags:
        - Gateway
      summary: Generate music
      description: Generates music using the requested model and provider settings.
      operationId: generateMusic
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MusicGenerateRequest'
      responses:
        '200':
          description: Music generation response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MusicGenerateResponse'
components:
  schemas:
    MusicGenerateRequest:
      type: object
      required:
        - model
      properties:
        model:
          type: string
        prompt:
          type: string
        duration:
          type: integer
        format:
          type: string
          enum:
            - mp3
            - wav
            - ogg
            - aac
        provider:
          $ref: '#/components/schemas/ProviderRoutingOptions'
        suno:
          type: object
          properties:
            prompt:
              type: string
            style:
              type: string
            title:
              type: string
            customMode:
              type: boolean
            instrumental:
              type: boolean
            personaId:
              type: string
            model:
              type: string
            negativeTags:
              type: string
            vocalGender:
              type: string
              enum:
                - m
                - f
            styleWeight:
              type: number
              minimum: 0
              maximum: 1
            weirdnessConstraint:
              type: number
              minimum: 0
              maximum: 1
            audioWeight:
              type: number
              minimum: 0
              maximum: 1
            callBackUrl:
              type: string
              format: uri
        elevenlabs:
          type: object
          properties:
            prompt:
              type: string
            composition_plan:
              type: object
            music_length_ms:
              type: integer
            model_id:
              type: string
            force_instrumental:
              type: boolean
            store_for_inpainting:
              type: boolean
            with_timestamps:
              type: boolean
            sign_with_c2pa:
              type: boolean
            output_format:
              type: string
        echo_upstream_request:
          type: boolean
        debug:
          $ref: '#/components/schemas/DebugOptions'
    MusicGenerateResponse:
      type: object
      additionalProperties: true
    ProviderRoutingOptions:
      type: object
      description: Provider routing preferences for gateway selection.
      properties:
        order:
          type: array
          items:
            type: string
        only:
          type: array
          items:
            type: string
        ignore:
          type: array
          items:
            type: string
        include_alpha:
          type: boolean
          description: Include alpha providers in routing (off by default).
    DebugOptions:
      type: object
      description: Gateway debug controls. These flags are never forwarded upstream.
      properties:
        enabled:
          type: boolean
        return_upstream_request:
          type: boolean
        return_upstream_response:
          type: boolean
        trace:
          type: boolean
        trace_level:
          type: string
          enum:
            - summary
            - full
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: Bearer token authentication

````