Why openai.createCompletion returns error 400?

Here is my code.

    const openaiResponse = await openai.createCompletion(
      {
        model: 'gpt-3.5-turbo',
        messages: [{ role: 'user', content: 'what is mass of mars?' }],
        stream: true,
      },
      {
        responseType: 'stream',
      }
    );

messages is used with OpenAI Chat API, while the createCompletion function expects a prompt parameter.

Here’s the corrected code:

const openaiResponse = await openai.createCompletion({
  model: 'gpt-3.5-turbo',
  prompt: 'what is the mass of mars?',
  stream: true,
}, {
  responseType: 'stream',
});