Skip to content

Commit 4e3baf6

Browse files
committed
Add command-specific options to --help, fix auth precedence, improve error hints
- Add Options section to each command's --help output listing all flags with descriptions and defaults - Add Getting Help section to root help page - Add command reference table with flags to README - Reorder credential resolution: flag > OAuth > config.yaml > env var - Show minimum plan required in model access and quota errors - Region-aware upgrade URL in error hints (minimax.io vs minimaxi.com)
1 parent f331bb5 commit 4e3baf6

19 files changed

Lines changed: 184 additions & 20 deletions

File tree

README.md

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,32 @@ minimax vision describe --image photo.jpg --prompt "What is this?"
6969

7070
## Commands
7171

72-
### text
72+
Run `minimax <command> --help` to see the full list of options, defaults, and usage examples for any command.
73+
74+
| Command | Description | Command-specific flags |
75+
|---|---|---|
76+
| `auth login` | Authenticate via OAuth or API key | `--method`, `--api-key`, `--no-browser` |
77+
| `auth status` | Show current authentication state ||
78+
| `auth refresh` | Manually refresh OAuth token ||
79+
| `auth logout` | Revoke tokens and clear stored credentials ||
80+
| `text chat` | Send a chat completion | `--model`, `--message`, `--messages-file`, `--system`, `--max-tokens`, `--temperature`, `--top-p`, `--stream`, `--tool` |
81+
| `speech synthesize` | Synchronous TTS, up to 10k chars | `--model`, `--text`, `--text-file`, `--voice`, `--speed`, `--volume`, `--pitch`, `--format`, `--sample-rate`, `--bitrate`, `--channels`, `--language`, `--subtitles`, `--pronunciation`, `--sound-effect`, `--out`, `--out-format`, `--stream` |
82+
| `image generate` | Generate images | `--prompt`, `--aspect-ratio`, `--n`, `--subject-ref`, `--out-dir`, `--out-prefix` |
83+
| `video generate` | Create a video generation task | `--model`, `--prompt`, `--first-frame`, `--callback-url`, `--wait`, `--poll-interval`, `--download` |
84+
| `video task get` | Query video task status | `--task-id` |
85+
| `video download` | Download a completed video by file ID | `--file-id`, `--out` |
86+
| `music generate` | Generate a song | `--prompt`, `--lyrics`, `--lyrics-file`, `--auto-lyrics`, `--format`, `--sample-rate`, `--bitrate`, `--stream`, `--out`, `--out-format` |
87+
| `search query` | Search the web via MiniMax | `--q` |
88+
| `vision describe` | Describe an image using MiniMax VLM | `--image`, `--prompt` |
89+
| `quota show` | Display Token Plan usage and remaining quotas ||
90+
| `config show` | Show current configuration ||
91+
| `config set` | Set a config value | `--key`, `--value` |
92+
93+
All commands also accept [global flags](#global-flags) (`--api-key`, `--output`, `--quiet`, `--verbose`, etc.).
94+
95+
### Examples
96+
97+
#### text
7398

7499
```bash
75100
# Simple chat
@@ -87,7 +112,7 @@ minimax text chat --message "user:Tell me a story" --stream
87112
cat conversation.json | minimax text chat --messages-file -
88113
```
89114

90-
### speech
115+
#### speech
91116

92117
```bash
93118
# Generate speech and save to file
@@ -103,7 +128,7 @@ minimax speech synthesize --text "Stream this" --stream | mpv --no-terminal -
103128
minimax speech synthesize --text "Fast narration" --voice English_expressive_narrator --speed 1.5 --out fast.mp3
104129
```
105130

106-
### image
131+
#### image
107132

108133
```bash
109134
# Generate an image
@@ -116,7 +141,7 @@ minimax image generate --prompt "Logo design" --aspect-ratio 1:1 --n 3 --out-dir
116141
minimax image generate --prompt "Portrait in oil painting style" --subject-ref ./photo.jpg
117142
```
118143

119-
### video
144+
#### video
120145

121146
```bash
122147
# Submit a video generation task
@@ -135,7 +160,7 @@ minimax video task get --task-id 106916112212032
135160
minimax video download --file-id 176844028768320 --out video.mp4
136161
```
137162

138-
### music
163+
#### music
139164

140165
```bash
141166
# Generate with custom lyrics
@@ -148,7 +173,7 @@ minimax music generate --prompt "Upbeat pop" --lyrics-file song.txt --out summer
148173
minimax music generate --prompt "Jazz lounge" --auto-lyrics --out jazz.mp3
149174
```
150175

151-
### search
176+
#### search
152177

153178
```bash
154179
# Web search
@@ -158,7 +183,7 @@ minimax search query --q "MiniMax AI"
158183
minimax search query --q "latest news" --output json
159184
```
160185

161-
### vision
186+
#### vision
162187

163188
```bash
164189
# Describe a local image
@@ -171,7 +196,7 @@ minimax vision describe --image https://example.com/photo.jpg
171196
minimax vision describe --image screenshot.png --prompt "Extract the text from this screenshot"
172197
```
173198

174-
### quota
199+
#### quota
175200

176201
```bash
177202
# Show usage and remaining quotas
@@ -181,7 +206,7 @@ minimax quota show
181206
minimax quota show --output json
182207
```
183208

184-
### config
209+
#### config
185210

186211
```bash
187212
# Show current configuration
@@ -197,7 +222,7 @@ minimax config set --key output --value json
197222
minimax config set --key timeout --value 600
198223
```
199224

200-
### auth
225+
#### auth
201226

202227
```bash
203228
# Login with API key

src/auth/resolver.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ import { CLIError } from '../errors/base';
66
import { ExitCode } from '../errors/codes';
77

88
export async function resolveCredential(config: Config): Promise<ResolvedCredential> {
9-
// 1. --api-key flag (passed through config.apiKey which includes flag + env precedence)
9+
// 1. --api-key flag
1010
if (config.apiKey) {
11-
const source = process.env.MINIMAX_API_KEY === config.apiKey ? 'env' : 'flag';
12-
return { token: config.apiKey, method: 'api-key', source };
11+
return { token: config.apiKey, method: 'api-key', source: 'flag' };
1312
}
1413

1514
// 2. OAuth credentials file
@@ -24,6 +23,11 @@ export async function resolveCredential(config: Config): Promise<ResolvedCredent
2423
return { token: config.fileApiKey, method: 'api-key', source: 'config.yaml' };
2524
}
2625

26+
// 4. Environment variable
27+
if (config.envApiKey) {
28+
return { token: config.envApiKey, method: 'api-key', source: 'env' };
29+
}
30+
2731
throw new CLIError(
2832
'No credentials found.',
2933
ExitCode.AUTH,

src/command.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
import type { Config } from './config/schema';
22
import type { GlobalFlags } from './types/flags';
33

4+
export interface OptionDef {
5+
flag: string;
6+
description: string;
7+
}
8+
49
export interface Command {
510
name: string;
611
description: string;
712
usage?: string;
13+
options?: OptionDef[];
814
examples?: string[];
915
execute(config: Config, flags: GlobalFlags): Promise<void>;
1016
}
@@ -13,6 +19,7 @@ export interface CommandSpec {
1319
name: string;
1420
description: string;
1521
usage?: string;
22+
options?: OptionDef[];
1623
examples?: string[];
1724
run(config: Config, flags: GlobalFlags): Promise<void>;
1825
}
@@ -22,6 +29,7 @@ export function defineCommand(spec: CommandSpec): Command {
2229
name: spec.name,
2330
description: spec.description,
2431
usage: spec.usage,
32+
options: spec.options,
2533
examples: spec.examples,
2634
execute: spec.run,
2735
};

src/commands/auth/login.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ export default defineCommand({
1818
name: 'auth login',
1919
description: 'Authenticate via OAuth or API key',
2020
usage: 'minimax auth login [--method oauth|api-key] [--api-key <key>] [--no-browser]',
21+
options: [
22+
{ flag: '--method <method>', description: 'Auth method: oauth (default), api-key' },
23+
{ flag: '--api-key <key>', description: 'API key to store' },
24+
{ flag: '--no-browser', description: 'Use device-code flow instead of browser' },
25+
],
2126
examples: [
2227
'minimax auth login',
2328
'minimax auth login --no-browser',

src/commands/config/set.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ export default defineCommand({
1414
name: 'config set',
1515
description: 'Set a config value',
1616
usage: 'minimax config set --key <key> --value <value>',
17+
options: [
18+
{ flag: '--key <key>', description: 'Config key (region, base_url, output, timeout, api_key)' },
19+
{ flag: '--value <value>', description: 'Value to set' },
20+
],
1721
examples: [
1822
'minimax config set --key output --value json',
1923
'minimax config set --key timeout --value 600',

src/commands/image/generate.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ export default defineCommand({
1515
name: 'image generate',
1616
description: 'Generate images (image-01)',
1717
usage: 'minimax image generate --prompt <text> [flags]',
18+
options: [
19+
{ flag: '--prompt <text>', description: 'Image description' },
20+
{ flag: '--aspect-ratio <ratio>', description: 'Aspect ratio (e.g. 16:9, 1:1)' },
21+
{ flag: '--n <count>', description: 'Number of images to generate (default: 1)' },
22+
{ flag: '--subject-ref <params>', description: 'Subject reference (type=character,image=path)' },
23+
{ flag: '--out-dir <dir>', description: 'Download images to directory' },
24+
{ flag: '--out-prefix <prefix>', description: 'Filename prefix (default: image)' },
25+
],
1826
examples: [
1927
'minimax image generate --prompt "A cat in a spacesuit on Mars" --aspect-ratio 16:9',
2028
'minimax image generate --prompt "Logo design" --n 3 --out-dir ./generated/',

src/commands/music/generate.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@ export default defineCommand({
1313
name: 'music generate',
1414
description: 'Generate a song (music-2.5)',
1515
usage: 'minimax music generate --prompt <text> [--lyrics <text>] [--out <path>] [flags]',
16+
options: [
17+
{ flag: '--prompt <text>', description: 'Music style description' },
18+
{ flag: '--lyrics <text>', description: 'Song lyrics' },
19+
{ flag: '--lyrics-file <path>', description: 'Read lyrics from file (use - for stdin)' },
20+
{ flag: '--auto-lyrics', description: 'Auto-generate lyrics from prompt' },
21+
{ flag: '--format <fmt>', description: 'Audio format (default: mp3)' },
22+
{ flag: '--sample-rate <hz>', description: 'Sample rate (default: 44100)' },
23+
{ flag: '--bitrate <bps>', description: 'Bitrate (default: 256000)' },
24+
{ flag: '--stream', description: 'Stream raw audio to stdout' },
25+
{ flag: '--out <path>', description: 'Output file path' },
26+
{ flag: '--out-format <fmt>', description: 'Output format: hex (default), url' },
27+
],
1628
examples: [
1729
'minimax music generate --prompt "Indie folk, melancholic" --lyrics-file song.txt --out my_song.mp3',
1830
'minimax music generate --prompt "Upbeat pop" --auto-lyrics --out summer.mp3',

src/commands/search/query.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ export default defineCommand({
2323
name: 'search query',
2424
description: 'Search the web via MiniMax',
2525
usage: 'minimax search query --q <query>',
26+
options: [
27+
{ flag: '--q <query>', description: 'Search query string' },
28+
],
2629
examples: [
2730
'minimax search query --q "MiniMax AI"',
2831
'minimax search query --q "latest news" --output json',

src/commands/speech/synthesize.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,26 @@ export default defineCommand({
1313
name: 'speech synthesize',
1414
description: 'Synchronous TTS, up to 10k chars (speech-2.8-hd / 2.6 / 02)',
1515
usage: 'minimax speech synthesize --text <text> --out <path> [flags]',
16+
options: [
17+
{ flag: '--model <model>', description: 'Model ID (default: speech-2.8-hd)' },
18+
{ flag: '--text <text>', description: 'Text to synthesize' },
19+
{ flag: '--text-file <path>', description: 'Read text from file (use - for stdin)' },
20+
{ flag: '--voice <id>', description: 'Voice ID (default: English_expressive_narrator)' },
21+
{ flag: '--speed <n>', description: 'Speech speed multiplier' },
22+
{ flag: '--volume <n>', description: 'Volume level' },
23+
{ flag: '--pitch <n>', description: 'Pitch adjustment' },
24+
{ flag: '--format <fmt>', description: 'Audio format (default: mp3)' },
25+
{ flag: '--sample-rate <hz>', description: 'Sample rate (default: 32000)' },
26+
{ flag: '--bitrate <bps>', description: 'Bitrate (default: 128000)' },
27+
{ flag: '--channels <n>', description: 'Audio channels (default: 1)' },
28+
{ flag: '--language <code>', description: 'Language boost' },
29+
{ flag: '--subtitles', description: 'Include subtitle timing data' },
30+
{ flag: '--pronunciation <from/to>', description: 'Custom pronunciation (repeatable)' },
31+
{ flag: '--sound-effect <effect>', description: 'Add sound effect' },
32+
{ flag: '--out <path>', description: 'Output file path' },
33+
{ flag: '--out-format <fmt>', description: 'Output format: hex (default), url' },
34+
{ flag: '--stream', description: 'Stream raw audio to stdout' },
35+
],
1636
examples: [
1737
'minimax speech synthesize --text "Hello, world!" --out hello.mp3',
1838
'echo "Breaking news." | minimax speech synthesize --text-file - --out news.mp3',

src/commands/text/chat.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,17 @@ export default defineCommand({
5757
name: 'text chat',
5858
description: 'Send a chat completion (M2.7 / M2.7-highspeed)',
5959
usage: 'minimax text chat --message <role:content> [flags]',
60+
options: [
61+
{ flag: '--model <model>', description: 'Model ID (default: MiniMax-M2.7)' },
62+
{ flag: '--message <role:content>', description: 'Message in role:content format (repeatable)' },
63+
{ flag: '--messages-file <path>', description: 'JSON file with messages array (use - for stdin)' },
64+
{ flag: '--system <text>', description: 'System prompt' },
65+
{ flag: '--max-tokens <n>', description: 'Maximum tokens to generate' },
66+
{ flag: '--temperature <n>', description: 'Sampling temperature' },
67+
{ flag: '--top-p <n>', description: 'Nucleus sampling threshold' },
68+
{ flag: '--stream', description: 'Stream response tokens (default: on in TTY)' },
69+
{ flag: '--tool <json-or-path>', description: 'Tool definition as JSON or file path (repeatable)' },
70+
],
6071
examples: [
6172
'minimax text chat --message "user:What is MiniMax?"',
6273
'minimax text chat --model MiniMax-M2.7-highspeed --system "You are a coding assistant." --message "user:Write fizzbuzz in Python"',

0 commit comments

Comments
 (0)