### Install and Start Open WebUI Source: https://platform.minimax.cn/docs/m-plan/other-tools Install Open WebUI via pip (requires Python 3.11) and start the server. ```bash pip install open-webui open-webui serve ``` -------------------------------- ### Start OpenClaw configuration Source: https://platform.minimax.cn/docs/m-plan/openclaw Run this command to start the configuration wizard if it does not start automatically after installation. ```bash openclaw configure ``` -------------------------------- ### Manual Pi installation and MiniMax configuration Source: https://platform.minimax.cn/docs/m-plan/other-tools Manually install Pi, set the MINIMAX_CN_API_KEY environment variable to your subscription key (prefix sk-cp-...), and start Pi with the MiniMax provider and model. ```bash npm install -g @earendil-works/pi-coding-agent ``` ```bash export MINIMAX_CN_API_KEY=sk-cp-... pi --provider minimax-cn --model MiniMax-M3.1-Flash-Preview ``` -------------------------------- ### One-click Pi setup with MiniMax Source: https://platform.minimax.cn/docs/m-plan/other-tools Run the one-click configuration wizard for Pi, which installs the official npm package and writes the MiniMax model to Pi's settings. Requires Node.js 22.19 or higher. ```bash npx -y mmx-cli@latest agent setup ``` ```bash pi ``` -------------------------------- ### Install uv on Windows Source: https://platform.minimax.cn/docs/guides/mcp-guide Installs uv and uvx on Windows. Run this in PowerShell to get the uvx executable. ```powershell powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" ``` -------------------------------- ### Run MiniMax M Plan setup wizard with npx mmx-cli Source: https://platform.minimax.cn/docs/m-plan/hermes-agent One-click configuration wizard for MiniMax M Plan. Select Hermes Agent from the tool list, enter your subscription key, and keep Hermes Agent in the second multi-select list if not installed. The wizard runs the official installer's non-interactive core CLI phase, skips optional flows like setup and gateway, and checks hermes --version. It updates ~/.hermes/config.yaml and ~/.hermes/.env. ```bash npx -y mmx-cli@latest agent setup ``` -------------------------------- ### Install AI SDK and MiniMax Provider Source: https://platform.minimax.cn/docs/api-reference/text-ai-sdk Install the AI SDK and the MiniMax provider using either npm or pnpm. Choose one package manager; both commands install the same packages. ```bash npm install ai vercel-minimax-ai-provider ``` ```bash pnpm add ai vercel-minimax-ai-provider ``` -------------------------------- ### Start nanobot Agent Source: https://platform.minimax.cn/docs/m-plan/other-tools Start the nanobot agent. ```bash nanobot agent ``` -------------------------------- ### Install AI SDK and MiniMax Provider Source: https://platform.minimax.cn/docs/api-reference/text-ai-sdk Install the required packages using npm or pnpm. ```APIDOC ## Install AI SDK and MiniMax Provider ### Description Install the `ai` and `vercel-minimax-ai-provider` packages. ### Installation #### npm ```bash npm install ai vercel-minimax-ai-provider ``` #### pnpm ```bash pnpm add ai vercel-minimax-ai-provider ``` ``` -------------------------------- ### Install Anthropic SDK for Node.js Source: https://platform.minimax.cn/docs/guides/quickstart-sdk Install the Anthropic SDK for Node.js. This is the recommended installation method for Node.js users. ```bash npm install @anthropic-ai/sdk ``` -------------------------------- ### Install OpenAI SDK Source: https://platform.minimax.cn/docs/guides/text-chat Install the OpenAI SDK for Python or Node.js to interact with the M2-her model. ```bash pip install openai ``` ```bash npm install openai ``` -------------------------------- ### Install OpenAI SDK (Node.js) Source: https://platform.minimax.cn/docs/api-reference/text-openai-api Install the OpenAI Node.js SDK using npm. ```bash npm install openai ``` -------------------------------- ### Install Anthropic SDK for Python Source: https://platform.minimax.cn/docs/guides/quickstart-sdk Install the Anthropic SDK for Python. This is the recommended installation method for Python users. ```bash pip install anthropic ``` -------------------------------- ### Install uv on macOS/Linux Source: https://platform.minimax.cn/docs/guides/mcp-guide Installs uv and uvx on macOS/Linux. Run this in a terminal before configuring MiniMax-MCP. ```bash curl -LsSf https://astral.sh/uv/install.sh | sh ``` -------------------------------- ### Install OpenAI SDK (Python) Source: https://platform.minimax.cn/docs/api-reference/text-openai-api Install the OpenAI Python SDK using pip. ```bash pip install openai ``` -------------------------------- ### Install Qwen Code on Windows Source: https://platform.minimax.cn/docs/m-plan/other-tools Install Qwen Code on Windows using Command Prompt or PowerShell. ```powershell powershell -Command "Invoke-WebRequest 'https://qwen-code-assets.oss-cn-hangzhou.aliyuncs.com/installation/install-qwen.bat' -OutFile (Join-Path $env:TEMP 'install-qwen.bat'); & (Join-Path $env:TEMP 'install-qwen.bat')" ``` -------------------------------- ### Install Grok CLI with npm Source: https://platform.minimax.cn/docs/m-plan/other-tools Installs the Grok CLI globally via npm. This is the manual installation step before setting environment variables and launching. ```bash npm install -g grok-dev ``` -------------------------------- ### Install Qwen Code on Linux/macOS Source: https://platform.minimax.cn/docs/m-plan/other-tools Install Qwen Code on Linux or macOS using the official installation script. ```bash bash -c "$(curl -fsSL https://qwen-code-assets.oss-cn-hangzhou.aliyuncs.com/installation/install-qwen.sh)" ``` -------------------------------- ### Install Anthropic SDK for Python and Node.js Source: https://platform.minimax.cn/docs/m-plan/quickstart Install the Anthropic SDK for Python or Node.js to test the MiniMax M Plan API. ```bash pip install anthropic ``` ```bash npm install @anthropic-ai/sdk ``` -------------------------------- ### Install and configure OpenHands with MiniMax Source: https://platform.minimax.cn/docs/m-plan/other-tools Install OpenHands with pipx, configure MiniMax by replacing sk-cp-... with your subscription key, then launch the agent. ```bash pipx install openhands ``` ```bash pipx run --spec openhands python -c ' import sys from openhands_cli.stores.agent_store import AgentStore AgentStore().create_and_save_from_settings( llm_api_key=sys.argv[1], settings={"llm_model": "openai/MiniMax-M3.1-Flash-Preview", "llm_base_url": "https://api.minimax.cn/v1"}, ) ' sk-cp-... ``` ```bash openhands ``` -------------------------------- ### Verify uvx installation on macOS/Linux or Windows Source: https://platform.minimax.cn/docs/guides/token-plan-mcp-guide Verify uvx installation on macOS/Linux or Windows. If installed correctly, a path like /usr/local/bin/uvx is shown; if the error spawn uvx ENOENT occurs, configure an absolute path. ```bash which uvx ``` ```powershell (Get-Command uvx).source ``` -------------------------------- ### Install Anthropic Node.js SDK Source: https://platform.minimax.cn/docs/api-reference/text-anthropic-api Installs the Anthropic Node.js SDK, required to call MiniMax models through the Anthropic-compatible API. ```bash npm install @anthropic-ai/sdk ``` -------------------------------- ### Start SGLang-Omni server for MiniMax-Music3 Source: https://platform.minimax.cn/docs/guides/local-deploy-music-3 Starts the SGLang-Omni HTTP server on the local loopback address 127.0.0.1:8000 using the downloaded model. Keep this terminal running. ```bash CUDA_VISIBLE_DEVICES=0 sgl-omni serve \ --model-path "$MUSIC3_MODEL_DIR" \ --model-name MiniMaxAI/MiniMax-Music3 \ --host 127.0.0.1 \ --port 8000 ``` -------------------------------- ### Install Anthropic Python SDK Source: https://platform.minimax.cn/docs/api-reference/text-anthropic-api Installs the Anthropic Python SDK, required to call MiniMax models through the Anthropic-compatible API. ```bash pip install anthropic ``` -------------------------------- ### Verify Node.js and npm installation Source: https://platform.minimax.cn/docs/guides/mcp-guide Verifies that Node.js and npm are installed correctly by printing their version numbers. ```bash node -v npm -v ``` -------------------------------- ### Go example for video_generation Source: https://platform.minimax.cn/docs/api-reference/video-generation-s2v Uses net/http to POST the video generation request with a JSON string body. Prints the response body. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.minimax.cn/v1/video_generation" payload := strings.NewReader("{\n \"prompt\": \"A girl runs toward the camera and winks with a smile.\",\n \"subject_reference\": [\n {\n \"type\": \"character\",\n \"image\": [\n \"https://cdn.hailuoai.com/prod/2025-08-12-17/video_cover/1754990600020238321-411603868533342214-cover.jpg\"\n ]\n }\n ],\n \"model\": \"S2V-01\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Content-Type", "") req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Install nanobot Source: https://platform.minimax.cn/docs/m-plan/other-tools Install nanobot using uv, pipx, or pip. On macOS, pip may require --user or --break-system-packages. ```bash uv tool install nanobot-ai # 或:pipx install nanobot-ai # 或:pip install nanobot-ai # macOS 上可能需要 --user 或 --break-system-packages ``` -------------------------------- ### Start SGLang server for MiniMax-M3 Source: https://platform.minimax.cn/docs/guides/local-deploy-m3 Starts the SGLang server for MiniMax-M3-MXFP8 with tensor parallelism 8 and the specified backends. The process listens on all interfaces inside the container, but the port is published only to the host loopback address. First startup downloads about 444 GB of weights. ```bash docker run --rm --name minimax-m3 \ --gpus all \ --shm-size 32g \ --ipc=host \ -p 127.0.0.1:30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ lmsysorg/sglang@sha256:de63ac56df5d7b064451e21147eaab89634a02332d830ca8c01cb8c033b3a78f \ sglang serve \ --trust-remote-code \ --model-path MiniMaxAI/MiniMax-M3-MXFP8 \ --revision c5454eb03678d8710e54a4e0fc681b9f3b4a3dba \ --reasoning-parser auto \ --tool-call-parser auto \ --tp 8 \ --attention-backend fa4 \ --mm-attention-backend flashinfer_cudnn \ --moe-runner-backend deep_gemm \ --chunked-prefill-size 8192 \ --mem-fraction-static 0.65 \ --host 0.0.0.0 \ --port 30000 ``` -------------------------------- ### Example output from MiniMax-M3 Source: https://platform.minimax.cn/docs/guides/quickstart-sdk Example output from the MiniMax-M3 call, showing the thinking and text fields returned by the model. ```json { "thinking": "The user is just greeting me casually. I should respond in a friendly, professional manner.", "text": "Hi there! I'm doing well, thanks for asking. I'm ready to help you with whatever you need today—whether it's coding, answering questions, brainstorming ideas, or just chatting. What can I do for you?" } ``` -------------------------------- ### Install OpenClaw on Windows Source: https://platform.minimax.cn/docs/m-plan/openclaw Run this command in PowerShell to install or update OpenClaw on Windows. ```powershell iwr -useb https://openclaw.ai/install.ps1 | iex ``` -------------------------------- ### Install uvx on macOS/Linux or Windows Source: https://platform.minimax.cn/docs/guides/token-plan-mcp-guide Install uvx on macOS/Linux or Windows. The macOS/Linux command uses curl, while the Windows command uses PowerShell. ```bash curl -LsSf https://astral.sh/uv/install.sh | sh ``` ```powershell powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" ``` -------------------------------- ### Install OpenClaw on macOS/Linux Source: https://platform.minimax.cn/docs/m-plan/openclaw Run this command in the terminal to install or update OpenClaw on macOS or Linux. ```bash curl -fsSL https://openclaw.ai/install.sh | bash ``` -------------------------------- ### Voice Cloning API Request Examples (PHP, Go, Java, Ruby) Source: https://platform.minimax.cn/docs/api-reference/voice-cloning-clone These are the request examples for the voice cloning API endpoint. They show how to send a POST request to https://api.minimax.cn/v1/voice_clone with the required Authorization header (Bearer token) and the JSON body containing file_id, voice_id, clone_prompt, text, model, and other parameters. The examples are provided in PHP, Go, Java (Unirest), and Ruby. ```php "https://api.minimax.cn/v1/voice_clone", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => json_encode([ 'file_id' => 123456789, 'voice_id' => '', 'clone_prompt' => [ 'prompt_audio' => 987654321, 'prompt_text' => 'This voice sounds natural and pleasant.' ], 'text' => 'A gentle breeze sweeps across the soft grass(breath), carrying the fresh scent along with the songs of birds.', 'model' => 'speech-2.8-hd', 'text_validation' => 'This voice sounds natural and pleasant.', 'accuracy' => 0.7, 'need_noise_reduction' => false, 'need_volume_normalization' => false, 'aigc_watermark' => false ]), CURLOPT_HTTPHEADER => [ "Authorization: Bearer ", "Content-Type: application/json" ], ]); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.minimax.cn/v1/voice_clone" payload := strings.NewReader("{\n \"file_id\": 123456789,\n \"voice_id\": \"\",\n \"clone_prompt\": {\n \"prompt_audio\": 987654321,\n \"prompt_text\": \"This voice sounds natural and pleasant.\"\n },\n \"text\": \"A gentle breeze sweeps across the soft grass(breath), carrying the fresh scent along with the songs of birds.\",\n \"model\": \"speech-2.8-hd\",\n \"text_validation\": \"This voice sounds natural and pleasant.\",\n \"accuracy\": 0.7,\n \"need_noise_reduction\": false,\n \"need_volume_normalization\": false,\n \"aigc_watermark\": false\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` ```java HttpResponse response = Unirest.post("https://api.minimax.cn/v1/voice_clone") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"file_id\": 123456789,\n \"voice_id\": \"\",\n \"clone_prompt\": {\n \"prompt_audio\": 987654321,\n \"prompt_text\": \"This voice sounds natural and pleasant.\"\n },\n \"text\": \"A gentle breeze sweeps across the soft grass(breath), carrying the fresh scent along with the songs of birds.\",\n \"model\": \"speech-2.8-hd\",\n \"text_validation\": \"This voice sounds natural and pleasant.\",\n \"accuracy\": 0.7,\n \"need_noise_reduction\": false,\n \"need_volume_normalization\": false,\n \"aigc_watermark\": false\n}") .asString(); ``` ```ruby require 'uri' require 'net/http' url = URI("https://api.minimax.cn/v1/voice_clone") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"file_id\": 123456789,\n \"voice_id\": \"\",\n \"clone_prompt\": {\n \"prompt_audio\": 987654321,\n \"prompt_text\": \"This voice sounds natural and pleasant.\"\n },\n \"text\": \"A gentle breeze sweeps across the soft grass(breath), carrying the fresh scent along with the songs of birds.\",\n \"model\": \"speech-2.8-hd\",\n \"text_validation\": \"This voice sounds natural and pleasant.\",\n \"accuracy\": 0.7,\n \"need_noise_reduction\": false,\n \"need_volume_normalization\": false,\n \"aigc_watermark\": false\n}" response = http.request(request) puts response.read_body ``` -------------------------------- ### Response example for get_voice Source: https://platform.minimax.cn/docs/api-reference/voice-management-get Example 200 response showing system_voice, voice_cloning, voice_generation arrays and base_resp with status_code 0 and status_msg 'success'. ```json { "system_voice": [ { "voice_id": "Chinese (Mandarin)_Reliable_Executive", "description": [ "一位沉稳可靠的中年男性高管声音,标准普通话,传递出值得信赖的感觉。" ], "voice_name": "沉稳高管", "created_time": "1970-01-01" }, { "voice_id": "Chinese (Mandarin)_News_Anchor", "description": [ "一位专业、播音腔的中年女性新闻主播,标准普通话。" ], "voice_name": "新闻女声", "created_time": "1970-01-01" } ], "voice_cloning": [ { "voice_id": "test12345", "description": [], "created_time": "2025-08-20" }, { "voice_id": "test12346", "description": [], "created_time": "2025-08-21" } ], "voice_generation": [ { "voice_id": "ttv-voice-2025082011321125-2uEN0X1S", "description": [], "created_time": "2025-08-20" }, { "voice_id": "ttv-voice-2025082014225025-ZCQt0U0k", "description": [], "created_time": "2025-08-20" } ], "base_resp": { "status_code": 0, "status_msg": "success" } } ``` -------------------------------- ### Use LangChain ChatOpenAI with MiniMax Source: https://platform.minimax.cn/docs/m-plan/other-tools Install the LangChain OpenAI adapter and use ChatOpenAI to connect to MiniMax. Replace sk-cp-... with your subscription key. ```bash pip install langchain-openai ``` ```python from langchain_openai import ChatOpenAI llm = ChatOpenAI( model="MiniMax-M3.1-Flash-Preview", api_key="sk-cp-...", base_url="https://api.minimax.cn/v1", ) print(llm.invoke("Hello").content) ``` -------------------------------- ### Install fixed sglang-omni 0.1.3 environment Source: https://platform.minimax.cn/docs/guides/local-deploy-music-3 Creates a Python 3.12 virtual environment, installs sglang-omni 0.1.3 with prerelease allowed, and verifies that CUDA is available. The final value printed must be True before continuing. ```bash uv venv .venv --python 3.12 source .venv/bin/activate uv pip install --prerelease=allow "sglang-omni==0.1.3" python -c "import sglang_omni, torch; print(sglang_omni.__version__, torch.__version__, torch.cuda.is_available())" ``` -------------------------------- ### Upload voice clone audio file to MiniMax API (PHP, Go, Java, Ruby) Source: https://platform.minimax.cn/docs/api-reference/voice-cloning-uploadcloneaudio These are the official code examples for uploading a voice clone audio file to the MiniMax API. Each example constructs a multipart/form-data request with the purpose field set to 'voice_clone' and includes the audio file content. The examples are provided in PHP, Go, Java (using Unirest), and Ruby, and all target the endpoint https://api.minimax.cn/v1/files/upload. Note that the Content-Type header in the examples uses 'multipart/form-datan' (a typo in the source) and the Authorization header uses a placeholder ''. ```php "https://api.minimax.cn/v1/files/upload", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => $payload, CURLOPT_HTTPHEADER => [ "Authorization: Bearer ", "Content-Type: multipart/form-datan; boundary=---011000010111000001101001" ], ]); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } ``` ```go package main import ( "bytes" "fmt" "net/http" "io" "os" ) func main() { url := "https://api.minimax.cn/v1/files/upload" var payload bytes.Buffer payload.WriteString("-----011000010111000001101001\r\nContent-Type: text/plain\r\n\r\nvoice_clone\r\n-----011000010111000001101001\r\nContent-Type: application/octet-stream\r\nContent-Disposition: attachment; filename=\"example-file\"\r\n\r\n") file0, err := os.ReadFile("example-file") if err != nil { panic(err) } payload.Write(file0) payload.WriteString("\r\n-----011000010111000001101001--") req, _ := http.NewRequest("POST", url, &payload) req.Header.Add("Content-Type", "multipart/form-datan; boundary=---011000010111000001101001") req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` ```java java.io.ByteArrayOutputStream payload = new java.io.ByteArrayOutputStream(); byte[] part0 = "-----011000010111000001101001\r\nContent-Type: text/plain\r\n\r\nvoice_clone\r\n-----011000010111000001101001\r\nContent-Type: application/octet-stream\r\nContent-Disposition: attachment; filename=\"example-file\"\r\n\r\n".getBytes(java.nio.charset.StandardCharsets.UTF_8); payload.write(part0, 0, part0.length); byte[] part1 = java.nio.file.Files.readAllBytes(java.nio.file.Paths.get("example-file")); payload.write(part1, 0, part1.length); byte[] part2 = "\r\n-----011000010111000001101001--".getBytes(java.nio.charset.StandardCharsets.UTF_8); payload.write(part2, 0, part2.length); HttpResponse response = Unirest.post("https://api.minimax.cn/v1/files/upload") .header("Content-Type", "multipart/form-datan; boundary=---011000010111000001101001") .header("Authorization", "Bearer ") .body(payload.toByteArray()) .asString(); ``` ```ruby require 'uri' require 'net/http' url = URI("https://api.minimax.cn/v1/files/upload") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Content-Type"] = 'multipart/form-datan; boundary=---011000010111000001101001' request["Authorization"] = 'Bearer ' request.body = [ "-----011000010111000001101001\r\nContent-Type: text/plain\r\n\r\nvoice_clone\r\n-----011000010111000001101001\r\nContent-Type: application/octet-stream\r\nContent-Disposition: attachment; filename=\"example-file\"\r\n\r\n", File.binread("example-file"), "\r\n-----011000010111000001101001--", ].map(&:b).join response = http.request(request) puts response.read_body ``` -------------------------------- ### Install Hermes Agent with curl Source: https://platform.minimax.cn/docs/m-plan/hermes-agent One-line installer for Hermes Agent. Run in a terminal on macOS, Linux, or Windows WSL2. Requires a valid M Plan subscription key. ```bash curl -fsSL https://raw.githubusercontent.com/NousResearch/hermes-agent/main/scripts/install.sh | bash ``` -------------------------------- ### 200 response example for get model details Source: https://platform.minimax.cn/docs/api-reference/models/openai/retrieve-model Example JSON response returned by the API when the request succeeds. Contains model id, object type, creation timestamp, and owner. ```json { "id": "MiniMax-M3", "object": "model", "created": 1780272000, "owned_by": "minimax" } ``` -------------------------------- ### Set offline environment and start SGLang-Omni server Source: https://platform.minimax.cn/docs/guides/local-deploy-music-3 Use these environment variables to prevent network access and start the server with a local model directory. The server binds to 127.0.0.1:8000. ```bash export HF_HUB_OFFLINE=1 export MUSIC3_MODEL_DIR=/data/models/MiniMax-Music3-fbdf52f CUDA_VISIBLE_DEVICES=0 sgl-omni serve \ --model-path "$MUSIC3_MODEL_DIR" \ --model-name MiniMaxAI/MiniMax-Music3 \ --host 127.0.0.1 \ --port 8000 ``` -------------------------------- ### Go example for music_cover_preprocess Source: https://platform.minimax.cn/docs/api-reference/music-cover-preprocess Creates an HTTP POST request with a JSON string body and headers. Reads and prints the response body. Requires Go standard library packages. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.minimax.cn/v1/music_cover_preprocess" payload := strings.NewReader("{\n \"model\": \"music-cover\",\n \"audio_url\": \"https://example.com/song.mp3\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Content-Type", "") req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Speaker diarization and per-sentence timestamps - Python Source: https://platform.minimax.cn/docs/guides/speech-to-text Uses response_format=verbose_json to get speaker labels and timestamps. Iterates over the 'segments' array and prints speaker, start, end, and text for each segment. ```python import os, requests api_key = os.getenv("MINIMAX_API_KEY") url = "https://api.minimax.cn/v1/speech_to_text" headers = {"Authorization": f"Bearer {api_key}"} with open("/path/to/meeting.wav", "rb") as f: files = {"file": ("meeting.wav", f)} data = {"model": "asr-1.0", "response_format": "verbose_json"} result = requests.post(url, headers=headers, data=data, files=files).json() for seg in result["segments"]: print(f"[{seg['speaker']}] {seg['start']:.2f}-{seg['end']:.2f} {seg['text']}") ``` -------------------------------- ### JavaScript fetch example for video_generation Source: https://platform.minimax.cn/docs/api-reference/video-generation-s2v Uses fetch to POST the video generation request and logs the JSON response. Handles errors with catch. ```javascript const options = { method: 'POST', headers: {'Content-Type': '', Authorization: 'Bearer '}, body: JSON.stringify({ prompt: 'A girl runs toward the camera and winks with a smile.', subject_reference: [ { type: 'character', image: [ 'https://cdn.hailuoai.com/prod/2025-08-12-17/video_cover/1754990600020238321-411603868533342214-cover.jpg' ] } ], model: 'S2V-01' }) }; fetch('https://api.minimax.cn/v1/video_generation', options) .then(res => res.json()) .then(res => console.log(res)) .catch(err => console.error(err)); ``` -------------------------------- ### Verify uvx on Windows Source: https://platform.minimax.cn/docs/guides/mcp-guide Verifies uvx is available on Windows. A successful install shows the full path to uvx. ```powershell (Get-Command uvx).source ``` -------------------------------- ### Python requests example for video_generation Source: https://platform.minimax.cn/docs/api-reference/video-generation-s2v Uses the requests library to POST the same payload to the video generation endpoint. Prints the response text. ```python import requests url = "https://api.minimax.cn/v1/video_generation" payload = { "prompt": "A girl runs toward the camera and winks with a smile.", "subject_reference": [ { "type": "character", "image": ["https://cdn.hailuoai.com/prod/2025-08-12-17/video_cover/1754990600020238321-411603868533342214-cover.jpg"] } ], "model": "S2V-01" } headers = { "Content-Type": "", "Authorization": "Bearer " } response = requests.post(url, json=payload, headers=headers) print(response.text) ``` -------------------------------- ### Streaming TTS WebSocket Client Source: https://platform.minimax.cn/docs/guides/speech-t2a-websocket Complete Python example for streaming TTS audio via WebSocket. Requires mpv player and MINIMAX_API_KEY environment variable. Establishes connection, sends task start, streams audio chunks, and saves output file. ```python import asyncio import websockets import json import ssl import subprocess import os model = "speech-2.8-hd" file_format = "mp3" class StreamAudioPlayer: def __init__(self): self.mpv_process = None def start_mpv(self): """Start MPV player process""" try: mpv_command = ["mpv", "--no-cache", "--no-terminal", "--", "fd://0"] self.mpv_process = subprocess.Popen( mpv_command, stdin=subprocess.PIPE, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) print("MPV player started") return True except FileNotFoundError: print("Error: mpv not found. Please install mpv") return False except Exception as e: print(f"Failed to start mpv: {e}") return False def play_audio_chunk(self, hex_audio): """Play audio chunk""" try: if self.mpv_process and self.mpv_process.stdin: audio_bytes = bytes.fromhex(hex_audio) self.mpv_process.stdin.write(audio_bytes) self.mpv_process.stdin.flush() return True except Exception as e: print(f"Play failed: {e}") return False return False def stop(self): """Stop player""" if self.mpv_process: if self.mpv_process.stdin and not self.mpv_process.stdin.closed: self.mpv_process.stdin.close() try: self.mpv_process.wait(timeout=20) except subprocess.TimeoutExpired: self.mpv_process.terminate() async def establish_connection(api_key): """Establish WebSocket connection""" url = "wss://api.minimax.cn/ws/v1/t2a_v2" headers = {"Authorization": f"Bearer {api_key}"} ssl_context = ssl.create_default_context() ssl_context.check_hostname = False ssl_context.verify_mode = ssl.CERT_NONE try: ws = await websockets.connect(url, additional_headers=headers, ssl=ssl_context) connected = json.loads(await ws.recv()) if connected.get("event") == "connected_success": print("Connection successful") return ws return None except Exception as e: print(f"Connection failed: {e}") return None async def start_task(websocket): """Send task start request""" start_msg = { "event": "task_start", "model": model, "voice_setting": { "voice_id": "male-qn-qingse", "speed": 1, "vol": 1, "pitch": 0, "english_normalization": False }, "audio_setting": { "sample_rate": 32000, "bitrate": 128000, "format": file_format, "channel": 1 } } await websocket.send(json.dumps(start_msg)) response = json.loads(await websocket.recv()) return response.get("event") == "task_started" async def continue_task_with_stream_play(websocket, text, player): """Send continue request and stream play audio""" await websocket.send(json.dumps({ "event": "task_continue", "text": text })) chunk_counter = 1 total_audio_size = 0 audio_data = b"" while True: try: response = json.loads(await websocket.recv()) if "data" in response and "audio" in response["data"]: audio = response["data"]["audio"] if audio: print(f"Playing chunk #{chunk_counter}") audio_bytes = bytes.fromhex(audio) if player.play_audio_chunk(audio): total_audio_size += len(audio_bytes) audio_data += audio_bytes chunk_counter += 1 if response.get("is_final"): print(f"Audio synthesis completed: {chunk_counter-1} chunks") if player.mpv_process and player.mpv_process.stdin: player.mpv_process.stdin.close() # Save audio to file with open(f"output.{file_format}", "wb") as f: f.write(audio_data) print(f"Audio saved as output.{file_format}") estimated_duration = total_audio_size * 0.0625 / 1000 wait_time = max(estimated_duration + 5, 10) return wait_time except Exception as e: print(f"Error: {e}") break return 10 async def close_connection(websocket): """Close connection""" if websocket: try: await websocket.send(json.dumps({"event": "task_finish"})) await websocket.close() except Exception: pass ``` -------------------------------- ### Step 1: Preprocess reference audio with music_cover_preprocess Source: https://platform.minimax.cn/docs/guides/music-generation This step is free (not billed) and returns cover_feature_id (valid 24 hours), formatted_lyrics with paragraph tags, structure_result as a JSON string, and audio_duration in seconds. Requires MINIMAX_API_KEY. ```python import requests import json import os url = "https://api.minimax.cn/v1/music_cover_preprocess" api_key = os.environ.get("MINIMAX_API_KEY") headers = { "Content-Type": "application/json", "Authorization": f"Bearer {api_key}" } payload = { "model": "music-cover", "audio_url": "https://example.com/original-song.mp3" } response = requests.post(url, headers=headers, json=payload) result = response.json() # 保存 cover_feature_id 并查看提取的歌词 cover_feature_id = result["cover_feature_id"] formatted_lyrics = result["formatted_lyrics"] print(f"特征 ID: {cover_feature_id}") print(f"提取的歌词:\n{formatted_lyrics}") ``` -------------------------------- ### Go 获取模型列表 Source: https://platform.minimax.cn/docs/api-reference/models/openai/list-models 使用 net/http 发送 GET 请求,需要替换 为实际的 API 密钥。 ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.minimax.cn/v1/models" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### 200 response example for music_cover_preprocess Source: https://platform.minimax.cn/docs/api-reference/music-cover-preprocess Shows a successful response containing the cover_feature_id, formatted_lyrics, structure_result, audio_duration, trace_id, and base_resp with status_code 0. ```json { "cover_feature_id": "a1b2c3d4e5f67890abcdef1234567890", "formatted_lyrics": "[Verse 1]\n歌曲第一行\n歌曲第二行\n\n[Chorus]\n这是副歌部分\n高声歌唱", "structure_result": "{\"num_segments\":4,\"segments\":[{\"start\":0,\"end\":15.5,\"label\":\"intro\"},{\"start\":15.5,\"end\":45.2,\"label\":\"verse\"},{\"start\":45.2,\"end\":75.0,\"label\":\"chorus\"},{\"start\":75.0,\"end\":90.0,\"label\":\"outro\"}]}", "audio_duration": 90, "trace_id": "061e5f144eb7f10b1fdde81126e24f91", "base_resp": { "status_code": 0, "status_msg": "success" } } ``` -------------------------------- ### Initialize nanobot Source: https://platform.minimax.cn/docs/m-plan/other-tools Initialize nanobot configuration. ```bash nanobot onboard ``` -------------------------------- ### Verify Hermes Agent installation with hermes doctor Source: https://platform.minimax.cn/docs/m-plan/hermes-agent Verifies the Hermes Agent installation. Run after the install script to confirm the CLI is available. ```bash hermes doctor ``` -------------------------------- ### Python requests example for music_cover_preprocess Source: https://platform.minimax.cn/docs/api-reference/music-cover-preprocess Uses the requests library to POST the model and audio_url to the endpoint. Prints the response text. Requires the requests package and a valid token. ```python import requests url = "https://api.minimax.cn/v1/music_cover_preprocess" payload = { "model": "music-cover", "audio_url": "https://example.com/song.mp3" } headers = { "Content-Type": "", "Authorization": "Bearer " } response = requests.post(url, json=payload, headers=headers) print(response.text) ``` -------------------------------- ### 发送 task_start 事件 Source: https://platform.minimax.cn/docs/api-reference/speech-t2a-websocket-bidi 发送 `task_start` 事件以正式开始合成任务。需在收到服务端返回的 `task_started` 事件后才能发送 `task_continue` 或 `task_finish`。 ```json { "event": "task_start", "model": "speech-2.8-turbo", "language_boost": "Chinese", "voice_setting": { "voice_id": "male-qn-qingse", "speed": 1, "vol": 1, "pitch": 0 }, "pronunciation_dict": { "tone": [ "处理/(chu3)(li3)", "危险/dangerous" ] }, "audio_setting": { "sample_rate": 32000, "bitrate": 128000, "format": "mp3", "channel": 1 }, "session_id": "my-session-001" } ``` -------------------------------- ### Launch SGLang server for MiniMax-M2.7 with docker run Source: https://platform.minimax.cn/docs/guides/local-deploy-m2-7 Starts the SGLang server for MiniMax-M2.7 on 4 NVIDIA GPUs with TP 4. Add the --env line to the docker run command when Hugging Face authentication is required for the initial model download. ```bash docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --ipc=host \ lmsysorg/sglang:v0.5.10.post1 \ sglang serve \ --model-path MiniMaxAI/MiniMax-M2.7 \ --tp 4 \ --tool-call-parser minimax-m2 \ --reasoning-parser minimax-append-think \ --trust-remote-code \ --mem-fraction-static 0.85 \ --host 0.0.0.0 \ --port 30000 ``` ```bash --env "HF_TOKEN=" ``` -------------------------------- ### Set environment variables and launch Grok CLI Source: https://platform.minimax.cn/docs/m-plan/other-tools Sets the MiniMax-compatible environment variables and starts Grok CLI with the MiniMax-M3.1-Flash-Preview model. The API key is obtained from M Plan. Ensure `OPENAI_API_KEY` and `OPENAI_BASE_URL` are cleared before use. ```bash export GROK_BASE_URL=https://api.minimax.cn/v1 export GROK_API_KEY=sk-cp-... # 从 M Plan 获取 grok --model MiniMax-M3.1-Flash-Preview ``` -------------------------------- ### Cherry Studio MCP config for MiniMax Source: https://platform.minimax.cn/docs/guides/mcp-guide Configuration for Cherry Studio. Paste this into the Import from JSON dialog in Settings -> MCP Settings -> Add Server. Ensure the base path exists and has write permissions. ```json { "name": "minimax-mcp", "isActive": true, "command": "uvx", "args": [ "minimax-mcp" ], "env": { "MINIMAX_API_KEY": "填写你的 API Key", "MINIMAX_MCP_BASE_PATH": "本地输出目录路径,如/User/xxx/Desktop,需要保证路径存在且具有写入权限", "MINIMAX_API_HOST": "https://api.minimax.cn", "MINIMAX_API_RESOURCE_MODE": "可选配置,资源生成后的提供方式, 可选项为 [url|local], 默认为 url" } } ``` -------------------------------- ### VTT response example for speech-to-text Source: https://platform.minimax.cn/docs/api-reference/speech-to-text Example WebVTT subtitle response when response_format=vtt. Shows timestamped subtitle entries with the recognized text. ```vtt WEBVTT 00:00:00.100 --> 00:00:01.660 嘎嘎会,可以,这把稳了。 00:00:02.000 --> 00:00:06.100 来检查一下,读下题。 ``` -------------------------------- ### SRT response example for speech-to-text Source: https://platform.minimax.cn/docs/api-reference/speech-to-text Example SRT subtitle response when response_format=srt. Shows timestamped subtitle entries with the recognized text. ```srt 1 00:00:00,100 --> 00:00:01,660 嘎嘎会,可以,这把稳了。 2 00:00:02,000 --> 00:00:06,100 来检查一下,读下题。 ``` -------------------------------- ### 启动 FL2VA 服务 Source: https://platform.minimax.cn/docs/guides/local-deploy-h3 在 SGLang 仓库目录中激活虚拟环境后运行 sglang serve 命令,启动 FL2VA 服务。保持进程运行,首次启动需要加载模型并 warmup,可能需要数分钟才会就绪。 ```bash HF_HUB_OFFLINE=1 sglang serve \ --model-path "$MINIMAX_H3_MODEL_DIR" \ --model-variant fl2va \ --num-gpus 8 \ --tp-size 1 \ --ulysses-degree 8 \ --encoder-parallel auto \ --performance-mode speed \ --host 127.0.0.1 \ --port 30010 ``` -------------------------------- ### Configure environment variables Source: https://platform.minimax.cn/docs/api-reference/text-openai-api Set the OpenAI base URL and API key for MiniMax. ```bash export OPENAI_BASE_URL=https://api.minimax.cn/v1 export OPENAI_API_KEY=${YOUR_API_KEY} ```