jackwener/OpenCLI · error · ArgumentError

Unknown model "${modelValue}". Available models: ${available

Error message

Unknown model "${modelValue}". Available models: ${availableIds.join(', ')}. Use "opencli gemini models" to see available values.

What it means

An ArgumentError raised when the user passes a --model value that is not among the model IDs discovered from the Gemini Web UI. The error lists all valid IDs and points to `opencli gemini models`.

Source

Thrown at clis/gemini/ask.js:178

            // Close the menu. Thinking support is intentionally not copied from
            // the currently-visible UI into every model row: Gemini exposes
            // thinking controls for the current selection, not a reliable
            // per-model capability matrix.
            await page.evaluate(`(() => { try { document.body.click(); } catch (_) {} })()`);
        }

        // ── Model selection ──────────────────────────────────────────────
        if (hasModel) {
            const availableModels = discoveredModels || [];
            if (!Array.isArray(availableModels) || availableModels.length === 0) {
                throw new CommandExecutionError(
                    'Gemini model discovery returned no selectable models. Gemini Web may have changed its model selector UI.'
                );
            }
            const availableIds = availableModels.map((m) => m?.model).filter(Boolean);
            if (!availableIds.includes(modelValue)) {
                throw new ArgumentError(
                    'Unknown model "' + modelValue + '". ' +
                    'Available models: ' + availableIds.join(', ') + '. ' +
                    'Use "opencli gemini models" to see available values.'
                );
            }
            await selectGeminiModel(page, modelValue);
        }

        // ── Thinking validation and selection ──────────────────────────
        if (hasThinking) {
            // Reuse the pre-discovered models from the shared discovery call.
            const discovered = discoveredModels || [];

            // When --model was supplied, scope thinking to the selected model;
            // otherwise scope to the current model from the web UI.
            let targetModelId;
            if (hasModel) {
                targetModelId = modelValue;

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Run `opencli gemini models` and copy an ID exactly from the printed list
  2. Fix spelling/casing of the --model value to match a discovered ID
  3. Re-run discovery if Gemini recently renamed models (available IDs come from the live UI)

Example fix

// before
opencli gemini ask --model gemini-1.5-pro
// after
opencli gemini ask --model "2.5 Pro"   # ID exactly as listed by: opencli gemini models
Defensive patterns

Strategy: validation

Validate before calling

const models = await getGeminiModels();
const ids = models.map(m => m.model);
if (!ids.includes(modelValue)) {
  throw new Error(`Unknown model "${modelValue}". Available: ${ids.join(', ')}`);
}

Try / catch

try {
  await ask({ model: modelValue });
} catch (e) {
  if (/Unknown model/.test(e.message)) console.error(e.message + '\nRun: opencli gemini models');
  else throw e;
}

Prevention

When it happens

Trigger: `availableIds.includes(modelValue)` is false, e.g. `opencli gemini ask --model nonexistent-model`.

Common situations: Typo in model name; using an old model ID after Gemini renamed/retired it; casing mismatch; copying an ID from a different product (AI Studio vs Gemini Web).

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/eb5ce229d5d5bd85. Report an issue: GitHub.