Skip to content

Commit 045c016

Browse files
committed
fix: apiDocs path, model validation, stream+url conflict
- Change apiDocs from full URL to path (fixes broken URL in --help) - Add client-side model validation for --model flag - Error when --stream and --output-format url are combined
1 parent e2b27e0 commit 045c016

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

src/commands/music/cover.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { musicCoverModel } from './models';
1414
export default defineCommand({
1515
name: 'music cover',
1616
description: 'Generate a cover version of a song based on reference audio (music-cover / music-cover-free)',
17-
apiDocs: 'https://platform.minimax.io/docs/api-reference/music-generation',
17+
apiDocs: '/docs/api-reference/music-generation',
1818
usage: 'mmx music cover --prompt <text> (--audio <url> | --audio-file <path>) [--lyrics <text>] [--out <path>] [flags]',
1919
options: [
2020
{ flag: '--model <model>', description: 'Model: music-cover (Token Plan), music-cover-free (Pay-as-you-go, default). Override only if needed.' },
@@ -69,6 +69,14 @@ export default defineCommand({
6969
const format = detectOutputFormat(config.output);
7070

7171
const model = (flags.model as string) || musicCoverModel(config);
72+
const VALID_MODELS = ['music-cover', 'music-cover-free'];
73+
if (flags.model && !VALID_MODELS.includes(model)) {
74+
throw new CLIError(
75+
`Invalid model "${model}". Valid models: ${VALID_MODELS.join(', ')}`,
76+
ExitCode.USAGE,
77+
'mmx music cover --model music-cover',
78+
);
79+
}
7280
const body: MusicRequest = {
7381
model,
7482
prompt,

src/commands/music/generate.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { musicGenerateModel } from './models';
1414
export default defineCommand({
1515
name: 'music generate',
1616
description: 'Generate a song (music-2.6 / music-2.6-free / music-2.5+ / music-2.5)',
17-
apiDocs: 'https://platform.minimax.io/docs/api-reference/music-generation',
17+
apiDocs: '/docs/api-reference/music-generation',
1818
usage: 'mmx music generate --prompt <text> (--lyrics <text> | --instrumental | --lyrics-optimizer) [--out <path>] [flags]',
1919
options: [
2020
{ flag: '--prompt <text>', description: 'Music style description (e.g. "cinematic orchestral, building tension"). Max 2000 chars when combined with structured flags.' },
@@ -125,6 +125,14 @@ export default defineCommand({
125125
const format = detectOutputFormat(config.output);
126126

127127
const model = (flags.model as string) || musicGenerateModel(config);
128+
const VALID_MODELS = ['music-2.6', 'music-2.6-free', 'music-2.5+', 'music-2.5'];
129+
if (flags.model && !VALID_MODELS.includes(model)) {
130+
throw new CLIError(
131+
`Invalid model "${model}". Valid models: ${VALID_MODELS.join(', ')}`,
132+
ExitCode.USAGE,
133+
'mmx music generate --model music-2.6',
134+
);
135+
}
128136
const outFormat = (flags.outputFormat as string) || 'hex';
129137
if (outFormat !== 'hex' && outFormat !== 'url') {
130138
throw new CLIError(
@@ -133,6 +141,13 @@ export default defineCommand({
133141
'mmx music generate --output-format url',
134142
);
135143
}
144+
if (flags.stream && outFormat === 'url') {
145+
throw new CLIError(
146+
'--stream and --output-format url cannot be used together. Streaming requires hex format.',
147+
ExitCode.USAGE,
148+
'mmx music generate --output-format url',
149+
);
150+
}
136151
const body: MusicRequest = {
137152
model,
138153
prompt,

0 commit comments

Comments
 (0)