NODEJS with “openai”: “^4.51.0”,

Creating a message as specified in the example on “Step 3” here:

     const message = await openai.beta.threads.messages.create(
        role: "user",
        content: question,

I got this error:
BadRequestError: 400 Unknown parameter: ‘role’.

Try without the curly braces around role and content?

curly brackets are necessary because the second parameter must be an object of type OpenAI.Beta.Threads.Messages.MessageCreateParams

I see. I meant use named parameters not positional:
…messages.create(thread_id=threadId, role=“user”, content=question)
Oops, your using nodejs. Different syntax.

I am having the same issue. And I am also using node.js. Maybe it is a bug with the node.js library?

This guys here has the same problem, and he is also using node.js:
(openai community url)/t/im-facing-issue-to-declare-user-in-theads-messages-create-in-nodejs/820728

The funny thing is that it seems random. Some times this error occurs and it suddenly stop happening without a single change in the code.

1 Like

For half an hour, I’ve also been experiencing this issue. Code that used to work fine now fails with the error message: ‘unknown parameter’.