Import Error with OpenAIApi in Node.js Project


I’m currently working on a Node.js project and have encountered an import error with the OpenAI API. I’ve recently updated to the latest version of the openai module. My Node.js version is v20.10.0. The error is as follows:

Error Message:
TypeError: openaiModule.default is not a constructor

Relevant Part of My Code:

const openaiModule = await import('openai');
const openai = new openaiModule.default({
  apiKey: process.env.OPENAI_API_KEY,

I'm looking for any advice or recommended practices to resolve this import error. Is this issue related to the specific version of Node.js or the openai module? Any insights would be greatly appreciated.

Thank you in advance for your help

give this a try

const OpenAI = require("openai");

const openai = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY,