Learn how to fix “Cannot read property choices of undefined” in OpenAI Node with updated API steps and quick troubleshooting tips.

Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
The error happens because the OpenAI node is outputting a different JSON shape than you expect. The old n8n OpenAI (Chat / Completion) nodes used data.choices, but the new n8n OpenAI node (OpenAI Assistant, Chat Model, etc.) uses data in a different structure, so choices doesn't exist. Fix it by checking the actual output of the node (in the "Execution Data" panel) and updating your expression to match the real path. In most cases, you need either {{ $json.data[0].text }} or {{ $json.choices[0].message.content }}, depending on which OpenAI node type you're using.
The message Cannot read property choices of undefined means:
The key detail: n8n doesn’t normalize OpenAI output. The shape depends on the model type you select inside the node.
OpenAI nodes in n8n produce one of these **actual** structures:
If you use expressions written for the first format while your node is returning the third format, you get the error.
If your node output shows "choices":
// Chat model
{{ $json.choices[0].message.content }}
// Completion (old)
{{ $json.choices[0].text }}
If your node output shows "data" array (Assistants API):
{{ $json.data[0].content[0].text.value }}
You can guard against undefined by checking existence:
{{ $json.choices?.[0]?.message?.content || '' }}
This won’t fix wrong paths, but it prevents the workflow from crashing. It’s useful in production where unexpected model changes or partial errors happen.
Every time you change model type in the OpenAI node, the JSON structure may change. n8n does not automatically adapt your expressions. Always check the real output of the node and rewrite expressions accordingly. That is the reliable production fix for “Cannot read property choices of undefined”.
When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.