[solved] 400 error when summarizing a text

I don’t know why, but this code runs properly now… Thank you.

const { Configuration, OpenAIApi } = require(‘openai’);
const { text } = require(‘./crawlTranslate’);
const Axios = require(‘axios’);

const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});

const openai = new OpenAIApi(configuration);

const axios = require(‘axios’);

async function summarizeText(text) {
try {
const response = await axios.post(
https://api.openai.com/v1/completions’,
{
model: ‘text-davinci-003’,
prompt: Summarize this to standard English:\n\n${text},
max_tokens: 50,
temperature: 0,
},
{
headers: {
‘Content-Type’: ‘application/json’,
‘Authorization’: Bearer ${process.env.OPENAI_API_KEY},
},
}
);

const summary = response.data.choices[0].text.trim();
return summary;

} catch (error) {
console.error(error.response.data);
throw new Error(‘Failed to summarize the text using OpenAI’);
}
}

module.exports = summarizeText;