{"record":{"id":"0b2bb9e6539414e9","repo":"n8n-io/n8n","slug":"chat-model-is-required","errorCode":null,"errorMessage":"Chat Model is required","messagePattern":"Chat Model is required","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/Guardrails/actions/process.ts","lineNumber":85,"sourceCode":"\t\t\t\tunexpectedError.status === 'rejected'\n\t\t\t\t\t? unexpectedError.reason\n\t\t\t\t\t: unexpectedError.value.originalException;\n\t\t\tthrow new NodeOperationError(this.getNode(), error, {\n\t\t\t\tdescription: error?.description || error?.message,\n\t\t\t\titemIndex,\n\t\t\t});\n\t\t}\n\t\treturn results.failed.map(mapGuardrailResultToUserResult);\n\t};\n\n\tconst stageGuardrails: StageGuardRails = {\n\t\tpreflight: [],\n\t\tinput: [],\n\t};\n\n\tconst checkModelAvailable = (model: BaseChatModel | null): model is BaseChatModel => {\n\t\tif (!model) {\n\t\t\tthrow new NodeOperationError(this.getNode(), 'Chat Model is required');\n\t\t}\n\t\treturn true;\n\t};\n\n\tif (guardrails.pii?.value) {\n\t\tconst { entities } = guardrails.pii.value;\n\t\tstageGuardrails.preflight.push({\n\t\t\tname: 'personalData',\n\t\t\tcheck: createPiiCheckFn({\n\t\t\t\tentities,\n\t\t\t}),\n\t\t});\n\t}\n\n\tif (guardrails.customRegex?.regex) {\n\t\tstageGuardrails.preflight.push({\n\t\t\tname: 'customRegex',\n\t\t\tcheck: createCustomRegexCheckFn({","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/Guardrails/actions/process.ts#L67-L103","documentation":"Thrown by the Guardrails node's checkModelAvailable() type guard when the resolved Chat Model is null. The guardrail pipeline requires a BaseChatModel to run LLM-based checks, so a missing model is fatal before any guardrail executes. The function doubles as a type predicate so the compiler narrows the model to BaseChatModel on success.","triggerScenarios":"checkModelAvailable(model) is invoked with the model resolved from the node's AiLanguageModel input connection. If model is null (no chat model connected, or the connected node did not supply one), it throws NodeOperationError 'Chat Model is required'.","commonSituations":"Using the Guardrails node with an LLM-based guardrail (e.g. moderation, custom LLM validation) but no Chat Model node wired into the model input; the connected model node errored during supplyData and resolved to null; a non-chat model (e.g. an embedding model) connected where a chat model is expected.","solutions":["Connect a Chat Model node (e.g. OpenAI Chat Model) to the Guardrails node's AiLanguageModel input.","Ensure the connected node is a chat model, not an embedding or legacy completion model.","If you only need non-LLM guardrails (regex, allow-list), remove the guardrails that require a model or use a mode that does not invoke checkModelAvailable."],"exampleFix":"// before: Guardrails node has LLM guardrails enabled but no model connected\n// after: wire a Chat Model node into the Guardrails 'Model' (AiLanguageModel) input","handlingStrategy":"type-guard","validationCode":"const model = await getInputConnectionData(NodeConnectionTypes.AiLanguageModel, 0);\nif (!model) throw new Error('Connect a chat model before executing');","typeGuard":"import { isChatInstance } from '...';\nfunction isUsableChatModel(m): m is BaseChatModel { return isChatInstance(m); }","tryCatchPattern":null,"preventionTips":["Always wire a Chat Model node when using LLM guardrails.","Validate the model input connection in a Set/check node before the Guardrails node.","Avoid enabling LLM guardrails unless a chat model is present."],"tags":["guardrails","chat-model","langchain","config"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}