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

  1. Connect a Chat Model node (e.g. OpenAI Chat Model) to the Guardrails node's AiLanguageModel input.
  2. Ensure the connected node is a chat model, not an embedding or legacy completion model.
  3. 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

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


AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12). Data as JSON: /api/errors/0b2bb9e6539414e9. Report an issue: GitHub.