const { Configuration, OpenAIApi } = require(“openai”);
// const readline = require(“readline”);
const configuration = new Configuration({
apiKey: “API_KEY”,
});
TypeError: Configuration is not a constructor
at Object. (D:\nodeJS-chatBot\index.cjs:5:23)
at Module._compile (node:internal/modules/cjs/loader:1226:14)
at Module._extensions…js (node:internal/modules/cjs/loader:1280:10)
at Module.load (node:internal/modules/cjs/loader:1089:32)
at Module._load (node:internal/modules/cjs/loader:930:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47
1 Like
Still it’s giving the same error
I’m using 4.0.1 version of Node openai npm library
and nodejs version : 18.14.0
1 Like
Hello there.
I was having the same error and found out this is due to some changes in the npm openai version 4 package. Check the Migration Guide in the openai-node github repository including all significant changes from v3 to v4, those changes include the initialization of the api, creating transcriptions and more.
3 Likes
https://chat.openai.com/share/b175130a-0d77-465e-8187-59b92590df8b
I created a ChatGPT-4 chat that contains the migration guide text and is ready for a query, if you get code issues run them into that chat and you should get a useful result.
1 Like
I got the same question here, it shows “const configuration = new OpenAIApi({
TypeError: OpenAIApi is not a constructor” after I change it into OpenAIApi
Could you help me in this case?
Thank You I’t really helps
but having another issue
Problems loading reference 'https://json.schemastore.org/package': Unable to load schema from 'https://json.schemastore.org/package': connect ETIMEDOUT 20.42.128.105:443.
problem showing some fault in package.json but i checked it’s correct