MiniMax Music Generation
Generate AI music using MiniMax Music 2.5 API.
Prerequisites
Set the MINIMAX_API_KEY environment variable:
CODEBLOCK0
Quick Start
CODEBLOCK1
Music Generation Parameters
| Parameter | Description | Default |
|---|
| INLINECODE1 | Music style description (required) | - |
| INLINECODE2 |
Lyrics text with [Verse], [Chorus] markers | - |
|
--lyrics-file | Path to lyrics file | - |
|
--instrumental | Generate instrumental music (no vocals) | false |
|
--sample-rate | Audio quality: 44100, 48000 | 44100 |
|
--bitrate | Audio bitrate: 128000, 256000, 320000 | 256000 |
|
--format | Output format: mp3, wav, flac | mp3 |
|
--download | Directory to save audio file | - |
|
--model | Model ID | music-2.5 |
Prompt Examples
Instrumental Music
CODEBLOCK2
Songs with Lyrics
CODEBLOCK3
Lyrics Format
Use section markers to structure the song:
CODEBLOCK4
Daily Quota
MiniMax Token Plan subscriptions include:
- - music-2.5: 7 generations/day (Plan 199)
- Quota resets daily at midnight
Sending Audio via Feishu
After generating music, send to user's Feishu:
CODEBLOCK5
Rules
- 1. Always check
MINIMAX_API_KEY is set before API calls. - Use
--instrumental for pure music without vocals. - Default to 44100 Hz, 256 kbps, MP3 format for good quality and compatibility.
- Download immediately - audio URLs expire after some time.
- Respect daily quota - inform user if they've hit their limit.
- Provide audio file to user after generation (download + share via Feishu if applicable).
MiniMax 音乐生成
使用 MiniMax Music 2.5 API 生成 AI 音乐。
前置条件
设置 MINIMAXAPIKEY 环境变量:
bash
export MINIMAXAPIKEY=your-api-key-here
快速开始
bash
生成纯音乐
python3 ~/.openclaw/workspace/skills/minimax-music/scripts/minimax_music.py create \
--prompt 钢琴,放松,冥想 \
--instrumental \
--download ~/Music
生成带歌词的歌曲
python3 ~/.openclaw/workspace/skills/minimax-music/scripts/minimax_music.py create \
--prompt 流行,欢快,庆祝 \
--lyrics [主歌]\n阳光洒满大地\n[副歌]\n快乐每一天 \
--download ~/Music
先生成歌词
python3 ~/.openclaw/workspace/skills/minimax-music/scripts/minimax_music.py lyrics \
--prompt 一首关于春天的歌 \
--output lyrics.txt
音乐生成参数
| 参数 | 描述 | 默认值 |
|---|
| --prompt | 音乐风格描述(必填) | - |
| --lyrics |
带[主歌]、[副歌]标记的歌词文本 | - |
| --lyrics-file | 歌词文件路径 | - |
| --instrumental | 生成纯音乐(无人声) | false |
| --sample-rate | 音频质量:44100, 48000 | 44100 |
| --bitrate | 音频比特率:128000, 256000, 320000 | 256000 |
| --format | 输出格式:mp3, wav, flac | mp3 |
| --download | 保存音频文件的目录 | - |
| --model | 模型 ID | music-2.5 |
提示词示例
纯音乐
放松钢琴
--prompt 钢琴,放松,冥想,柔和,氛围
电子氛围
--prompt 电子,氛围,环境,合成器,轻松
管弦乐
--prompt 管弦乐,电影感,史诗,弦乐,铜管
爵士乐
--prompt 爵士,流畅,萨克斯,钢琴,夜店
带歌词的歌曲
bash
中文流行
--prompt 华语流行,情感,抒情 \
--lyrics [主歌]\n夜深人静\n思念着你\n[副歌]\n心中的爱\n永不改变
英文流行
--prompt 流行,欢快,充满活力 \
--lyrics [主歌]\n走在街上\n感受节拍\n[副歌]\n今晚一起庆祝
歌词格式
使用段落标记来组织歌曲结构:
[前奏]
(器乐开场)
[主歌]
主要歌词
[预副歌]
铺垫部分
[副歌]
主旋律/副歌
[桥段]
对比部分
[尾奏]
结束部分
每日配额
MiniMax Token 计划订阅包含:
- - music-2.5:每天 7 次生成(计划 199)
- 配额每天零点重置
通过飞书发送音频
生成音乐后,发送给用户的飞书:
python
import requests
1. 上传音频文件
with open(music.mp3, rb) as f:
upload_resp = requests.post(
https://open.feishu.cn/open-apis/im/v1/files,
headers={Authorization: fBearer {TENANT
ACCESSTOKEN}},
files={file: (music.mp3, f, audio/mpeg)},
data={file
type: stream, filename: music.mp3}
)
file
key = uploadresp.json()[data][file_key]
2. 发送文件消息
requests.post(
https://open.feishu.cn/open-apis/im/v1/messages?receive
idtype=open_id,
headers={Authorization: fBearer {TENANT
ACCESSTOKEN}, Content-Type: application/json},
json={
msg_type: file,
content: json.dumps({file
key: filekey}),
receive
id: USEROPEN_ID
}
)
规则
- 1. 始终检查 API 调用前是否设置了 MINIMAXAPIKEY。
- 使用 --instrumental 生成无人声的纯音乐。
- 默认使用 44100 Hz、256 kbps、MP3 格式,以获得良好的质量和兼容性。
- 立即下载 - 音频 URL 会在一段时间后过期。
- 尊重每日配额 - 如果用户已达到限制,请告知用户。
- 生成后提供音频文件给用户(下载并通过飞书分享,如适用)。