Messages is a required property

Hello, I’m having difficulties with switching from text-davinci-003 to gpt-3.5-turbo-1106. Here’s my code:

async function handleSubmit() {
    if (AIInput) {
      const prompt = `{prompt removed to make code shorter}`
      const response = await{
      model: "gpt-3.5-turbo-1106",
          prompt: prompt,
          max_tokens: 10000,

I’m getting this error message: Uncaught (in promise) Error: 400 ‘messages’ is a required property

I’m new to this, so forgive me if this seems like an obvious question. Would anyone be so kind as to help me fix the syntax?

The chat completions doesn’t take a bare prompt. It accepts formatted messages assigned to roles.

    {"role": "system", "content": "You are gpt-3.5-turbo."},
    {"role": "user", "content": "How do I program the API?"}

then secondly, the max_tokens is the size of the response, and the specification cannot exceed 4k for that model, with 1500 a better setting.


Welcome to the forum.

If you don’t want to switch to the new Chat Completion (ChatML) format and want to keep using Completion (Legacy) engine, you can also use this model…


1 Like