Cannot find openai module when executing code

Describe the issue/error/question

Problem in node code, can’t get openai module working with the following code

const openai = require('openai');

const apiKey = '<your-openai-api-key>';
const modelId = '<your-model-id>';

What is the error message (if any)?

Problem in node ‘code’
Cannot find module ‘openai’ [line 1, for item 0]

Please share the workflow


const openai = require(‘openai’);

const apiKey = ‘’;
const modelId = ‘’;


## Information on your n8n setup
- **n8n version:**
 0.209.4

- **Database you're using (default: SQLite):**

Whatever one is with desktop app
- **Running n8n with the execution process [own(default), main]:**

Not sure
- **Running n8n via [Docker, npm, n8n.cloud, desktop app]:**

Windows Desktop app

If anyone can help that would be greatly appreciated, thanks

Hey @Frank948489,

Welcome to the community :cake:

Have you installed the openai package? It isn’t something we ship with so you would need to manually add it to your install which can be tricky if you are running on the desktop release. Newer versions of n8n have an OpenAI node though or rather than using a package you could also use their API through the HTTP Request node which might be easier depending on what you are trying to do.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.