const { Configuration, OpenAIApi } = require("openai"); const api_key = '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'; const configuration = new Configuration({ apiKey: api_key }); const openai = new OpenAIApi(configuration); openai.createCompletion({ model: "text-davinci-003", prompt: "say hello in 3 random language", temperature: 0.6, }).then(response => { console.log(response.data.choices[0].text) }); // const client = new openai(api_key); // const prompt = 'Once upon a time, in a far-off kingdom, there lived a beautiful princess named...'; // const model = 'text-davinci-002'; // client.completions.create({ // engine: model, // prompt: prompt, // max_tokens: 50, // n: 1, // stop: '\n' // }).then(result => { // console.log(result.choices[0].text); // }).catch(err => { // console.log(err); // });