{"record":{"id":"b73d327dae0386f3","repo":"n8n-io/n8n","slug":"please-connect-a-model-to-the-fallback-model-input-b73d32","errorCode":null,"errorMessage":"Please connect a model to the Fallback Model input or disable the fallback option","messagePattern":"Please connect a model to the Fallback Model input or disable the fallback option","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/chains/ChainLLM/methods/processItem.ts","lineNumber":40,"sourceCode":"\t\t}\n\t\t// We get the models in reversed order from the workflow so we need to reverse them again to match the right index\n\t\tconst reversedModels = [...connectedModels].reverse();\n\t\tmodel = reversedModels[index] as BaseLanguageModel;\n\t} else {\n\t\tmodel = connectedModels as BaseLanguageModel;\n\t}\n\n\treturn model;\n}\n\nexport const processItem = async (ctx: IExecuteFunctions, itemIndex: number) => {\n\tconst needsFallback = ctx.getNodeParameter('needsFallback', 0, false) as boolean;\n\tconst llm = await getChatModel(ctx, 0);\n\tassert(llm, 'Please connect a model to the Chat Model input');\n\n\tconst fallbackLlm = needsFallback ? await getChatModel(ctx, 1) : null;\n\tif (needsFallback && !fallbackLlm) {\n\t\tthrow new NodeOperationError(\n\t\t\tctx.getNode(),\n\t\t\t'Please connect a model to the Fallback Model input or disable the fallback option',\n\t\t);\n\t}\n\n\t// Get output parser if configured\n\tconst outputParser = await getOptionalOutputParser(ctx, itemIndex);\n\n\t// Get user prompt based on node version\n\tlet prompt: string;\n\n\tif (ctx.getNode().typeVersion <= 1.3) {\n\t\tprompt = ctx.getNodeParameter('prompt', itemIndex) as string;\n\t} else {\n\t\tprompt = getPromptInputByType({\n\t\t\tctx,\n\t\t\ti: itemIndex,\n\t\t\tinputKey: 'text',","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/chains/ChainLLM/methods/processItem.ts#L22-L58","documentation":"Thrown by processItem in the Basic LLM Chain when needsFallback is true (the user enabled 'Use Fallback Model') but getChatModel(ctx, 1) returned null — meaning no LLM is connected to the secondary 'Fallback Model' AI input. The chain cannot fall back without a fallback model.","triggerScenarios":"The node option 'needsFallback' is enabled, but the second AI Language Model input (connection index 1) has nothing wired to it. getChatModel returns null and the guard throws.","commonSituations":"User toggled the fallback option on but forgot to wire a second model; the fallback model node is disabled; the connection was deleted when reorganizing the canvas; the wrong connection type was used (e.g. AiTool instead of AiLanguageModel).","solutions":["Connect a second AiLanguageModel-compatible node to the 'Fallback Model' input of the Basic LLM Chain.","If you do not need a fallback, disable the 'Use Fallback Model' option in the node settings.","Make sure the connected fallback node is enabled and not erroring on its own.","Confirm the connection type is AiLanguageModel (chat model), not a tool or other AI connection."],"exampleFix":"// before\nconst fallbackLlm = needsFallback ? await getChatModel(ctx, 1) : null;\nif (needsFallback && !fallbackLlm) {\n  throw new NodeOperationError(ctx.getNode(), 'Please connect a model to the Fallback Model input or disable the fallback option');\n}\n\n// after — clearer instruction; no behavioral change\nif (needsFallback && !fallbackLlm) {\n  throw new NodeOperationError(ctx.getNode(), {\n    message: 'Fallback model is enabled but no model is connected to the Fallback Model input.',\n    description: 'Either connect a Chat Model to the Fallback input, or turn off the Use Fallback Model option.',\n  });\n}","handlingStrategy":"validation","validationCode":"const needsFallback = ctx.getNodeParameter('needsFallback', 0, false) as boolean;\nif (needsFallback) {\n  const fb = await getChatModel(ctx, 1);\n  if (!fb) {\n    throw new Error('Fallback enabled but no model connected to input 1');\n  }\n}","typeGuard":"function isLanguageModel(m: unknown): m is BaseLanguageModel {\n  return !!m && typeof (m as any).invoke === 'function';\n}","tryCatchPattern":null,"preventionTips":["When enabling Use Fallback Model, immediately wire a second chat model.","Disable the fallback option if you are not using it.","Verify the fallback model node is enabled and healthy."],"tags":["configuration","model-connection","fallback","langchain"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}