eyaltoledano/claude-task-master · error · NoSuchModelError
NoSuchModelError (languageModel, modelId: ${modelId})
Error message
NoSuchModelError (languageModel, modelId: ${modelId}) What it means
The Grok CLI language model constructor validates the modelId and throws the AI SDK's NoSuchModelError (modelType 'languageModel') when the id is falsy, not a string, or blank. This surfaces as NoSuchModelError: no such languageModel: <modelId> from the AI SDK pipeline.
Source
Thrown at packages/ai-sdk-provider-grok-cli/src/grok-cli-language-model.ts:58
readonly defaultObjectGenerationMode = 'json' as const;
readonly supportsImageUrls = false;
readonly supportsStructuredOutputs = false;
readonly supportedUrls: Record<string, RegExp[]> = {};
readonly modelId: GrokCliModelId;
readonly settings: GrokCliSettings;
constructor(options: GrokCliLanguageModelOptions) {
this.modelId = options.id;
this.settings = options.settings ?? {};
// Validate model ID format
if (
!this.modelId ||
typeof this.modelId !== 'string' ||
this.modelId.trim() === ''
) {
throw new NoSuchModelError({
modelId: this.modelId,
modelType: 'languageModel'
});
}
}
get provider(): string {
return 'grok-cli';
}
/**
* Check if Grok CLI is installed and available
*/
private async checkGrokCliInstallation(): Promise<boolean> {
return new Promise((resolve) => {
const child = spawn('grok', ['--version'], {
stdio: 'pipe'
});View on GitHub (pinned to c0c98d367c)
Solutions
- Pass a valid non-empty model id, e.g. grokCli('grok-latest') or a GrokCliModelId value.
- Check the config/env supplying the model id (e.g. GROK_MODEL) is set and non-blank.
- Add a startup check that fails fast with a clear message if the model id is missing.
- Trim user-supplied ids before passing them in.
Example fix
// before const model = grokCli(process.env.GROK_MODEL); // undefined -> NoSuchModelError // after const model = grokCli(process.env.GROK_MODEL ?? 'grok-latest');
Defensive patterns
Strategy: validation
Validate before calling
const id = process.env.GROK_MODEL; if (typeof id !== 'string' || id.trim() === '') throw new Error('GROK_MODEL must be a non-empty string'); Type guard
function isValidModelId(v) { return typeof v === 'string' && v.trim().length > 0; } Try / catch
try { const model = grokCli(modelId); } catch (e) { if (e.name === 'NoSuchModelError') { throw new ConfigError(`Invalid grok model id: ${JSON.stringify(modelId)}`); } throw e; } Prevention
- Default the model id to a known-good value when env/config is missing
- Trim and type-check ids at config load time
- Use the GrokCliModelId union type instead of raw strings
When it happens
Trigger: Calling `grokCli('')`, `grokCli(undefined as any)`, or `new grokCli(' ')`; a settings/config object passing an empty model id into createModel.
Common situations: Environment variable for the model unset and defaulted to empty string; typo'd config key so the modelId resolves to undefined; migrating from another provider where the id field has a different name.
Related errors
- Generated object does not match schema: ${validationError.me
- NoSuchModelError (textEmbeddingModel, modelId: ${modelId})
- NoSuchModelError (imageModel, modelId: ${modelId})
- ${this.name} Model ID is required
- MFA_VERIFICATION_FAILED
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/63cb5184f9f3e83d.
Report an issue: GitHub.