Threads.messages.list gives malformed response object

Sorry in advance if this is a “hallucination” or if there is something that I simply do not understand. No one else is talking about this, so I’m probably at fault.

Attempting to retrieve a list of messages in a thread returns a malformed response dissimilar to what is described in the official API Reference.

I am very certain that this was not the case until recently, as the program I am working on was written to use the expected object structure and worked previously.

I considered that perhaps there were changes and the documentation was not updated to reflect. However the response is still incongruent with all of the other responses received by other requests. All the other response objects are proper, it’s just Threads.messages.list that is wrong.

Using the nodejs openai library. I can reproduce it simply with:

const emptyThread = await openai.beta.threads.create();
const messages = await openai.beta.threads.messages.list(emptyThread.id);
console.log(messages);

it should look like this:

{
“object”: “list”,
“data”: [
{
id: ‘msg_aaL4rllwcA6vSPzATC6XXXXX’,
object: ‘thread.message’,
created_at: 1703016536,
thread_id: ‘thread_kfPmQQqeLxsXzTaRmy2XXXXX’,
role: ‘assistant’,
content: [ [Object] ],
file_ids: ,
assistant_id: ‘asst_pI19XXXXXXXXXXXXXXXXXXXX’,
run_id: ‘run_DHyh10LFY6jfgJFRcCFwGaPZ’,
metadata: {}
},
{
id: ‘msg_O9Cb4CNkyiZD9sCOZyeXXXXX’,
object: ‘thread.message’,
created_at: 1703016533,
thread_id: ‘thread_kfPmQQqeLxsXzTaRmy2XXXXX’,
role: ‘user’,
content: [ [Object] ],
file_ids: ,
assistant_id: null,
run_id: null,
metadata: {}
}
]
}

but instead looks like this:

ThreadMessagesPage {
options: {
method: ‘get’,
path: ‘/threads/thread_kfPmQQqeLxsXzTaRmy2XXXXX/messages’,
query: {},
headers: { ‘OpenAI-Beta’: ‘assistants=v1’ }
},
response: Response {
size: 0,
timeout: 0,
[Symbol(Body internals)]: { body: [Gunzip], disturbed: true, error: null },
[Symbol(Response internals)]: {
url: ‘Sorry, you cant include links in your posts.’,
status: 200,
statusText: ‘OK’,
headers: [Headers],
counter: 0
}
},
body: {
object: ‘list’,
data: [ [Object], [Object] ],
first_id: ‘msg_aaL4rllwcA6vSPzATC6XXXXX’,
last_id: ‘msg_O9Cb4CNkyiZD9sCOZyeXXXXX’,
has_more: false
},
data: [
{
id: ‘msg_aaL4rllwcA6vSPzATC6XXXXX’,
object: ‘thread.message’,
created_at: 1703016536,
thread_id: ‘thread_kfPmQQqeLxsXzTaRmy2XXXXX’,
role: ‘assistant’,
content: [Array],
file_ids: ,
assistant_id: ‘asst_pI19XXXXXXXXXXXXXXXXXXXX’,
run_id: ‘run_DHyh10LFY6jfgJFRcCFwGaPZ’,
metadata: {}
},
{
id: ‘msg_O9Cb4CNkyiZD9sCOZyeXXXXX’,
object: ‘thread.message’,
created_at: 1703016533,
thread_id: ‘thread_kfPmQQqeLxsXzTaRmy2XXXXX’,
role: ‘user’,
content: [Array],
file_ids: ,
assistant_id: null,
run_id: null,
metadata: {}
}
]
}

What gives?

Reply to this text as my friend. How are you doing?