n8n-io/n8n · error · NodeOperationError
Chat Model is required
Error message
Chat Model is required
What it means
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.
Source
Thrown at packages/@n8n/nodes-langchain/nodes/Guardrails/actions/process.ts:85
unexpectedError.status === 'rejected'
? unexpectedError.reason
: unexpectedError.value.originalException;
throw new NodeOperationError(this.getNode(), error, {
description: error?.description || error?.message,
itemIndex,
});
}
return results.failed.map(mapGuardrailResultToUserResult);
};
const stageGuardrails: StageGuardRails = {
preflight: [],
input: [],
};
const checkModelAvailable = (model: BaseChatModel | null): model is BaseChatModel => {
if (!model) {
throw new NodeOperationError(this.getNode(), 'Chat Model is required');
}
return true;
};
if (guardrails.pii?.value) {
const { entities } = guardrails.pii.value;
stageGuardrails.preflight.push({
name: 'personalData',
check: createPiiCheckFn({
entities,
}),
});
}
if (guardrails.customRegex?.regex) {
stageGuardrails.preflight.push({
name: 'customRegex',
check: createCustomRegexCheckFn({View on GitHub (pinned to 5ac6606e81)
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.
Example fix
// before: Guardrails node has LLM guardrails enabled but no model connected // after: wire a Chat Model node into the Guardrails 'Model' (AiLanguageModel) input
Defensive patterns
Strategy: type-guard
Validate before calling
const model = await getInputConnectionData(NodeConnectionTypes.AiLanguageModel, 0);
if (!model) throw new Error('Connect a chat model before executing'); Type guard
import { isChatInstance } from '...';
function isUsableChatModel(m): m is BaseChatModel { return isChatInstance(m); } Prevention
- 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.
When it happens
Trigger: 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'.
Common situations: 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.
Related errors
- Invalid URL in allow list: "${entry}" - ${error instanceof E
- Failed to parse output
- No models connected
- No tool inputs found
- Conversational Agent requires Chat Model
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/0b2bb9e6539414e9.
Report an issue: GitHub.