Boiler plate not working for nodejs library

import { Configuration, OpenAIApi } from "openai";
const configuration = new Configuration({
  apiKey: process.env.OPENAI_API_KEY,
const openai = new OpenAIApi(configuration);
const resp = await openai.createTranslation(


I am running this boilerplate and getting the following error:

import { Configuration, OpenAIApi } from "openai";
SyntaxError: The requested module 'openai' does not provide an export named 'Configuration'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:131:21)
    at async (node:internal/modules/esm/module_job:213:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
    at async loadESM (node:internal/process/esm_loader:34:7)
    at async handleMainPromise (node:internal/modules/run_main:66:12)

Node.js v20.8.0

Using this version of openai "openai": "^4.12.1"

The code in the boiler plate is old. You are using v4.

Follow this migration guide to update your code: