mmx-cli 1.0.21 → 1.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/sdk.mjs CHANGED
@@ -494,7 +494,7 @@ function maybeShowStatusBar(config, token, model) {
494
494
  // package.json
495
495
  var package_default = {
496
496
  name: "mmx-cli",
497
- version: "1.0.21",
497
+ version: "0.0.0-dev",
498
498
  description: "CLI for the MiniMax AI Platform",
499
499
  type: "module",
500
500
  repository: {
@@ -534,10 +534,15 @@ var package_default = {
534
534
  "test:watch": "bun test --watch"
535
535
  },
536
536
  dependencies: {
537
- "@clack/prompts": "^0.7.0",
537
+ "@clack/core": "1.0.0",
538
+ "@clack/prompts": "1.0.0",
538
539
  "bun-plugin-dts": "^0.4.0",
539
540
  "es-toolkit": "^1.46.1",
540
- undici: "^6.21.1"
541
+ "jsonc-parser": "^3.3.1",
542
+ picocolors: "^1.1.1",
543
+ "smol-toml": "^1.8.0",
544
+ undici: "^6.21.1",
545
+ yaml: "^2.9.0"
541
546
  },
542
547
  devDependencies: {
543
548
  "@eslint/js": "^9.0.0",
@@ -834,6 +839,24 @@ function vlmEndpoint(baseUrl) {
834
839
  function quotaEndpoint(baseUrl) {
835
840
  return `${baseUrl}/v1/token_plan/remains`;
836
841
  }
842
+ function accountBalanceEndpoint(baseUrl) {
843
+ return `${baseUrl}/account/query_balance`;
844
+ }
845
+ function isSecretApiKey(apiKey) {
846
+ return apiKey.startsWith("sk-api-");
847
+ }
848
+ function selectUsageEndpoint(baseUrl, credential) {
849
+ if (credential.method === "api-key" && isSecretApiKey(credential.token)) {
850
+ return {
851
+ url: accountBalanceEndpoint(baseUrl),
852
+ kind: "account-balance"
853
+ };
854
+ }
855
+ return {
856
+ url: quotaEndpoint(baseUrl),
857
+ kind: "quota"
858
+ };
859
+ }
837
860
  function fileUploadEndpoint(baseUrl) {
838
861
  return `${baseUrl}/v1/files/upload`;
839
862
  }
@@ -2105,34 +2128,63 @@ class VisionSDK extends Client {
2105
2128
  }
2106
2129
 
2107
2130
  // src/sdk/quota/index.ts
2131
+ function isQuotaResponse(response) {
2132
+ return "model_remains" in response;
2133
+ }
2134
+ function isAccountBalanceResponse(response) {
2135
+ return "available_amount" in response;
2136
+ }
2137
+
2108
2138
  class QuotaSDK extends Client {
2109
2139
  async info() {
2110
- const url = quotaEndpoint(this.config.baseUrl);
2111
- const res = await this.requestJson({ url });
2112
- return res;
2140
+ const credential = await resolveCredential(this.config);
2141
+ const endpoint = selectUsageEndpoint(this.config.baseUrl, credential);
2142
+ if (endpoint.kind === "account-balance") {
2143
+ return this.requestJson({ url: endpoint.url });
2144
+ }
2145
+ return this.requestJson({ url: endpoint.url });
2113
2146
  }
2114
2147
  }
2115
2148
 
2116
- // src/sdk/file/index.ts
2149
+ // src/files/upload.ts
2117
2150
  import { existsSync as existsSync5 } from "node:fs";
2118
2151
  import { readFile } from "node:fs/promises";
2119
- import { resolve as resolve3, basename } from "node:path";
2152
+ import { basename, resolve as resolve3 } from "node:path";
2153
+ function resolveFileUploadPath(filePath, createFileNotFoundError) {
2154
+ const fullPath = resolve3(filePath);
2155
+ if (!existsSync5(fullPath)) {
2156
+ throw createFileNotFoundError(fullPath);
2157
+ }
2158
+ return fullPath;
2159
+ }
2160
+ async function uploadFile({
2161
+ filePath,
2162
+ purpose,
2163
+ baseUrl,
2164
+ requestJson: requestJson2,
2165
+ createFileNotFoundError
2166
+ }) {
2167
+ const fullPath = resolveFileUploadPath(filePath, createFileNotFoundError);
2168
+ const fileData = await readFile(fullPath);
2169
+ const formData = new FormData;
2170
+ formData.append("file", new Blob([fileData]), basename(fullPath));
2171
+ formData.append("purpose", purpose);
2172
+ return requestJson2({
2173
+ url: fileUploadEndpoint(baseUrl),
2174
+ method: "POST",
2175
+ body: formData
2176
+ });
2177
+ }
2178
+
2179
+ // src/sdk/file/index.ts
2120
2180
  class FileSDK extends Client {
2121
2181
  async upload(filePath, purpose = "retrieval") {
2122
- const fullPath = resolve3(filePath);
2123
- if (!existsSync5(fullPath)) {
2124
- throw new SDKError(`File not found: ${fullPath}`, ExitCode.USAGE);
2125
- }
2126
- const fileData = await readFile(fullPath);
2127
- const fileName = basename(fullPath);
2128
- const formData = new FormData;
2129
- formData.append("file", new Blob([fileData]), fileName);
2130
- formData.append("purpose", purpose);
2131
- const url = fileUploadEndpoint(this.config.baseUrl);
2132
- return this.requestJson({
2133
- url,
2134
- method: "POST",
2135
- body: formData
2182
+ return uploadFile({
2183
+ filePath,
2184
+ purpose,
2185
+ baseUrl: this.config.baseUrl,
2186
+ requestJson: (opts) => this.requestJson(opts),
2187
+ createFileNotFoundError: (fullPath) => new SDKError(`File not found: ${fullPath}`, ExitCode.USAGE)
2136
2188
  });
2137
2189
  }
2138
2190
  async list() {
@@ -2176,5 +2228,7 @@ class MiniMaxSDK extends Client {
2176
2228
  }
2177
2229
  }
2178
2230
  export {
2179
- MiniMaxSDK
2231
+ MiniMaxSDK,
2232
+ isAccountBalanceResponse,
2233
+ isQuotaResponse
2180
2234
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mmx-cli",
3
- "version": "1.0.21",
3
+ "version": "1.0.24",
4
4
  "description": "CLI for the MiniMax AI Platform",
5
5
  "type": "module",
6
6
  "repository": {
@@ -40,10 +40,15 @@
40
40
  "test:watch": "bun test --watch"
41
41
  },
42
42
  "dependencies": {
43
- "@clack/prompts": "^0.7.0",
43
+ "@clack/core": "1.0.0",
44
+ "@clack/prompts": "1.0.0",
44
45
  "bun-plugin-dts": "^0.4.0",
45
46
  "es-toolkit": "^1.46.1",
46
- "undici": "^6.21.1"
47
+ "jsonc-parser": "^3.3.1",
48
+ "picocolors": "^1.1.1",
49
+ "smol-toml": "^1.8.0",
50
+ "undici": "^6.21.1",
51
+ "yaml": "^2.9.0"
47
52
  },
48
53
  "devDependencies": {
49
54
  "@eslint/js": "^9.0.0",
package/README.md DELETED
@@ -1,193 +0,0 @@
1
- <img src="https://file.cdn.minimax.io/public/MMX-capabilities.png" alt="MiniMax" width="100%" />
2
-
3
- <p align="center">
4
- <strong>The official CLI for the MiniMax AI Platform</strong><br>
5
- Built for AI agents. Generate text, images, video, and speech — from any agent or terminal.
6
- </p>
7
-
8
- <p align="center">
9
- <a href="https://www.npmjs.com/package/mmx-cli"><img src="https://img.shields.io/npm/v/mmx-cli.svg" alt="npm version" /></a>
10
- <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License: MIT" /></a>
11
- <a href="https://nodejs.org"><img src="https://img.shields.io/badge/node-%3E%3D18-brightgreen.svg" alt="Node.js >= 18" /></a>
12
- </p>
13
-
14
- <p align="center">
15
- <a href="README_CN.md">中文文档</a> · <a href="https://platform.minimax.io">Global Platform</a> · <a href="https://platform.minimaxi.com">CN Platform</a> · <a href="https://platform.minimax.io/docs/token-plan/minimax-cli">Example</a>
16
- </p>
17
-
18
- ## Features
19
-
20
- - **Text** — Multi-turn chat, streaming, system prompts, JSON output
21
- - **Image** — Text-to-image with aspect ratio and batch controls
22
- - **Video** — Async video generation with progress tracking
23
- - **Speech** — TTS with 30+ voices, speed control, streaming playback
24
- - **Vision** — Image understanding and description
25
- - **Search** — Web search powered by MiniMax
26
- - **Dual Region** — Seamless Global (`api.minimax.io`) and CN (`api.minimaxi.com`) support
27
-
28
- <img src="https://file.cdn.minimax.io/public/MMX-CLI-help.png" alt="MiniMax" width="100%" />
29
-
30
- ## Install
31
-
32
- ```bash
33
- # For AI agents (OpenClaw, Cursor, Claude Code, etc.): add skill to your agent
34
- npx skills add MiniMax-AI/cli -y -g
35
-
36
- # Or install CLI globally for terminal use
37
- npm install -g mmx-cli
38
- ```
39
-
40
- > Requires [Node.js](https://nodejs.org) 18+
41
-
42
- > **Requires a MiniMax Token Plan** — [Global](https://platform.minimax.io/subscribe/token-plan) · [CN](https://platform.minimaxi.com/subscribe/token-plan)
43
-
44
- ## Quick Start
45
-
46
- ```bash
47
- # Authenticate (interactive — choose MiniMax OAuth or paste an API key)
48
- mmx auth login
49
-
50
- # Or non-interactive
51
- mmx auth login --api-key sk-xxxxx
52
-
53
- # Start creating
54
- mmx text chat --message "What is MiniMax?"
55
- mmx image "A cat in a spacesuit"
56
- mmx speech synthesize --text "Hello!" --out hello.mp3
57
- mmx video generate --prompt "Ocean waves at sunset"
58
- mmx search "MiniMax AI latest news"
59
- mmx vision photo.jpg
60
- mmx quota
61
- ```
62
-
63
- ## Commands
64
-
65
- ### `mmx text`
66
-
67
- ```bash
68
- mmx text chat --message "Write a poem"
69
- mmx text chat --model MiniMax-M3 --message "Hello" --stream
70
- mmx text chat --system "You are a coding assistant" --message "Fizzbuzz in Go"
71
- mmx text chat --message "user:Hi" --message "assistant:Hey!" --message "How are you?"
72
- cat messages.json | mmx text chat --messages-file - --output json
73
- ```
74
-
75
- ### `mmx image`
76
-
77
- ```bash
78
- mmx image "A cat in a spacesuit"
79
- mmx image generate --prompt "A cat" --n 3 --aspect-ratio 16:9
80
- mmx image generate --prompt "Logo" --out-dir ./out/
81
- ```
82
-
83
- ### `mmx video`
84
-
85
- ```bash
86
- # Hailuo-2.3 (Video Generation V1)
87
- mmx video generate --prompt "Ocean waves at sunset" --download sunset.mp4
88
- mmx video generate --prompt "A robot painting" --async
89
-
90
- # MiniMax-H3 (Video Generation V2)
91
- mmx video generate --api-key "$MINIMAX_API_KEY" --model MiniMax-H3 --prompt "Ocean waves at sunset"
92
- mmx video generate --api-key "$MINIMAX_API_KEY" --model MiniMax-H3 --prompt "The subject walks forward" --image start.jpg
93
- mmx video generate --api-key "$MINIMAX_API_KEY" --model MiniMax-H3 --prompt "Keep the same character" --reference-image character.png --reference-video motion.mp4
94
-
95
- mmx video task get --task-id 123456
96
- mmx video task get --task-id 424010985738629 --model MiniMax-H3
97
- mmx video download --file-id 176844028768320 --out video.mp4
98
- ```
99
-
100
- For MiniMax-H3, local files and Base64 data URIs are preflight-checked against the documented limits: image 30 MB, reference video 50 MB, reference audio 15 MB, and total JSON request body 64 MB. The API validates dimensions, aspect ratio, duration, frame rate, and codecs for all media.
101
-
102
- `--region` is an existing global CLI option, not an H3 parameter. Normal video generation does not need it; the CLI uses the saved or automatically detected region. H3 defaults to 2K, 5 seconds, and 16:9 for text-to-video.
103
-
104
- ### `mmx speech`
105
-
106
- ```bash
107
- mmx speech synthesize --text "Hello!" --out hello.mp3
108
- mmx speech synthesize --text "Stream me" --stream | mpv -
109
- mmx speech synthesize --text "Hi" --voice English_magnetic_voiced_man --speed 1.2
110
- echo "Breaking news" | mmx speech synthesize --text-file - --out news.mp3
111
- mmx speech voices
112
- ```
113
-
114
- ### `mmx vision`
115
-
116
- ```bash
117
- mmx vision photo.jpg
118
- mmx vision describe --image https://example.com/img.jpg --prompt "What breed?"
119
- mmx vision describe --file-id file-123
120
- ```
121
-
122
- ### `mmx search`
123
-
124
- ```bash
125
- mmx search "MiniMax AI"
126
- mmx search query --q "latest news" --output json
127
- ```
128
-
129
- > The `/v1/coding_plan/search` API returns at most 10 results per call and does not currently expose a pagination parameter (see #107). Refine your query if you need different results.
130
-
131
- ### `mmx auth`
132
-
133
- ```bash
134
- mmx auth login # interactive: pick OAuth (Global / China) or paste an API key
135
- mmx auth login --api-key sk-xxxxx # save an API key directly
136
- mmx auth login --recommend # skip the menu, pick OAuth region interactively
137
- mmx auth login --recommend --region=global # OAuth → api.minimax.io
138
- mmx auth login --recommend --region=cn # OAuth → api.minimaxi.com
139
- mmx auth status
140
- mmx auth refresh
141
- mmx auth logout
142
- ```
143
-
144
- `mmx auth status` is the canonical way to verify active authentication.
145
-
146
- **OAuth** uses the [Device Authorization Grant (RFC 8628)](https://tools.ietf.org/html/rfc8628) with PKCE —
147
- the CLI opens your browser, you enter a code, and `access_token` + `refresh_token`
148
- are saved to `~/.mmx/config.json`. Tokens refresh automatically (5-min buffer);
149
- manual refresh via `mmx auth refresh`.
150
-
151
- **API key** auth auto-detects the correct region by probing both Global and CN.
152
- Useful for CI/CD (`mmx auth login --api-key sk-xxxxx`), or pass per-command via `--api-key`.
153
-
154
- OAuth and API key are mutually exclusive — logging in with one clears the other.
155
- Credential priority: `--api-key` flag > OAuth (config) > `api_key` (config).
156
-
157
- ### Environment variables
158
-
159
- | Variable | Description |
160
- |---|---|
161
- | `MINIMAX_REGION` | `global` or `cn`. |
162
- | `MINIMAX_BASE_URL` | Override the API base URL. |
163
- | `MINIMAX_OUTPUT` | `text` or `json`. |
164
- | `MINIMAX_TIMEOUT` | Request timeout in seconds. |
165
- | `MINIMAX_VERBOSE` | `1` to enable verbose HTTP logging. |
166
- | `MMX_CONFIG_DIR` | Directory containing the `config.json` file (default: `~/.mmx`). Set this when `mmx` runs from a subprocess, service, or CI job whose home directory differs from where you logged in. |
167
-
168
- ### `mmx config` · `mmx quota`
169
-
170
- ```bash
171
- mmx quota
172
- mmx config show
173
- mmx config set --key region --value cn
174
- mmx config set --key default-text-model --value MiniMax-M3
175
- mmx config export-schema | jq .
176
- ```
177
-
178
- ### `mmx update`
179
-
180
- ```bash
181
- mmx update
182
- mmx update latest
183
- ```
184
-
185
- ## Thanks to
186
-
187
- <a href="https://github.com/MiniMax-AI/cli/graphs/contributors">
188
- <img src="https://contrib.rocks/image?repo=MiniMax-AI/cli" />
189
- </a>
190
-
191
- ## License
192
-
193
- [MIT](LICENSE)