List Messages API Change?

The data structure returned from

 client.beta.threads.messages.list([thread_id])

does not seem to match the documented API examples.

Or am I just taking crazy pills?

Welcome to the forum Rayder. Are you able to provide more context?

When calling:

thread_messages = client.beta.threads.messages.list("thread_abc123")
print(thread_messages.data)

The API documentation shows the following response data structure:

{
“object”: “list”,
“data”: [
{
“id”: “msg_abc123”,
“object”: “thread.message”,
“created_at”: 1699016383,
“thread_id”: “thread_abc123”,
“role”: “user”,
“content”: [
{
“type”: “text”,
“text”: {
“value”: “How does AI work? Explain it in simple terms.”,
“annotations”:
}
}
],
“file_ids”: ,
“assistant_id”: null,
“run_id”: null,
“metadata”: {}
},
{
“id”: “msg_abc456”,
“object”: “thread.message”,
“created_at”: 1699016383,
“thread_id”: “thread_abc123”,
“role”: “user”,
“content”: [
{
“type”: “text”,
“text”: {
“value”: “Hello, what is AI?”,
“annotations”:
}
}
],
“file_ids”: [
“file-abc123”
],
“assistant_id”: null,
“run_id”: null,
“metadata”: {}
}
],
“first_id”: “msg_abc123”,
“last_id”: “msg_abc456”,
“has_more”: false
}

But I am getting a different structure when execute the identical code:

[
ThreadMessage(
id=‘msg_ilAFcaiX6lGGfyvRU0qu2eM8’,
assistant_id=‘asst_0Cl6T8G5sQBYk0uCLvgL6Crd’,
content=[
MessageContentText(
text=Text(
annotations=,
value=‘Hello! How can I assist you today?’),
type=‘text’
)],
created_at=1705632425,
file_ids=,
metadata={},
object=‘thread.message’,
role=‘assistant’,
run_id=‘run_p30f7lZDtGvYVqm9yKAMPKlp’,
thread_id=‘thread_EvWwLEhZ1F7bbbx6vUVR1S19’),
ThreadMessage(
id=‘msg_RNGfT3FGM2Coe8487PCYJoIr’,
assistant_id=None,
content=[
MessageContentText(
text=Text(
annotations=,
value=‘Greetings.’),
type=‘text’)],
created_at=1705632423,
file_ids=,
metadata={},
object=‘thread.message’,
role=‘user’,
run_id=None,
thread_id=‘thread_EvWwLEhZ1F7bbbx6vUVR1S19’)
]

Using python openai library, you receive class instance response defined by the library.

If you use pure curl, you should get the exact json format response as the documentation you provided.

It’s not a mismatch, it’s because an advanced interface wrapper of the library.