Skip to content

feat(asset-gen): add MiniMax music-generation audio provider - #1301

Open
octo-patch wants to merge 1 commit into
CoplayDev:betafrom
octo-patch:octo/20260730-music-generation-tool-recvqcneE7EJMr
Open

feat(asset-gen): add MiniMax music-generation audio provider#1301
octo-patch wants to merge 1 commit into
CoplayDev:betafrom
octo-patch:octo/20260730-music-generation-tool-recvqcneE7EJMr

Conversation

@octo-patch

@octo-patch octo-patch commented Jul 30, 2026

Copy link
Copy Markdown

Reason: The asset-gen provider registry generates background music through the existing audio provider only, with no MiniMax music-generation integration.

What this adds

Registers a MiniMax audio provider for background-music generation in the asset-gen provider chain, so generate_audio can target it the same way as the existing audio provider.

  • MiniMaxAudioAdapter — a new IAudioProviderAdapter for the synchronous /v1/music_generation endpoint. Because the endpoint returns the result inline in a single response (no task id or poll endpoint), the request runs in SubmitAsync and PollAsync returns the stored result immediately — the same shape the OpenRouter image adapter already uses.
    • Covers both regional hosts — global (api.minimax.io) and China (api.minimaxi.com) — selected via the MCPFORUNITY_MINIMAX_REGION env var (global default, cn for China). The key is only ever attached to the resolved region host (validated through the shared ProviderHttp.RequireHost guard).
    • Sends the JSON request body (model, prompt, is_instrumental, output_format, audio_setting) with a Bearer key and requests mp3 (an import-allowed extension).
    • Parses the response contract: base_resp.status_code == 0, data.status == 2 (completed), and data.audio — returning either a hosted URL (output_format: url) or a decoded hex payload. Error messages are scrubbed of the key.
  • AssetGenProviders — registers minimax in the Audio(id) factory and advertises a key-free minimax audio row (capabilities text, music) in List().
  • AssetGenModelCatalog — adds curated entries for the music-generation models (default first, referencing the adapter constant via the existing drift guard). These are prompt-only (the model returns a full track), so they carry no duration knob.
  • Tests — a new MiniMaxAudioAdapterTests (submit endpoint/host/key, default and override model, region selection, URL and hex results, non-zero status / in-progress / no-audio / HTTP-error failure and key redaction), plus additions to AssetGenProvidersTests and AssetGenModelCatalogTests for the registry row, factory resolution, catalog default and model list.

Checks

The changed code is Unity Editor C# under MCPForUnity/; the added EditMode tests run under the Unity Test Runner, which is not available in this environment, so no build or test command was run here.

Summary by CodeRabbit

  • New Features

    • Added MiniMax as an audio provider for music generation.
    • Supports global and China-region endpoints.
    • Added curated MiniMax music models, including free options.
    • Generated audio can be returned as an MP3 download or inline audio data.
  • Tests

    • Added coverage for provider selection, model configuration, regional routing, successful generation, and error handling.

Register a MiniMax audio provider in the asset-gen provider registry so
background music can be generated alongside the existing audio provider.
The adapter posts the synchronous /v1/music_generation endpoint, covers
the global and China regional hosts (selected via MCPFORUNITY_MINIMAX_REGION),
sends the JSON request fields, requests mp3 output, and parses the
base_resp.status_code / data.status / data.audio response, returning either
a hosted URL or a decoded hex payload. Adds curated catalog entries for the
music-generation models and unit tests covering submit, region selection,
URL and hex results, and error/redaction paths.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2d47ae5a-9592-4aec-8bb1-4fa887334a9d

📥 Commits

Reviewing files that changed from the base of the PR and between fc70dda and e1d2763.

📒 Files selected for processing (8)
  • MCPForUnity/Editor/Services/AssetGen/AssetGenModelCatalog.cs
  • MCPForUnity/Editor/Services/AssetGen/Providers/AssetGenProviders.cs
  • MCPForUnity/Editor/Services/AssetGen/Providers/MiniMaxAudioAdapter.cs
  • MCPForUnity/Editor/Services/AssetGen/Providers/MiniMaxAudioAdapter.cs.meta
  • TestProjects/UnityMCPTests/Assets/Tests/EditMode/AssetGen/AssetGenModelCatalogTests.cs
  • TestProjects/UnityMCPTests/Assets/Tests/EditMode/AssetGen/AssetGenProvidersTests.cs
  • TestProjects/UnityMCPTests/Assets/Tests/EditMode/AssetGen/MiniMaxAudioAdapterTests.cs
  • TestProjects/UnityMCPTests/Assets/Tests/EditMode/AssetGen/MiniMaxAudioAdapterTests.cs.meta

📝 Walkthrough

Walkthrough

Added MiniMax music generation support with regional endpoints, curated models, provider registration, URL or hex audio results, and EditMode tests covering success and failure paths.

Changes

MiniMax audio generation

Layer / File(s) Summary
Adapter request and result flow
MCPForUnity/Editor/Services/AssetGen/Providers/MiniMaxAudioAdapter.cs, MCPForUnity/Editor/Services/AssetGen/Providers/MiniMaxAudioAdapter.cs.meta
Adds MiniMax request submission, region selection, response parsing, hex decoding, immediate polling, and MP3 result handling.
Provider registry and model catalog
MCPForUnity/Editor/Services/AssetGen/Providers/AssetGenProviders.cs, MCPForUnity/Editor/Services/AssetGen/AssetGenModelCatalog.cs
Registers minimax as an audio provider with music capability and adds four curated MiniMax audio models.
Validation coverage
TestProjects/UnityMCPTests/Assets/Tests/EditMode/AssetGen/*MiniMax*, TestProjects/UnityMCPTests/Assets/Tests/EditMode/AssetGen/AssetGenModelCatalogTests.cs, TestProjects/UnityMCPTests/Assets/Tests/EditMode/AssetGen/AssetGenProvidersTests.cs
Tests provider discovery, catalog consistency, regional requests, model overrides, audio result formats, failures, and API-key redaction.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Suggested labels: enhancement

Suggested reviewers: scriptwonder

Sequence Diagram(s)

sequenceDiagram
  participant AudioGenRequest
  participant MiniMaxAudioAdapter
  participant MiniMaxMusicAPI
  participant ProviderPollResult
  AudioGenRequest->>MiniMaxAudioAdapter: SubmitAsync request
  MiniMaxAudioAdapter->>MiniMaxMusicAPI: POST music_generation with model and prompt
  MiniMaxMusicAPI-->>MiniMaxAudioAdapter: URL or hex audio response
  MiniMaxAudioAdapter->>ProviderPollResult: PollAsync returns audio result
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a MiniMax music-generation audio provider.
Description check ✅ Passed The description covers the main changes, testing note, and implementation details, with only a few template fields left partially filled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant