jackwener/OpenCLI · error · ArgumentError

--model "${value}" is not accepted. Short aliases like "pro"

Error message

--model "${value}" is not accepted. Short aliases like "pro", "flash", or "flash-lite" are not supported. Use a canonical model id (e.g. "2.5-flash"). Use "opencli gemini models" to list available values.

What it means

validateAskModelValue in clis/gemini/ask.js rejects `--model` values lacking a version number (regex `/\d+\.\d+/`). Short aliases like `pro`, `flash`, or `flash-lite` are intentionally unsupported because they are ambiguous across Gemini versions. A canonical `version-variant` id is required.

Source

Thrown at clis/gemini/ask.js:58

    }
    for (const row of unwrapped) {
        if (!row || typeof row.model !== 'string' || !Array.isArray(row.thinkingValues)) {
            throw new CommandExecutionError('Gemini model discovery returned a malformed row');
        }
    }
    return unwrapped;
}

function validateAskModelValue(value) {
    if (!value) {
        throw new ArgumentError(
            '--model requires a canonical model id (e.g. "2.5-flash"). ' +
            'Use "opencli gemini models" to list available values.'
        );
    }
    // Reject short aliases like "pro", "flash", "flash-lite" that lack a version number.
    if (!/\d+\.\d+/.test(value)) {
        throw new ArgumentError(
            '--model "' + value + '" is not accepted. ' +
            'Short aliases like "pro", "flash", or "flash-lite" are not supported. ' +
            'Use a canonical model id (e.g. "2.5-flash"). ' +
            'Use "opencli gemini models" to list available values.'
        );
    }
    // Must match canonical format: X.Y-variant
    if (!/^\d+\.\d+-[a-z][a-z-]*$/.test(value)) {
        throw new ArgumentError(
            '--model "' + value + '" is not a valid canonical model id. ' +
            'Expected format: version-variant (e.g. "2.5-flash", "3.1-pro"). ' +
            'Use "opencli gemini models" to list available values.'
        );
    }
}

export const __test__ = {
    validateAskModelValue,

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Replace the alias with the canonical id, e.g. `--model 2.5-flash`, `--model 2.5-pro`, `--model 2.5-flash-lite`
  2. Run `opencli gemini models` to map the alias to the current canonical id
  3. Update wrapper scripts to store full canonical ids

Example fix

// before
opencli gemini ask --model flash --prompt "hi"
// after
opencli gemini ask --model 2.5-flash --prompt "hi"
Defensive patterns

Strategy: validation

Validate before calling

const CANONICAL_RE = /^\d+\.\d+-[a-z][a-z-]*$/;
if (['pro','flash','flash-lite'].includes(args.model) || !CANONICAL_RE.test(args.model)) {
  throw new Error(`Use a canonical model id (e.g. 2.5-flash), got "${args.model}"`);
}

Type guard

function isCanonicalModelId(v) {
  return typeof v === 'string' && /^\d+\.\d+-[a-z][a-z-]*$/.test(v);
}

Try / catch

try {
  await geminiAsk(args);
} catch (err) {
  if (err.name === 'ArgumentError' && err.message.includes('Short aliases')) {
    const expanded = expandAlias(args.model); // flash -> 2.5-flash
    if (expanded) return geminiAsk({ ...args, model: expanded });
  }
  throw err;
}

Prevention

When it happens

Trigger: `opencli gemini ask --model flash` or `--model pro` / `--model flash-lite` — any value without a `X.Y` version component.

Common situations: Habit carried over from other CLIs or SDKs that accept short aliases; docs/blog snippets using bare model names; scripts parameterized with `MODEL=flash` from older tooling.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/f25f6fe585d493ae. Report an issue: GitHub.