{"record":{"id":"63cb5184f9f3e83d","repo":"eyaltoledano/claude-task-master","slug":"nosuchmodelerror-languagemodel-modelid-modeli","errorCode":null,"errorMessage":"NoSuchModelError (languageModel, modelId: ${modelId})","messagePattern":"NoSuchModelError \\(languageModel, modelId: (.+?)\\)","errorType":"exception","errorClass":"NoSuchModelError","httpStatus":null,"severity":"error","filePath":"packages/ai-sdk-provider-grok-cli/src/grok-cli-language-model.ts","lineNumber":58,"sourceCode":"\treadonly defaultObjectGenerationMode = 'json' as const;\n\treadonly supportsImageUrls = false;\n\treadonly supportsStructuredOutputs = false;\n\treadonly supportedUrls: Record<string, RegExp[]> = {};\n\n\treadonly modelId: GrokCliModelId;\n\treadonly settings: GrokCliSettings;\n\n\tconstructor(options: GrokCliLanguageModelOptions) {\n\t\tthis.modelId = options.id;\n\t\tthis.settings = options.settings ?? {};\n\n\t\t// Validate model ID format\n\t\tif (\n\t\t\t!this.modelId ||\n\t\t\ttypeof this.modelId !== 'string' ||\n\t\t\tthis.modelId.trim() === ''\n\t\t) {\n\t\t\tthrow new NoSuchModelError({\n\t\t\t\tmodelId: this.modelId,\n\t\t\t\tmodelType: 'languageModel'\n\t\t\t});\n\t\t}\n\t}\n\n\tget provider(): string {\n\t\treturn 'grok-cli';\n\t}\n\n\t/**\n\t * Check if Grok CLI is installed and available\n\t */\n\tprivate async checkGrokCliInstallation(): Promise<boolean> {\n\t\treturn new Promise((resolve) => {\n\t\t\tconst child = spawn('grok', ['--version'], {\n\t\t\t\tstdio: 'pipe'\n\t\t\t});","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/packages/ai-sdk-provider-grok-cli/src/grok-cli-language-model.ts#L40-L76","documentation":"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.","triggerScenarios":"Calling `grokCli('')`, `grokCli(undefined as any)`, or `new grokCli('  ')`; a settings/config object passing an empty model id into createModel.","commonSituations":"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.","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."],"exampleFix":"// before\nconst model = grokCli(process.env.GROK_MODEL); // undefined -> NoSuchModelError\n// after\nconst model = grokCli(process.env.GROK_MODEL ?? 'grok-latest');","handlingStrategy":"validation","validationCode":"const id = process.env.GROK_MODEL; if (typeof id !== 'string' || id.trim() === '') throw new Error('GROK_MODEL must be a non-empty string');","typeGuard":"function isValidModelId(v) { return typeof v === 'string' && v.trim().length > 0; }","tryCatchPattern":"try { const model = grokCli(modelId); } catch (e) { if (e.name === 'NoSuchModelError') { throw new ConfigError(`Invalid grok model id: ${JSON.stringify(modelId)}`); } throw e; }","preventionTips":["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"],"tags":["ai-sdk","model-id","validation","grok"],"backgroundTag":"no-such-model","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}