AI Agent node error: "Cannot read properties of undefined (reading 'message')" when using OpenRouter model

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.