OpenAI node is not parsing or reading any input value

I am passing small JSON with few strings thru HttpRequest and OpenAI is connected to my account thru a Key but can’t read any incoming messages when I use a “Message to Model”

This is the error I am getting

TypeError: Cannot read properties of undefined (reading ‘error’) at ExecuteContext.router (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/@n8n+n8n-nodes-langchain@file+packages+@n8n+nodes-langchain_7e9d43189da28db518476f7779d5ed6f/node_modules/@n8n/n8n-nodes-langchain/nodes/vendors/OpenAi/actions/router.ts:65:64) at processTicksAndRejections (node:internal/process/task_queues:105:5) at ExecuteContext.execute (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/@n8n+n8n-nodes-langchain@file+packages+@n8n+nodes-langchain_7e9d43189da28db518476f7779d5ed6f/node_modules/@n8n/n8n-nodes-langchain/nodes/vendors/OpenAi/OpenAi.node.ts:16:10) at WorkflowExecute.runNode (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@[email protected][email protected][email protected]_/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:1212:9) at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@[email protected][email protected][email protected]_/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:1582:27 at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@[email protected][email protected][email protected]_/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:2153:11

1 Like

Hey @Varun_Ramanujam hope all is well, welcome to the community.

Could you include a minimal reproducible example of your workflow? Please don’t just paste it, use the code tags.

{
“nodes”: [
{
“parameters”: {
“url”: “https://newsapi.org/v2/everything”,
“sendQuery”: true,
“queryParameters”: {
“parameters”: [
{
“name”: “q”,
“value”: “={{ $json.message.text }}”
},
{
“name”: “from”,
“value”: “={{ $today.minus({days:1}).toFormat(‘yyyy-MM-dd’) }}”
},
{
“name”: “apiKey”,
“value”: “db99ddaf117645c892d5f4848948cb72”
}
]
},
“options”: {}
},
“type”: “n8n-nodes-base.httpRequest”,
“typeVersion”: 4.2,
“position”: [
-176,
480
],
“id”: “b1c36734-f6a7-4979-8105-98ef0de55427”,
“name”: “HTTP Request”
},
{
“parameters”: {
“modelId”: {
“__rl”: true,
“value”: “gpt-4.1-mini”,
“mode”: “list”,
“cachedResultName”: “GPT-4.1-MINI”
},
“messages”: {
“values”: [
{
“content”: “=You are a highly intelligent and accurate sentiment analyzer specializing in the financial markets. Analyze the sentiment of the provided text\n\n- Evaluate the immediate market reaction, recent news impact, and technical volatility\n- Determin a sentiment category: "Positive", "Neutral", "Negative"\n- Calculate a numerical score between -1 (extremely negative) and 1 (extremely positive)\n- Provide a concise rationale explaining the short-term sentiment (give a detailed response with appropriate headlines for major events.\n\nYour output must be exactly a JSON object. The value must be an object with three keys: "category", "score", and "rationale". Do not output any additional text.\n\nFor example, your output should look like:\n\n{\n\t"shortTermSentiment": {\n\t\t"category": "Positive",\n\t\t"score": "0.7,\n\t\t"rationale": "…"\n\t\t\nNow, analyze the following text and produce your JSON output:\n\n\t {{ JSON.stringify($json.articles[0]) }}”,
“role”: “system”
}
]
},
“options”: {}
},
“type”: “@n8n/n8n-nodes-langchain.openAi”,
“typeVersion”: 1.8,
“position”: [
32,
480
],
“id”: “b73c057b-c8aa-476a-9fe9-4317cd617bb1”,
“name”: “Message a model”,
“credentials”: {
“openAiApi”: {
“id”: “eMhfjilrBpsiJjpv”,
“name”: “OpenAi account 2”
}
}
}
],
“connections”: {
“HTTP Request”: {
“main”: [
[
{
“node”: “Message a model”,
“type”: “main”,
“index”: 0
}
]
]
}
},
“pinData”: {},
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “f38c2a4e406bcd1e59d40800709341507ede59b247b990988555c37bd912bf9d”
}
}

Try to copy this workflow, run and see if this works for you

Nope…still the same error. Not sure if OpenAI node has some bug or something.

Is your OpenAI Platform in free plan?

No, I am paying $20/month for it

Hi @Varun_Ramanujam

It looks like the error property is undefined, which probably means the response from OpenAI didn’t come through as expected — possibly due to a malformed request or missing required fields.

If you’re sending a small JSON via HTTP Request, double-check that:

  • The Content-Type is set to application/json
  • Your payload matches OpenAI’s expected format (especially for messages, model, etc.)
  • Your API key is valid and has the correct scopes

Also, try logging the full response before it hits the Message to Model node — that might help pinpoint what’s missing.

Best

1 Like

Figured out the problem. I have recharged OpenAI with additional tokens and it is working fine now.

1 Like