Minimax Tools Skill
Direct MiniMax API integration for speech synthesis (TTS), voice cloning, image generation, video generation, and music generation using local Python scripts instead of MCP. Use when you want reliable script-based MiniMax workflows inside OpenClaw for: (1) text-to-speech with built-in Chinese/English defaults or explicit voice IDs, (2) voice cloning with upload + preview flows, (3) text-to-image or reference-image generation, (4) text-to-video, image-to-video, or first/last-frame video generatio
Choose how to use this skill
You do not need every option. Choose the path your AI client supports. The stable page stays the same; versioned files are immutable.
1. Native installer
This listing has no registered native installer command. Use the complete package or source fallback below, depending on what your client supports.
Do not guess an installer command or replace an existing version without reviewing the diff.
2. Complete package recommended
Download the ZIP when available. It includes SKILL.md plus the references, security notes and version metadata.
No complete ProSkills package is published for this listing yet.3. Prompt-only
Copy the prompt above when the agent can read the stable page or when you want to adopt the workflow without installing a skill.
Need only the instruction file?
Download SKILL.md only if your client requires a single file. The complete ZIP is safer for a full installation because it preserves the references and release context.
No path installs or executes anything by itself. Your agent still needs access to the project files. Before updating, compare the installed version and review the diff.
// RATINGS
Not yet listed on ClawHub or SkillsMP
// README
MiniMax Tools Skill
An OpenClaw skill for calling MiniMax multimodal APIs directly through local Python wrappers.
Instead of relying on the official MiniMax MCP server, this repository provides a maintained, script-first skill that is easy to use from OpenClaw, shell workflows, and local automation.
What this skill does
This skill currently supports:
-
Speech synthesis (TTS)
- synchronous TTS
- built-in default Chinese and English voices
- explicit
voice_idsupport - speed / volume / pitch / emotion controls
-
Voice cloning
- upload clone audio
- upload optional prompt audio
- create cloned voices
- optionally download preview audio (
demo_audio) - one-shot
clone-from-filesworkflow
-
Image generation
- text-to-image
- reference-image generation via
subject_reference - local image path / URL / Data URL support
-
Video generation
- text-to-video
- image-to-video
- first/last-frame video generation
- async task query / wait / download flow
-
Music generation
- prompt + lyrics song generation
- instrumental generation
- lyrics optimizer support
What is not implemented yet
At the moment, this repository does not include:
- subject-reference-to-video (
s2v) - video agent templates
- voice design
- voice listing / management helpers
- async long-text TTS wrappers
- full MiniMax file management coverage beyond what this skill needs today
Why this skill exists
MiniMax exposes a broad multimodal API surface, but not every workflow is convenient to use through raw HTTP or an aging MCP integration.
This skill is designed for:
- direct local control
- predictable file outputs
- reproducible script-based workflows
- easy reuse inside OpenClaw skills and automations
Repository structure
.
├── SKILL.md
├── README.md
├── LICENSE
├── references/
│ └── api-notes.md
└── scripts/
├── common.py
├── minimax.py
├── minimax_tts.py
├── minimax_voice.py
├── minimax_image.py
├── minimax_video.py
└── minimax_music.py
Requirements
Runtime
- Python 3
requests
Install dependency if needed:
pip install requests
Environment variables
Required:
export MINIMAX_API_KEY=your_api_key_here
Optional:
export MINIMAX_BASE_URL=https://api.minimaxi.com
Install
From ClawHub
clawhub install minimax-tools
From GitHub
Clone this repository and copy or symlink it into your OpenClaw skills/ directory.
Example:
ln -s /home/yangtao/repos/minimax-tools-skill <workspace>/skills/minimax-tools
Unified CLI
Use the single entrypoint:
python3 scripts/minimax.py <subcommand> ...
Available top-level subcommands:
ttsvoiceimagevideomusic
Quick examples
TTS with default Chinese voice
python3 scripts/minimax.py tts \
--text "你好,欢迎使用 MiniMax。"
TTS with default English voice
python3 scripts/minimax.py tts \
--text "Hello, welcome to MiniMax." \
--voice-lang en
Clone a voice in one step
python3 scripts/minimax.py voice clone-from-files \
--clone-file ./voice.wav \
--voice-id MyVoice001 \
--text "你好,欢迎使用我的复刻音色。" \
--download-demo
Text-to-image
python3 scripts/minimax.py image \
--prompt "Cyberpunk city at night, cinematic lighting, dense details" \
--aspect-ratio 16:9
Reference-image generation
python3 scripts/minimax.py image \
--prompt "Same character standing in a rainy neon street" \
--subject-reference ./character.png \
--aspect-ratio 16:9
Text-to-video
python3 scripts/minimax.py video create \
--prompt "An orange cat watching rain by the window, cinematic, soft light" \
--wait --download
Image-to-video
python3 scripts/minimax.py video i2v \
--first-frame-image ./cat.png \
--prompt "Slow push-in, the cat blinks, rain outside the window" \
--wait --download
First/last-frame video
python3 scripts/minimax.py video fl2v \
--first-frame-image ./young.jpg \
--last-frame-image ./old.jpg \
--prompt "A person slowly grows older, stable camera" \
--wait --download
Music generation
python3 scripts/minimax.py music \
--prompt "indie folk, warm, late night city walk" \
--lyrics "[Verse]\nNight wind slips across the street lights..."
TTS defaults
Current built-in defaults:
- Chinese voice:
female-tianmei - English voice:
English_Graceful_Lady - Model:
speech-2.8-turbo - Format:
mp3 - Sample rate:
32000 - Bitrate:
128000
Voice cloning constraints
Clone source audio
- formats:
mp3,m4a,wav - duration: 10 seconds to 5 minutes
- size: <= 20 MB
Prompt audio
- formats:
mp3,m4a,wav - duration: under 8 seconds
- size: <= 20 MB
MiniMax docs note that cloned voices are temporary unless used in real TTS within 7 days.
Image generation notes
The current image wrapper supports:
- text-to-image
- reference-image generation through
subject_reference
This is closer to reference-driven generation / character consistency than a full mask-based editor workflow.
Video generation notes
Video generation is asynchronous. The typical flow is:
- create a task
- query or wait for completion
- download the final file
The wrapper already supports the full create/query/wait/download path.
Output behavior
Scripts print JSON to stdout for easy automation.
Typical fields include:
oktrace_idvoice_idtask_idfile_ididpathpathsmeta
ClawHub publishing notes
This skill declares its required environment variable in SKILL.md metadata:
MINIMAX_API_KEY
That helps ClawHub understand the skill’s external requirements and reduces the chance of publish-time flagging.
License
MIT-0
// HOW IT'S BUILT
// FILES
14 files shipped with this skill. Inline text is the catalog copy. The upstream link is the source repository.
SKILL.md3.5 KB5c026dab7cceupstream ↗
--- name: minimax-tools description: "Direct MiniMax API integration for speech synthesis (TTS), voice cloning, image generation, video generation, and music generation using local Python scripts instead of MCP. Use when you want reliable script-based MiniMax workflows inside OpenClaw for: (1) text-to-speech with built-in Chinese/English defaults or explicit voice IDs, (2) voice cloning with upload + preview flows, (3) text-to-image or reference-image generation, (4) text-to-video, image-to-video, or first/last-frame video generation with async polling/download, and (5) music generation from prompts and lyrics." metadata: { "openclaw": { "requires": { "bins": ["python3"], "env": ["MINIMAX_API_KEY"] }, "primaryEnv": "MINIMAX_API_KEY", "homepage": "https://github.com/cytwyatt/minimax-tools-skill" } } --- # MiniMax Tools Use this skill to call MiniMax multimodal APIs directly through local Python wrappers instead of relying on an external MCP server. ## Overview This skill currently supports: - Speech synthesis (TTS) - Voice cloning - Image generation - Video generation - Music generation All wrappers are exposed through a single entrypoint script: ```bash python3 scripts/minimax.py <subcommand> ... ``` Read `references/api-notes.md` only when you need endpoint details or parameter reminders. ## Prerequisites Expect these environment variables to be available before running the scripts: - `MINIMAX_API_KEY` Optional: - `MINIMAX_BASE_URL` if you need to override the default API host Python dependency: - `requests` ## Routing guide - Use `tts` for speech synthesis - Use `voice` for uploading clone inputs, creating cloned voices, and optionally downloading preview audio - Use `image` for text-to-image or reference-image generation - Use `video` for text-to-video, image-to-video, or first/last-frame video workflows - Use `music` for song or instrumental generation ## TTS defaults - Default model: `speech-2.8-turbo` - Default format: `mp3` - Default sample rate: `32000` - Default bitrate: `128000` - Default Chinese voice: `female-tianmei` - Default English voice: `English_Graceful_Lady` - If `--voice` is omitted, the script uses `--voice-lang zh|en` and defaults to `zh` ## Voice cloning notes - Clone source audio constraints: - `mp3`, `m4a`, or `wav` - 10 seconds to 5 minutes - <= 20 MB - Optional prompt audio constraints: - `mp3`, `m4a`, or `wav` - under 8 seconds - <= 20 MB - If cloning succeeds, the returned `voice_id` can be used immediately in TTS - MiniMax documentation notes cloned voices are temporary unless used in real TTS within 7 days ## Video support Supported modes: - text-to-video: `video create` - image-to-video: `video i2v` - first/last-frame video: `video fl2v` Video creation is asynchronous. Use `video query`, `video wait`, and `video download` for task follow-up. ## File handling rules - Prefer saving outputs locally and returning file paths - Local image inputs for image/video wrappers can be converted to Data URLs automatically - Prefer URL-based output when MiniMax returns temporary files, then download immediately - Avoid tight polling loops for async video jobs ## Resources - `scripts/minimax.py` - unified CLI entrypoint - `scripts/minimax_tts.py` - TTS wrapper - `scripts/minimax_voice.py` - voice cloning wrapper - `scripts/minimax_image.py` - image generation wrapper - `scripts/minimax_video.py` - video generation wrapper - `scripts/minimax_music.py` - music generation wrapper - `references/api-notes.md` - focused API notes and constraintsREADME.md5.9 KB31737b082802upstream ↗
# MiniMax Tools Skill An OpenClaw skill for calling MiniMax multimodal APIs directly through local Python wrappers. Instead of relying on the official MiniMax MCP server, this repository provides a maintained, script-first skill that is easy to use from OpenClaw, shell workflows, and local automation. ## What this skill does This skill currently supports: - **Speech synthesis (TTS)** - synchronous TTS - built-in default Chinese and English voices - explicit `voice_id` support - speed / volume / pitch / emotion controls - **Voice cloning** - upload clone audio - upload optional prompt audio - create cloned voices - optionally download preview audio (`demo_audio`) - one-shot `clone-from-files` workflow - **Image generation** - text-to-image - reference-image generation via `subject_reference` - local image path / URL / Data URL support - **Video generation** - text-to-video - image-to-video - first/last-frame video generation - async task query / wait / download flow - **Music generation** - prompt + lyrics song generation - instrumental generation - lyrics optimizer support ## What is not implemented yet At the moment, this repository does **not** include: - subject-reference-to-video (`s2v`) - video agent templates - voice design - voice listing / management helpers - async long-text TTS wrappers - full MiniMax file management coverage beyond what this skill needs today ## Why this skill exists MiniMax exposes a broad multimodal API surface, but not every workflow is convenient to use through raw HTTP or an aging MCP integration. This skill is designed for: - direct local control - predictable file outputs - reproducible script-based workflows - easy reuse inside OpenClaw skills and automations ## Repository structure ```text . ├── SKILL.md ├── README.md ├── LICENSE ├── references/ │ └── api-notes.md └── scripts/ ├── common.py ├── minimax.py ├── minimax_tts.py ├── minimax_voice.py ├── minimax_image.py ├── minimax_video.py └── minimax_music.py ``` ## Requirements ### Runtime - Python 3 - `requests` Install dependency if needed: ```bash pip install requests ``` ### Environment variables Required: ```bash export MINIMAX_API_KEY=your_api_key_here ``` Optional: ```bash export MINIMAX_BASE_URL=https://api.minimaxi.com ``` ## Install ### From ClawHub ```bash clawhub install minimax-tools ``` ### From GitHub Clone this repository and copy or symlink it into your OpenClaw `skills/` directory. Example: ```bash ln -s /home/yangtao/repos/minimax-tools-skill <workspace>/skills/minimax-tools ``` ## Unified CLI Use the single entrypoint: ```bash python3 scripts/minimax.py <subcommand> ... ``` Available top-level subcommands: - `tts` - `voice` - `image` - `video` - `music` ## Quick examples ### TTS with default Chinese voice ```bash python3 scripts/minimax.py tts \ --text "你好,欢迎使用 MiniMax。" ``` ### TTS with default English voice ```bash python3 scripts/minimax.py tts \ --text "Hello, welcome to MiniMax." \ --voice-lang en ``` ### Clone a voice in one step ```bash python3 scripts/minimax.py voice clone-from-files \ --clone-file ./voice.wav \ --voice-id MyVoice001 \ --text "你好,欢迎使用我的复刻音色。" \ --download-demo ``` ### Text-to-image ```bash python3 scripts/minimax.py image \ --prompt "Cyberpunk city at night, cinematic lighting, dense details" \ --aspect-ratio 16:9 ``` ### Reference-image generation ```bash python3 scripts/minimax.py image \ --prompt "Same character standing in a rainy neon street" \ --subject-reference ./character.png \ --aspect-ratio 16:9 ``` ### Text-to-video ```bash python3 scripts/minimax.py video create \ --prompt "An orange cat watching rain by the window, cinematic, soft light" \ --wait --download ``` ### Image-to-video ```bash python3 scripts/minimax.py video i2v \ --first-frame-image ./cat.png \ --prompt "Slow push-in, the cat blinks, rain outside the window" \ --wait --download ``` ### First/last-frame video ```bash python3 scripts/minimax.py video fl2v \ --first-frame-image ./young.jpg \ --last-frame-image ./old.jpg \ --prompt "A person slowly grows older, stable camera" \ --wait --download ``` ### Music generation ```bash python3 scripts/minimax.py music \ --prompt "indie folk, warm, late night city walk" \ --lyrics "[Verse]\nNight wind slips across the street lights..." ``` ## TTS defaults Current built-in defaults: - Chinese voice: `female-tianmei` - English voice: `English_Graceful_Lady` - Model: `speech-2.8-turbo` - Format: `mp3` - Sample rate: `32000` - Bitrate: `128000` ## Voice cloning constraints ### Clone source audio - formats: `mp3`, `m4a`, `wav` - duration: 10 seconds to 5 minutes - size: <= 20 MB ### Prompt audio - formats: `mp3`, `m4a`, `wav` - duration: under 8 seconds - size: <= 20 MB MiniMax docs note that cloned voices are temporary unless used in real TTS within 7 days. ## Image generation notes The current image wrapper supports: - text-to-image - reference-image generation through `subject_reference` This is closer to reference-driven generation / character consistency than a full mask-based editor workflow. ## Video generation notes Video generation is asynchronous. The typical flow is: 1. create a task 2. query or wait for completion 3. download the final file The wrapper already supports the full create/query/wait/download path. ## Output behavior Scripts print JSON to stdout for easy automation. Typical fields include: - `ok` - `trace_id` - `voice_id` - `task_id` - `file_id` - `id` - `path` - `paths` - `meta` ## ClawHub publishing notes This skill declares its required environment variable in `SKILL.md` metadata: - `MINIMAX_API_KEY` That helps ClawHub understand the skill’s external requirements and reduces the chance of publish-time flagging. ## License MIT-0scripts/common.py5.0 KBa9f1a5273ebfupstream ↗
#!/usr/bin/env python3 import argparse import base64 import binascii import json import os import sys import time from datetime import datetime from pathlib import Path from typing import Any, Dict, Optional from urllib.parse import urlparse import requests BASE_URL = os.environ.get("MINIMAX_BASE_URL", "https://api.minimaxi.com") API_KEY_ENV = "MINIMAX_API_KEY" ROOT = Path(__file__).resolve().parents[1] OUTPUT_DIR = ROOT / "outputs" OUTPUT_DIR.mkdir(parents=True, exist_ok=True) class MiniMaxError(RuntimeError): pass def get_api_key() -> str: key = os.environ.get(API_KEY_ENV) if not key: raise MiniMaxError(f"Missing {API_KEY_ENV} in environment") return key def headers(extra: Optional[Dict[str, str]] = None) -> Dict[str, str]: h = {"Authorization": f"Bearer {get_api_key()}"} if extra: h.update(extra) return h def request_json(method: str, path: str, *, params=None, json_body=None, timeout: int = 180) -> Dict[str, Any]: resp = requests.request( method, BASE_URL + path, headers=headers({"Content-Type": "application/json"}), params=params, json=json_body, timeout=timeout, ) try: data = resp.json() except Exception as e: raise MiniMaxError(f"HTTP {resp.status_code} non-JSON response: {resp.text[:500]}") from e if resp.status_code >= 400: raise MiniMaxError(f"HTTP {resp.status_code}: {json.dumps(data, ensure_ascii=False)}") base = data.get("base_resp") or {} status_code = base.get("status_code", 0) if status_code not in (0, None): trace_id = data.get("trace_id") raise MiniMaxError( f"MiniMax error status_code={status_code} status_msg={base.get('status_msg')} trace_id={trace_id}" ) return data def request_multipart(path: str, *, data=None, files=None, timeout: int = 180) -> Dict[str, Any]: resp = requests.post( BASE_URL + path, headers={"Authorization": f"Bearer {get_api_key()}"}, data=data, files=files, timeout=timeout, ) try: payload = resp.json() except Exception as e: raise MiniMaxError(f"HTTP {resp.status_code} non-JSON response: {resp.text[:500]}") from e if resp.status_code >= 400: raise MiniMaxError(f"HTTP {resp.status_code}: {json.dumps(payload, ensure_ascii=False)}") base = payload.get("base_resp") or {} status_code = base.get("status_code", 0) if status_code not in (0, None): raise MiniMaxError( f"MiniMax error status_code={status_code} status_msg={base.get('status_msg')}" ) return payload def request_stream_download(path: str, params: Dict[str, Any], out_path: Path, timeout: int = 600) -> Path: out_path.parent.mkdir(parents=True, exist_ok=True) with requests.get(BASE_URL + path, headers=headers(), params=params, stream=True, timeout=timeout) as resp: if resp.status_code >= 400: try: j = resp.json() except Exception: j = {"text": resp.text[:500]} raise MiniMaxError(f"HTTP {resp.status_code}: {json.dumps(j, ensure_ascii=False)}") with out_path.open("wb") as f: for chunk in resp.iter_content(chunk_size=8192): if chunk: f.write(chunk) return out_path def download_url(url: str, out_path: Path, timeout: int = 600) -> Path: out_path.parent.mkdir(parents=True, exist_ok=True) with requests.get(url, stream=True, timeout=timeout) as resp: resp.raise_for_status() with out_path.open("wb") as f: for chunk in resp.iter_content(chunk_size=8192): if chunk: f.write(chunk) return out_path def decode_hex_to_file(hex_string: str, out_path: Path) -> Path: out_path.parent.mkdir(parents=True, exist_ok=True) out_path.write_bytes(bytes.fromhex(hex_string)) return out_path def timestamp_slug() -> str: return datetime.now().strftime("%Y%m%d-%H%M%S") def safe_ext_from_url(url: str, fallback: str) -> str: parsed = urlparse(url) suffix = Path(parsed.path).suffix return suffix if suffix else fallback def print_json(obj: Dict[str, Any]) -> None: print(json.dumps(obj, ensure_ascii=False, indent=2)) def add_common_output_args(parser: argparse.ArgumentParser, default_prefix: str) -> None: parser.add_argument("--output", help="explicit output path") parser.add_argument("--prefix", default=default_prefix, help="filename prefix when --output not set") def resolve_output_path(explicit: Optional[str], prefix: str, extension: str) -> Path: if explicit: return Path(explicit).expanduser().resolve() return (OUTPUT_DIR / f"{prefix}-{timestamp_slug()}{extension}").resolve() def fail(msg: str, trace_id: Optional[str] = None, **extra: Any) -> None: payload = {"ok": False, "error": msg} if trace_id: payload["trace_id"] = trace_id payload.update(extra) print_json(payload) sys.exit(1)scripts/minimax.py1.9 KBd27b2bbd8eaeupstream ↗
#!/usr/bin/env python3 import os import subprocess import sys from pathlib import Path SCRIPT_DIR = Path(__file__).resolve().parent COMMAND_MAP = { "tts": SCRIPT_DIR / "minimax_tts.py", "music": SCRIPT_DIR / "minimax_music.py", "video": SCRIPT_DIR / "minimax_video.py", "image": SCRIPT_DIR / "minimax_image.py", "voice": SCRIPT_DIR / "minimax_voice.py", } def main() -> int: argv = sys.argv[1:] if not argv or argv[0] in {"-h", "--help", "help"}: print( """MiniMax unified CLI Usage: python3 skills/minimax-tools/scripts/minimax.py tts [args...] python3 skills/minimax-tools/scripts/minimax.py music [args...] python3 skills/minimax-tools/scripts/minimax.py video [args...] python3 skills/minimax-tools/scripts/minimax.py image [args...] python3 skills/minimax-tools/scripts/minimax.py voice [args...] Examples: python3 skills/minimax-tools/scripts/minimax.py tts --text \"你好\" --voice \"Chinese (Mandarin)_Lyrical_Voice\" python3 skills/minimax-tools/scripts/minimax.py music --prompt \"lofi, rainy night\" --instrumental python3 skills/minimax-tools/scripts/minimax.py video create --prompt \"一只橘猫看雨\" --wait --download python3 skills/minimax-tools/scripts/minimax.py image --prompt \"赛博朋克城市夜景\" --aspect-ratio 16:9 python3 skills/minimax-tools/scripts/minimax.py voice clone-from-files --clone-file voice.wav --voice-id MyVoice001 --text \"你好呀\" --download-demo """ ) return 0 cmd = argv[0] target = COMMAND_MAP.get(cmd) if not target: print(f"Unknown subcommand: {cmd}", file=sys.stderr) print(f"Available: {', '.join(COMMAND_MAP)}", file=sys.stderr) return 2 proc = subprocess.run([sys.executable, str(target), *argv[1:]], env=os.environ.copy()) return proc.returncode if __name__ == "__main__": raise SystemExit(main())scripts/minimax_image.py4.0 KB9b57a7628e28upstream ↗
#!/usr/bin/env python3 import argparse import base64 import mimetypes from pathlib import Path from typing import List from common import ( MiniMaxError, decode_hex_to_file, download_url, print_json, request_json, resolve_output_path, add_common_output_args, safe_ext_from_url, ) def file_to_data_url(path: str) -> str: p = Path(path).expanduser().resolve() mime, _ = mimetypes.guess_type(str(p)) if not mime: mime = "image/png" b64 = base64.b64encode(p.read_bytes()).decode("ascii") return f"data:{mime};base64,{b64}" def normalize_image_ref(value: str) -> str: if value.startswith("http://") or value.startswith("https://") or value.startswith("data:"): return value return file_to_data_url(value) def save_base64_image(data: str, out_path: Path) -> Path: out_path.parent.mkdir(parents=True, exist_ok=True) out_path.write_bytes(base64.b64decode(data)) return out_path def main() -> None: ap = argparse.ArgumentParser(description="MiniMax image generation wrapper") ap.add_argument("--model", default="image-01") ap.add_argument("--prompt", required=True) ap.add_argument("--aspect-ratio", default="1:1", choices=["1:1", "16:9", "4:3", "3:2", "2:3", "3:4", "9:16", "21:9"]) ap.add_argument("--width", type=int) ap.add_argument("--height", type=int) ap.add_argument("--response-format", default="url", choices=["url", "base64"]) ap.add_argument("--seed", type=int) ap.add_argument("-n", type=int, default=1) ap.add_argument("--prompt-optimizer", action="store_true") ap.add_argument("--watermark", action="store_true") ap.add_argument("--style-type") ap.add_argument("--style-weight", type=float, default=0.8) ap.add_argument( "--subject-reference", action="append", default=[], help="reference image URL, data URL, or local path; repeatable", ) ap.add_argument("--subject-type", default="character") add_common_output_args(ap, "image") args = ap.parse_args() body = { "model": args.model, "prompt": args.prompt, "response_format": args.response_format, "n": args.n, "prompt_optimizer": args.prompt_optimizer, "aigc_watermark": args.watermark, } if args.aspect_ratio: body["aspect_ratio"] = args.aspect_ratio if args.width is not None and args.height is not None: body["width"] = args.width body["height"] = args.height if args.seed is not None: body["seed"] = args.seed if args.style_type: body["style"] = { "style_type": args.style_type, "style_weight": args.style_weight, } if args.subject_reference: body["subject_reference"] = [ {"type": args.subject_type, "image_file": normalize_image_ref(item)} for item in args.subject_reference ] try: data = request_json("POST", "/v1/image_generation", json_body=body, timeout=600) except MiniMaxError as e: raise SystemExit(str(e)) trace_id = data.get("trace_id") data_obj = data.get("data") or {} urls: List[str] = data_obj.get("image_urls") or [] b64s: List[str] = data_obj.get("image_base64") or [] paths = [] if args.response_format == "url": for i, url in enumerate(urls, 1): out_path = resolve_output_path(None, f"{args.prefix}-{i}", ".png") ext = safe_ext_from_url(url, ".png") out_path = out_path.with_suffix(ext) download_url(url, out_path) paths.append(str(out_path)) else: for i, image_b64 in enumerate(b64s, 1): out_path = resolve_output_path(None, f"{args.prefix}-{i}", ".png") save_base64_image(image_b64, out_path) paths.append(str(out_path)) print_json( { "ok": True, "trace_id": trace_id, "id": data.get("id"), "paths": paths, "count": len(paths), "meta": data.get("metadata") or {}, } ) if __name__ == "__main__": main()scripts/minimax_music.py3.1 KBf9a8a67d4a99upstream ↗
#!/usr/bin/env python3 import argparse from common import ( MiniMaxError, decode_hex_to_file, download_url, print_json, request_json, resolve_output_path, add_common_output_args, safe_ext_from_url, ) def main() -> None: ap = argparse.ArgumentParser(description="MiniMax music generation wrapper") ap.add_argument("--model", default="music-2.5+") ap.add_argument("--prompt") ap.add_argument("--lyrics") ap.add_argument("--lyrics-file") ap.add_argument("--lyrics-optimizer", action="store_true") ap.add_argument("--instrumental", action="store_true") ap.add_argument("--stream", action="store_true") ap.add_argument("--output-format", default="url", choices=["url", "hex"]) ap.add_argument("--sample-rate", type=int, default=44100) ap.add_argument("--bitrate", type=int, default=256000) ap.add_argument("--format", default="mp3", choices=["mp3", "wav", "pcm"]) ap.add_argument("--watermark", action="store_true") add_common_output_args(ap, "music") args = ap.parse_args() lyrics = args.lyrics if args.lyrics_file: lyrics = open(args.lyrics_file, "r", encoding="utf-8").read() if args.stream and args.output_format == "url": raise SystemExit("stream mode only supports hex output") if not args.instrumental and not lyrics and not args.lyrics_optimizer: raise SystemExit("non-instrumental mode requires --lyrics or --lyrics-file, unless --lyrics-optimizer is used") if args.instrumental and args.model != "music-2.5+": raise SystemExit("instrumental mode is only documented for music-2.5+") body = { "model": args.model, "stream": args.stream, "output_format": args.output_format, "audio_setting": { "sample_rate": args.sample_rate, "bitrate": args.bitrate, "format": args.format, }, "aigc_watermark": args.watermark, "lyrics_optimizer": args.lyrics_optimizer, "is_instrumental": args.instrumental, } if args.prompt: body["prompt"] = args.prompt if lyrics: body["lyrics"] = lyrics try: data = request_json("POST", "/v1/music_generation", json_body=body, timeout=600) except MiniMaxError as e: raise SystemExit(str(e)) audio = ((data.get("data") or {}).get("audio")) trace_id = data.get("trace_id") extra = data.get("extra_info") or {} if not audio: raise SystemExit("MiniMax music API returned no audio") out_path = resolve_output_path(args.output, args.prefix, f".{args.format}") if args.output_format == "url": ext = safe_ext_from_url(audio, f".{args.format}") out_path = out_path.with_suffix(ext) download_url(audio, out_path) source = "url" else: decode_hex_to_file(audio, out_path) source = "hex" print_json( { "ok": True, "trace_id": trace_id, "path": str(out_path), "source": source, "meta": extra, } ) if __name__ == "__main__": main()scripts/minimax_tts.py3.5 KB8dc936fc2a5bupstream ↗
#!/usr/bin/env python3 import argparse from pathlib import Path from common import ( MiniMaxError, decode_hex_to_file, download_url, print_json, request_json, resolve_output_path, add_common_output_args, safe_ext_from_url, ) def main() -> None: ap = argparse.ArgumentParser(description="MiniMax TTS wrapper") ap.add_argument("--text", required=True) ap.add_argument("--model", default="speech-2.8-turbo") ap.add_argument("--voice", help="voice_id; if omitted, use built-in default by --voice-lang") ap.add_argument("--voice-lang", default="zh", choices=["zh", "en"], help="default voice bucket when --voice is omitted") ap.add_argument("--speed", type=float, default=1.0) ap.add_argument("--volume", type=float, default=1.0) ap.add_argument("--pitch", type=int, default=0) ap.add_argument("--emotion") ap.add_argument("--sample-rate", type=int, default=32000) ap.add_argument("--bitrate", type=int, default=128000) ap.add_argument("--format", default="mp3", choices=["mp3", "wav", "pcm", "flac"]) ap.add_argument("--channel", type=int, default=1) ap.add_argument("--language-boost") ap.add_argument("--subtitle", action="store_true") ap.add_argument("--stream", action="store_true") ap.add_argument("--output-format", default="url", choices=["url", "hex"]) ap.add_argument("--watermark", action="store_true") add_common_output_args(ap, "tts") args = ap.parse_args() if args.stream and args.output_format == "url": raise SystemExit("stream mode only supports hex output") default_voices = { "zh": "Chinese (Mandarin)_Lyrical_Voice", "en": "English_Graceful_Lady", } voice_id = args.voice or default_voices[args.voice_lang] body = { "model": args.model, "text": args.text, "stream": args.stream, "voice_setting": { "voice_id": voice_id, "speed": args.speed, "vol": args.volume, "pitch": args.pitch, }, "audio_setting": { "sample_rate": args.sample_rate, "bitrate": args.bitrate, "format": args.format, "channel": args.channel, }, "subtitle_enable": args.subtitle, "output_format": args.output_format, "aigc_watermark": args.watermark, } if args.emotion: body["voice_setting"]["emotion"] = args.emotion if args.language_boost: body["language_boost"] = args.language_boost try: data = request_json("POST", "/v1/t2a_v2", json_body=body) except MiniMaxError as e: raise SystemExit(str(e)) audio = ((data.get("data") or {}).get("audio")) trace_id = data.get("trace_id") extra = data.get("extra_info") or {} subtitle_file = (data.get("data") or {}).get("subtitle_file") if not audio: raise SystemExit("MiniMax TTS returned no audio") out_path = resolve_output_path(args.output, args.prefix, f".{args.format}") if args.output_format == "url": ext = safe_ext_from_url(audio, f".{args.format}") out_path = out_path.with_suffix(ext) download_url(audio, out_path) source = "url" else: decode_hex_to_file(audio, out_path) source = "hex" print_json( { "ok": True, "trace_id": trace_id, "voice_id": voice_id, "path": str(out_path), "subtitle_file": subtitle_file, "source": source, "meta": extra, } ) if __name__ == "__main__": main()scripts/minimax_video.py7.0 KBe5e4c8a5d282upstream ↗
#!/usr/bin/env python3 import argparse import base64 import mimetypes import time from pathlib import Path from common import ( MiniMaxError, OUTPUT_DIR, print_json, request_json, request_stream_download, timestamp_slug, ) def file_to_data_url(path: str) -> str: p = Path(path).expanduser().resolve() mime, _ = mimetypes.guess_type(str(p)) if not mime: mime = "image/png" b64 = base64.b64encode(p.read_bytes()).decode("ascii") return f"data:{mime};base64,{b64}" def normalize_image_ref(value: str) -> str: if value.startswith("http://") or value.startswith("https://") or value.startswith("data:"): return value return file_to_data_url(value) def build_video_body(args): body = { "model": args.model, "prompt_optimizer": not args.no_prompt_optimizer, "duration": args.duration, "resolution": args.resolution, "aigc_watermark": args.watermark, } if getattr(args, "prompt", None): body["prompt"] = args.prompt if getattr(args, "fast_pretreatment", False): body["fast_pretreatment"] = args.fast_pretreatment if getattr(args, "first_frame_image", None): body["first_frame_image"] = normalize_image_ref(args.first_frame_image) if getattr(args, "last_frame_image", None): body["last_frame_image"] = normalize_image_ref(args.last_frame_image) return body def cmd_create(args): body = build_video_body(args) data = request_json("POST", "/v1/video_generation", json_body=body, timeout=180) task_id = data.get("task_id") result = { "ok": True, "task_id": task_id, "base_resp": data.get("base_resp"), } if args.wait: status_data = wait_for_task(task_id, args.poll_interval, args.max_wait) result["status"] = status_data if status_data.get("status") == "Success" and status_data.get("file_id"): if args.download: path = download_file(status_data["file_id"], args.output) result["path"] = str(path) print_json(result) def cmd_query(args): data = request_json("GET", "/v1/query/video_generation", params={"task_id": args.task_id}, timeout=60) print_json({"ok": True, **data}) def wait_for_task(task_id: str, poll_interval: int, max_wait: int): deadline = time.time() + max_wait last = None while time.time() < deadline: data = request_json("GET", "/v1/query/video_generation", params={"task_id": task_id}, timeout=60) last = data status = data.get("status") if status in ("Success", "Fail"): return data time.sleep(poll_interval) raise MiniMaxError(f"Timed out waiting for task {task_id}. Last status: {last}") def download_file(file_id: str, output: str | None): if output: out_path = Path(output).expanduser().resolve() else: out_path = (OUTPUT_DIR / f"video-{timestamp_slug()}.mp4").resolve() return request_stream_download("/v1/files/retrieve_content", {"file_id": file_id}, out_path, timeout=1800) def cmd_wait(args): data = wait_for_task(args.task_id, args.poll_interval, args.max_wait) result = {"ok": True, **data} if data.get("status") == "Success" and data.get("file_id") and args.download: result["path"] = str(download_file(data["file_id"], args.output)) print_json(result) def cmd_download(args): path = download_file(args.file_id, args.output) print_json({"ok": True, "file_id": args.file_id, "path": str(path)}) def main(): ap = argparse.ArgumentParser(description="MiniMax video generation wrapper") sub = ap.add_subparsers(dest="cmd", required=True) p_create = sub.add_parser("create") p_create.add_argument("--prompt", required=True) p_create.add_argument("--model", default="MiniMax-Hailuo-2.3") p_create.add_argument("--duration", type=int, default=6) p_create.add_argument("--resolution", default="768P", choices=["720P", "768P", "1080P"]) p_create.add_argument("--no-prompt-optimizer", action="store_true") p_create.add_argument("--fast-pretreatment", action="store_true") p_create.add_argument("--watermark", action="store_true") p_create.add_argument("--wait", action="store_true") p_create.add_argument("--download", action="store_true") p_create.add_argument("--poll-interval", type=int, default=10) p_create.add_argument("--max-wait", type=int, default=1800) p_create.add_argument("--output") p_create.set_defaults(func=cmd_create) p_i2v = sub.add_parser("i2v") p_i2v.add_argument("--first-frame-image", required=True, help="URL, data URL, or local image path") p_i2v.add_argument("--prompt") p_i2v.add_argument("--model", default="MiniMax-Hailuo-2.3") p_i2v.add_argument("--duration", type=int, default=6) p_i2v.add_argument("--resolution", default="768P", choices=["512P", "720P", "768P", "1080P"]) p_i2v.add_argument("--no-prompt-optimizer", action="store_true") p_i2v.add_argument("--fast-pretreatment", action="store_true") p_i2v.add_argument("--watermark", action="store_true") p_i2v.add_argument("--wait", action="store_true") p_i2v.add_argument("--download", action="store_true") p_i2v.add_argument("--poll-interval", type=int, default=10) p_i2v.add_argument("--max-wait", type=int, default=1800) p_i2v.add_argument("--output") p_i2v.set_defaults(func=cmd_create) p_fl2v = sub.add_parser("fl2v") p_fl2v.add_argument("--first-frame-image", help="URL, data URL, or local image path") p_fl2v.add_argument("--last-frame-image", required=True, help="URL, data URL, or local image path") p_fl2v.add_argument("--prompt") p_fl2v.add_argument("--model", default="MiniMax-Hailuo-02", choices=["MiniMax-Hailuo-02"]) p_fl2v.add_argument("--duration", type=int, default=6) p_fl2v.add_argument("--resolution", default="768P", choices=["768P", "1080P"]) p_fl2v.add_argument("--no-prompt-optimizer", action="store_true") p_fl2v.add_argument("--watermark", action="store_true") p_fl2v.add_argument("--wait", action="store_true") p_fl2v.add_argument("--download", action="store_true") p_fl2v.add_argument("--poll-interval", type=int, default=10) p_fl2v.add_argument("--max-wait", type=int, default=1800) p_fl2v.add_argument("--output") p_fl2v.set_defaults(func=cmd_create) p_query = sub.add_parser("query") p_query.add_argument("task_id") p_query.set_defaults(func=cmd_query) p_wait = sub.add_parser("wait") p_wait.add_argument("task_id") p_wait.add_argument("--poll-interval", type=int, default=10) p_wait.add_argument("--max-wait", type=int, default=1800) p_wait.add_argument("--download", action="store_true") p_wait.add_argument("--output") p_wait.set_defaults(func=cmd_wait) p_download = sub.add_parser("download") p_download.add_argument("file_id") p_download.add_argument("--output") p_download.set_defaults(func=cmd_download) args = ap.parse_args() try: args.func(args) except MiniMaxError as e: raise SystemExit(str(e)) if __name__ == "__main__": main()scripts/minimax_voice.py4.7 KBacbce1b48a06upstream ↗
#!/usr/bin/env python3 import argparse from pathlib import Path from common import MiniMaxError, download_url, print_json, request_json, request_multipart, resolve_output_path def upload_file(path: str, purpose: str): p = Path(path).expanduser().resolve() with p.open("rb") as f: files = {"file": (p.name, f)} data = {"purpose": purpose} return request_multipart("/v1/files/upload", data=data, files=files, timeout=600) def cmd_upload_clone(args): data = upload_file(args.file, "voice_clone") print_json({"ok": True, "file": data.get("file"), "base_resp": data.get("base_resp")}) def cmd_upload_prompt(args): data = upload_file(args.file, "prompt_audio") print_json({"ok": True, "file": data.get("file"), "base_resp": data.get("base_resp")}) def cmd_clone(args): body = { "file_id": int(args.file_id), "voice_id": args.voice_id, "need_noise_reduction": args.noise_reduction, "need_volume_normalization": args.volume_normalization, "aigc_watermark": args.watermark, } if args.text: body["text"] = args.text body["model"] = args.model if args.language_boost: body["language_boost"] = args.language_boost if args.prompt_audio_id or args.prompt_text: if not (args.prompt_audio_id and args.prompt_text): raise SystemExit("clone_prompt requires both --prompt-audio-id and --prompt-text") body["clone_prompt"] = { "prompt_audio": int(args.prompt_audio_id), "prompt_text": args.prompt_text, } data = request_json("POST", "/v1/voice_clone", json_body=body, timeout=600) result = { "ok": True, "voice_id": args.voice_id, "demo_audio": data.get("demo_audio"), "input_sensitive": data.get("input_sensitive"), "base_resp": data.get("base_resp"), } if args.download_demo and data.get("demo_audio"): out = resolve_output_path(args.output, "voice-demo", ".mp3") download_url(data["demo_audio"], out) result["demo_path"] = str(out) print_json(result) def cmd_clone_from_files(args): clone_upload = upload_file(args.clone_file, "voice_clone") file_id = clone_upload.get("file", {}).get("file_id") prompt_audio_id = None if args.prompt_audio: prompt_upload = upload_file(args.prompt_audio, "prompt_audio") prompt_audio_id = prompt_upload.get("file", {}).get("file_id") clone_args = argparse.Namespace( file_id=file_id, voice_id=args.voice_id, text=args.text, model=args.model, language_boost=args.language_boost, prompt_audio_id=prompt_audio_id, prompt_text=args.prompt_text, noise_reduction=args.noise_reduction, volume_normalization=args.volume_normalization, watermark=args.watermark, download_demo=args.download_demo, output=args.output, ) cmd_clone(clone_args) def main(): ap = argparse.ArgumentParser(description="MiniMax voice cloning wrapper") sub = ap.add_subparsers(dest="cmd", required=True) p1 = sub.add_parser("upload-clone") p1.add_argument("file") p1.set_defaults(func=cmd_upload_clone) p2 = sub.add_parser("upload-prompt") p2.add_argument("file") p2.set_defaults(func=cmd_upload_prompt) p3 = sub.add_parser("clone") p3.add_argument("--file-id", required=True) p3.add_argument("--voice-id", required=True) p3.add_argument("--text") p3.add_argument("--model", default="speech-2.8-hd") p3.add_argument("--language-boost") p3.add_argument("--prompt-audio-id") p3.add_argument("--prompt-text") p3.add_argument("--noise-reduction", action="store_true") p3.add_argument("--volume-normalization", action="store_true") p3.add_argument("--watermark", action="store_true") p3.add_argument("--download-demo", action="store_true") p3.add_argument("--output") p3.set_defaults(func=cmd_clone) p4 = sub.add_parser("clone-from-files") p4.add_argument("--clone-file", required=True) p4.add_argument("--voice-id", required=True) p4.add_argument("--prompt-audio") p4.add_argument("--prompt-text") p4.add_argument("--text") p4.add_argument("--model", default="speech-2.8-hd") p4.add_argument("--language-boost") p4.add_argument("--noise-reduction", action="store_true") p4.add_argument("--volume-normalization", action="store_true") p4.add_argument("--watermark", action="store_true") p4.add_argument("--download-demo", action="store_true") p4.add_argument("--output") p4.set_defaults(func=cmd_clone_from_files) args = ap.parse_args() try: args.func(args) except MiniMaxError as e: raise SystemExit(str(e)) if __name__ == "__main__": main()references/api-notes.md4.5 KB6f3f6d9929e9upstream ↗
# MiniMax API Notes Reference summary for the local `minimax-tools` skill. ## Authentication - Env var: `MINIMAX_API_KEY` - Auth header: `Authorization: Bearer <MINIMAX_API_KEY>` ## Base URL - `https://api.minimaxi.com` ## Endpoints used by this skill ### 1) TTS - `POST /v1/t2a_v2` - Recommended non-streaming mode for local file generation - Useful request fields: - `model` - `text` - `stream` - `voice_setting.voice_id` - `voice_setting.speed` - `voice_setting.vol` - `voice_setting.pitch` - `voice_setting.emotion` - `audio_setting.sample_rate` - `audio_setting.bitrate` - `audio_setting.format` - `audio_setting.channel` - `output_format` = `url` or `hex` - `subtitle_enable` - Text limit: under 10000 chars for sync API - Response may include: - `data.audio` (hex or url depending on output mode) - `data.subtitle_file` - `extra_info` - `trace_id` - `base_resp.status_code/status_msg` ### 2) Voice cloning - Upload clone source audio: `POST /v1/files/upload` with `purpose=voice_clone` - Upload optional prompt audio: `POST /v1/files/upload` with `purpose=prompt_audio` - Clone voice: `POST /v1/voice_clone` - Main request fields: - `file_id` - `voice_id` - `clone_prompt.prompt_audio` - `clone_prompt.prompt_text` - `text` - `model` - `language_boost` - `need_noise_reduction` - `need_volume_normalization` - `aigc_watermark` - Source clone audio constraints: - mp3 / m4a / wav - 10 seconds to 5 minutes - <= 20 MB - Prompt audio constraints: - mp3 / m4a / wav - under 8 seconds - <= 20 MB - If `text` and `model` are provided, response may include `demo_audio` - A cloned `voice_id` can be used later in TTS - MiniMax docs note cloned voices are temporary unless used within 7 days in actual TTS ### 3) Image generation - `POST /v1/image_generation` - Supports both text-to-image and image-to-image / subject-reference generation - Useful request fields: - `model` (`image-01` or `image-01-live`) - `prompt` - `subject_reference` - `style.style_type` - `style.style_weight` - `aspect_ratio` - `width` - `height` - `response_format` = `url` or `base64` - `seed` - `n` - `prompt_optimizer` - `aigc_watermark` - Response may include: - `data.image_urls` - `data.image_base64` - `metadata.success_count` - `metadata.failed_count` - `id` - `base_resp` - Subject reference images support public URLs or Data URLs; local files can be converted to Data URLs by the wrapper script ### 4) Video generation - Create task: `POST /v1/video_generation` - Query task: `GET /v1/query/video_generation?task_id=...` - Download result file: `GET /v1/files/retrieve_content?file_id=...` - Supported wrapper modes: - text-to-video via `prompt` - image-to-video via `first_frame_image` - first/last-frame video via `first_frame_image` + `last_frame_image` - Main request fields: - `model` - `prompt` - `first_frame_image` - `last_frame_image` - `prompt_optimizer` - `fast_pretreatment` - `duration` - `resolution` - `aigc_watermark` - Local image paths can be converted to Data URLs by the wrapper script - Query statuses: - `Preparing` - `Queueing` - `Processing` - `Success` - `Fail` ### 5) Music generation - `POST /v1/music_generation` - Useful request fields: - `model` (`music-2.5+` recommended) - `prompt` - `lyrics` - `lyrics_optimizer` - `is_instrumental` - `stream` - `output_format` - `audio_setting.sample_rate` - `audio_setting.bitrate` - `audio_setting.format` - Response may include: - `data.audio` (hex or url depending on output mode) - `trace_id` - `extra_info` - `base_resp` ## Common error codes - `0`: success - `1002`: rate limited - `1004`: auth failed - `1008`: insufficient balance - `1026`: sensitive input - `1027`: sensitive output - `1042`: invalid/invisible characters too high (mainly speech/text inputs) - `2013`: invalid parameters - `2049`: invalid API key ## Skill conventions - Prefer `output_format=url` in non-streaming mode, then download immediately - TTS wrapper built-in defaults: Chinese = `Chinese (Mandarin)_Lyrical_Voice`, English = `English_Graceful_Lady` - For image generation, prefer `response_format=url` unless raw Base64 is specifically needed - Save outputs under `skills/minimax-tools/outputs/` - Print JSON only from scripts - Include `trace_id` in failures whenever present ## Sources - API overview - TTS HTTP - Voice cloning (upload / clone) - Image generation (text-to-image / image-to-image) - Video generation create/query - Music generation - File retrieve_content - Error codes.gitignore33 B267a444fd30aupstream ↗
__pycache__/ *.pyc outputs/ .envLICENSE911 B7b5ec01f3e31upstream ↗
MIT No Attribution Copyright (c) 2026 Yangtao Chen Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.referencesupstream ↗
Contents are not inlined in the catalog. Open the upstream file.
scriptsupstream ↗
Contents are not inlined in the catalog. Open the upstream file.
Plain-text copy, no login: /skill-bundles/minimax-tools-skill.md