I’m encountering a recurring error in an n8n workflow when using the AI Agent (LangChain) node with an OpenRouter Chat Model.
The error appears immediately when executing the workflow:
Cannot read properties of undefined (reading 'message')
Workflow Setup:
-
Trigger: Google Sheets Trigger (rowAdded)
-
Data fields: Project Name, Topic, Keywords, Project URL
-
Flow:
-
Google Sheets Trigger → AI Agent → Output
-
OpenRouter Chat Model connected to AI Agent
-
(Optional) AI Agent Tool also connected
AI Agent Prompt (simplified):
Project: {{ $json["Project Name"] }}
Topic: {{ $json.Topic }}
Keywords: {{ $json.Keywords }}
Act as a senior SEO strategist...
It could be anything.
Please share your workflow
Hi @Operations_Digital_N Welcome! that Cannot read properties of undefined (reading 'message') almost always means the OpenRouter model returned an empty body — usually the model slug is wrong, openrouter needs the full vendor/model format like openai/gpt-4o-mini, not just gpt-4o-mini. minimal repro:
swap the model slug to whichever openrouter model you’re paying for and plug your openrouter creds into the chat model node.
hey @Operations_Digital_N curious if the full vendor/model slug fix sorted the empty-response error? also worth flagging — if u accidentally pointed the openrouter creds at an OpenAI-format key (instead of an openrouter key starting with sk-or-v1-), u’d get the exact same “Cannot read properties of undefined” error since openrouter silently rejects the auth before responding. easy thing to miss when copy-pasting between providers.