Is this no longer the correct implementation

Hi I tried setting up the chatgpt API for my current project but I get the error that Configuration is not a constructor. I used in on a previous project that had the 3.3 version of the api where this syntax was working properly so I was wondering if there has been a change to the implementation. Thank you for your time and here is the code:
`const express = require(“express”);
const aiRouter = express.Router();
const { Configuration, OpenAIApi } = require(“openai”);
require(“dotenv”).config({path: “…/server/config.env”});

// Data configuration for chatgpt
const configuration = new Configuration({
organization: process.env.OPENAI_ORG_NUM,
apiKey: process.env.OPENAI_API_KEY,

const openai = new OpenAIApi(configuration);“/findBestMatches”, async (req, res) => {
try {
console.log(“Find best matches route has started”);
const contentArray = req.query.contentArray;
const gptQuery = req.query.gptQuery;

    //build completion

    const completion = await openai.createChatCompletion(
            model: "gpt-3.5-turbo",

            messages: [
                {role:"system", content:`You will receive an array of names of different files folders and your goal is to find the three that match the ${gptQuery} as closely as possible`},
                {role:"system", content:"format the response as a javascript array comprising of the three alternatives"}
            temperature: 0,
            max_tokens: 4000

    const responseText =[0].message;
    res.status(200).json({gptResponse: responseText, message: "Response from gpt api successful"});
} catch (error) {
    res.status(500).json({message: "Internal server Error"});


module.exports = aiRouter;`


1 Like

Thank you it was just what I needed! :slight_smile: