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.
So, I stumbled upon the same issue, but on the Ruby client side. In my case, I saw Unknown parameter: 'role'. even though role was set properly. It was the thread_id that was nil / empty.
The API error is incorrect in this case and should instead say “thread_id is null” or something similar.
I can reproduce it with this
With a wrong thread_id, it shows the correct error.
curl https://api.openai.com/v1/threads/thread_abc123/messages \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "OpenAI-Beta: assistants=v2" \
-d '{
"role": "user",
"content": "How does AI work? Explain it in simple terms."
}'
{
"error": {
"message": "No thread found with id 'thread_abc123'.",
"type": "invalid_request_error",
"param": null,
"code": null
}
}