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

# 音楽を生成

> プロバイダーに依存しない単一のエンドポイントで音楽を生成します。Phaseo は同期プロバイダーを待機し、各プロバイダーのキュー確認を内部で処理します。

プロバイダーに依存しない1つのAPIで音楽を生成します。Phaseoが同期レスポンスとプロバイダーキューのポーリングをバックグラウンドで処理します。

生成が完了すると、レスポンスには`audio_url`または`audio_base64`が含まれます。プロバイダーが未完了のジョブを返した場合は、同じレスポンスの`id`を使って`GET /music/generate/{music_id}`を呼び出してください。

## リクエストの形式

```json theme={null}
{
  "model": "minimax/music-3.0:free",
  "prompt": "Warm jazz trio with brushed drums",
  "format": "mp3"
}
```

## Sunoのオプション

* `suno.customMode` （boolean、既定値: `false`）
* `suno.instrumental` （boolean、既定値: `false`）
* `suno.prompt` （トップレベルの`prompt`を任意で上書き）
* `suno.style`, `suno.title` （`customMode = true`の場合に必須）
* `suno.personaId`, `suno.personaModel`
* `suno.negativeTags`, `suno.vocalGender`
* `suno.styleWeight`, `suno.weirdnessConstraint`, `suno.audioWeight`

## 検証ルール

* `customMode = false`の場合、`prompt`が必要です。
* `customMode = true`の場合、`style`と`title`の両方が必要です。
* `customMode = true`かつ`instrumental = false`の場合、`prompt`が必要です。

検証エラーは`400`と次の内容を返します。

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

## 応答

```json theme={null}
{
  "id": "req_01JY6MUSIC123",
  "object": "music",
  "status": "completed",
  "provider": "gmicloud",
  "model": "minimax/music-3.0:free",
  "nativeResponseId": "5c30b275-d669-4a25-8151-de6d60214853",
  "audio_url": "https://.../generated-music.mp3",
  "usage": {
    "requests": 1,
    "output_audio_seconds": 25.364
  }
}
```

* `id` は Phaseo の固定リクエスト ID です。`GET /music/generate/{music_id}` でリクエストを取得できます。
* `nativeResponseId` は上流プロバイダーの識別子で、プロバイダーとの照合やサポート時に使用します。
* `status` は `queued`、`in_progress`、`completed`、`failed` のいずれかです。
* プロバイダーが生成時間を返す場合、`usage` に `output_audio_seconds` が含まれることがあります。


## OpenAPI

````yaml ja/openapi/v1/openapi.localized.yaml POST /music/generate
openapi: 3.0.3
info:
  title: Phaseo Gateway API
  description: OpenAI互換のエンドポイントを通じて、さまざまなAIモデルにアクセスするためのゲートウェイAPI。
  version: 1.0.0
  contact:
    name: Phaseo
    url: https://phaseo.app
    email: danielbutler500@gmail.com
servers:
  - url: https://api.phaseo.app/v1
    description: グローバルルーティング
security:
  - BearerAuth: []
tags:
  - name: Gateway
    description: Core Phaseo Gateway operations.
paths:
  /music/generate:
    post:
      tags:
        - Gateway
      summary: 音楽を生成
      description: >-
        プロバイダーに依存しない単一のエンドポイントで音楽を生成します。Phaseo
        は同期プロバイダーを待機し、各プロバイダーのキュー確認を内部で処理します。
      operationId: generateMusic
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MusicGenerateRequest'
      responses:
        '200':
          description: 音楽生成の応答
          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
      required:
        - id
        - object
        - status
        - model
        - provider
      properties:
        id:
          type: string
          description: GET /music/generate/{music_id} で使用する、安定した Phaseo リクエスト ID です。
        object:
          type: string
          enum:
            - music
        status:
          type: string
          enum:
            - queued
            - in_progress
            - completed
            - failed
        model:
          type: string
        provider:
          type: string
        nativeResponseId:
          type: string
          nullable: true
          description: 照合およびサポートに使用する上流プロバイダーの識別子です。
        audio_url:
          type: string
          format: uri
        audio_base64:
          type: string
        result:
          description: Phaseo によって正規化されたプロバイダー結果のメタデータです。
        output:
          type: array
          items:
            type: object
            additionalProperties: true
        usage:
          type: object
          additionalProperties: true
      additionalProperties: true
    ProviderRoutingOptions:
      type: object
      description: ゲートウェイでの選択に使用するプロバイダーのルーティング設定。
      properties:
        order:
          type: array
          items:
            type: string
        only:
          type: array
          items:
            type: string
        ignore:
          type: array
          items:
            type: string
        include_alpha:
          type: boolean
          description: ルーティングに alpha プロバイダーを含める（既定ではオフ）。
        allow_fallbacks:
          type: boolean
          nullable: true
          description: 失敗後に別の対象プロバイダーへフォールバックすることを許可します。
        require_parameters:
          type: boolean
          nullable: true
          description: ルーティング前に、要求されたパラメーターにプロバイダーが対応していることを必須にします。
        required_execution_region:
          type: string
          nullable: true
          description: 指定された実行リージョンに対応するプロバイダーにルーティングを限定します。
        required_data_region:
          type: string
          nullable: true
          description: 指定されたデータリージョンに対応するプロバイダーにルーティングを限定します。
        require_zero_data_retention:
          type: boolean
          nullable: true
          description: ゼロデータ保持に対応するプロバイダーにルーティングを限定します。
        data_collection:
          type: string
          nullable: true
          enum:
            - allow
            - deny
        zdr:
          type: boolean
          nullable: true
        enforce_distillable_text:
          type: boolean
          nullable: true
        quantizations:
          type: array
          nullable: true
          items:
            type: string
        sort:
          oneOf:
            - type: string
            - type: object
              additionalProperties: true
          description: このリクエストのプロバイダーを、価格、レイテンシ、スループットなどで並べ替えます。
        max_price:
          type: object
          properties:
            prompt:
              oneOf:
                - type: number
                - type: string
            completion:
              oneOf:
                - type: number
                - type: string
            image:
              oneOf:
                - type: number
                - type: string
            audio:
              oneOf:
                - type: number
                - type: string
            request:
              oneOf:
                - type: number
                - type: string
        preferred_min_throughput:
          oneOf:
            - type: number
            - type: object
              additionalProperties:
                type: number
        preferred_max_latency:
          oneOf:
            - type: number
            - type: object
              additionalProperties:
                type: number
    DebugOptions:
      type: object
      description: ゲートウェイのデバッグ設定です。これらのフラグがプロバイダーに転送されることはありません。
      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 トークンによる認証

````

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