jackwener/OpenCLI · error · ArgumentError
Unknown ChatGPT model "${model}"
Error message
Unknown ChatGPT model "${model}" What it means
requireKnownChatGPTModel validates the requested model name against CHATGPT_MODEL_TARGETS/CHATGPT_MODEL_ALIASES and throws ArgumentError when nothing matches. Aliases are normalized (trimmed, lowercased) before lookup, so only genuinely unknown names fail. The error's suggestion lists every accepted choice.
Source
Thrown at clis/chatgpt/utils.js:383
throw new AuthRequiredError(CHATGPT_DOMAIN, message);
}
return state;
}
export async function ensureChatGPTComposer(page, message = 'ChatGPT composer is not available on the current page.') {
const state = await ensureChatGPTLogin(page, message);
if (!state.hasComposer) {
throw new CommandExecutionError(message);
}
return state;
}
function requireKnownChatGPTModel(model) {
const key = String(model ?? '').trim().toLowerCase();
const targetKey = CHATGPT_MODEL_ALIASES[key] || key;
const option = CHATGPT_MODEL_TARGETS[targetKey];
if (!option) {
throw new ArgumentError(
`Unknown ChatGPT model "${model}"`,
`Choose one of: ${CHATGPT_MODEL_CHOICES.join(', ')}`,
);
}
return { key: targetKey, alias: key !== targetKey ? key : null, ...option };
}
function requireKnownChatGPTTool(tool) {
const key = String(tool ?? '').trim().toLowerCase();
const option = CHATGPT_TOOL_OPTIONS[key];
if (!option) {
throw new ArgumentError(
`Unknown ChatGPT tool "${tool}"`,
`Choose one of: ${CHATGPT_TOOL_CHOICES.join(', ')}`,
);
}
return { key, ...option };
}View on GitHub (pinned to 49907e53dc)
Solutions
- Run with one of the listed choices: fast, balanced, advanced, very-high, gpt-5.6-pro, pro (or aliases like high/thinking, medium, ultra, speed/instant).
- Lowercase and trim your value — lookup is case-insensitive but the word must match exactly.
- Map any OpenAI-API-style model id to the closest ChatGPT tier in your config (e.g. gpt-4o -> balanced).
- Update the library if ChatGPT introduced a new model tier this version doesn't know yet.
Example fix
// before
const target = await chatgpt.model({ model: 'gpt-4o' }); // ArgumentError
// after
const target = await chatgpt.model({ model: 'balanced' }); // accepted choice Defensive patterns
Strategy: validation
Validate before calling
import { CHATGPT_MODEL_CHOICES } from '@jackwener/opencli/chatgpt/utils';
const key = String(model ?? '').trim().toLowerCase();
if (!CHATGPT_MODEL_CHOICES.includes(key)) {
throw new Error(`model must be one of: ${CHATGPT_MODEL_CHOICES.join(', ')}`);
} Type guard
function isKnownChatGPTModel(model, choices) {
return typeof model === 'string' && choices.map(c => c.toLowerCase()).includes(model.trim().toLowerCase());
} Try / catch
try {
await selectChatGPTModel(page, model);
} catch (err) {
if (err instanceof ArgumentError && /Unknown ChatGPT model/.test(err.message)) {
console.error(err.suggestion ?? err.message);
}
throw err;
} Prevention
- Read choices from CHATGPT_MODEL_CHOICES instead of hardcoding model names.
- Validate CLI/config inputs against the exported choice list before invoking commands.
- Treat aliases (speed, medium, high, thinking, ultra) as the only accepted synonyms.
- Keep configs in sync when upgrading the library, since model tiers change.
When it happens
Trigger: Passing a model argument like `--model gpt-4o` or `--model opus` to a ChatGPT command whose `target` path resolves through requireKnownChatGPTModel; any spelling not in the fast/balanced/advanced/very-high/gpt-5.6-pro/pro alias table (e.g. 'GPT-5.5', '5', 'thinking-pro').
Common situations: Copying model names from another tool (OpenAI API ids like gpt-4o or o3); stale docs listing retired model names after ChatGPT renamed tiers; script config files carrying old model keys.
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
- Unknown ChatGPT tool "${tool}"
- chatgpt project commands require a chatgpt.com project id or
- chatgpt project commands require a project id or /g/g-p-<id>
- archive search sort must be one of ${SORT_OPTIONS.join(', ')
- archive search mediatype must be one of ${MEDIATYPES.join(',
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/50b93ce5b2eab9f1.
Report an issue: GitHub.