"status" key missing from Assistant API's GET Message response

Documentation for Assistant API Message objects describes a required “status” key, which is not present in response. Lost me an hour of debugging on why my json deserialization was breaking.

GET https://api.openai.com/v1/threads/{thread_id}/messages/{message_id}

headers: {
        "Authorization":
            "Bearer my-key",
        "OpenAI-Beta": "assistants=v1"}


//Response has no "status" key
{
    "id": "some_message_id",
    "object": "thread.message",
    "created_at": 1714869955,
    "assistant_id": "some_assistant_id",
    "thread_id": "some_thread_id",
    "run_id": "some_run_id",
    "role": "assistant",
    "content": [
        {
            "type": "text",
            "text": {
                "value": "Feel free to ask for more details or specific events if needed!",
                "annotations": []
            }
        }
    ],
    "file_ids": [],
    "metadata": {}
}

1 Like

In my opinion, status will appear only after you run the thread. I could be wrong.

This is only applicable to the v2 version of the api.

2 Likes

Hello nikunj,

I’ve tried both “assistants=v1” and “assistants=v2” in the headers. There is no “status” key.

`//Response for assistants=v1:
{
    "id": "msg_E1KHpEddo5okJGuWz7hNyKV5",
    "object": "thread.message",
    "created_at": 1714869955,
    "assistant_id": "asst_MlSfNr6U1xP9bdgMGPd9tQzI",
    "thread_id": "thread_Kqq4ES4zSxEDTByN3zd1JCEk",
    "run_id": "run_q4wHZlXe7QQAdZgWjLkW4xqa",
    "role": "assistant",
    "content": [
        {
            "type": "text",
            "text": {
                "value": "Feel free to ask for more details or specific events if needed!",
                "annotations": []
            }
        }
    ],
    "file_ids": [],
    "metadata": {}
}

//Response for assistants = v2
{
    "id": "msg_E1KHpEddo5okJGuWz7hNyKV5",
    "object": "thread.message",
    "created_at": 1714869955,
    "assistant_id": "asst_MlSfNr6U1xP9bdgMGPd9tQzI",
    "thread_id": "thread_Kqq4ES4zSxEDTByN3zd1JCEk",
    "run_id": "run_q4wHZlXe7QQAdZgWjLkW4xqa",
    "role": "assistant",
    "content": [
        {
            "type": "text",
            "text": {
                "value": "Feel free to ask for more details or specific events if needed!",
                "annotations": []
            }
        }
    ],
    "attachments": [],
    "metadata": {}
}`

Added by Python

I’ve got it as None or null with the (retrieve) message method (by individual message ID). Python openai 1.26 (which has it as a validation type).

get https://api.openai.com/v1/threads/{thread_id}/messages/{message_id}

>>>message = client.beta.threads.messages.retrieve(
  message_id="msg_4xrZJi49...",
  thread_id="thread_nmSSVF...",
)
>>>print(json.dumps(message.model_dump(), indent=2))
{
  "id": "msg_4xrZJi49...",
  "assistant_id": "asst_AI0PRu...",
  "attachments": [],
  "completed_at": null,
  "content": [
    {
      "text": {
        "annotations": [],
        "value": "It appears there were no search results related ...!"
      },
      "type": "text"
    }
  ],
  "created_at": 1715148407,
  "incomplete_at": null,
  "incomplete_details": null,
  "metadata": {},
  "object": "thread.message",
  "role": "assistant",
  "run_id": "run_GZ88cWCTSC...",
  "status": null,
  "thread_id": "thread_nmSSVF..."
}

However, not actually in the http response:

import os, json, urllib3

thread = "thread_nmSSVFV..."
message = "msg_4xrZJi49..."
url = f"https://api.openai.com/v1/threads/{thread}/messages/{message}"
headers = {
    "Content-Type": "application/json",
    "Authorization": f"Bearer {os.environ.get('OPENAI_API_KEY')}",
    "OpenAI-Beta": "assistants=v2"
}

http = urllib3.PoolManager()
try:
    response = http.request(
        "GET",
        url,
        headers=headers
        # body=json.dumps({"command": "go bananas"})
    )
except Exception as e:
    print(f"Error: {e}")

if response.status != 200:
    print(f"HTTP error {response.status}: {response.data.decode('utf-8')}")
else:
    reply = json.loads(response.data.decode("utf-8"))
    print(response.data)

bytes:

b'{\n "id": "msg_4xrZJi49...",\n "object": "thread.message",\n "created_at": 1715148407,\n "assistant_id": "asst_AI0PRuCNCdfzEQzzTEbHrKBT",\n "thread_id": "thread_nmSSVFVI...",\n "run_id": "run_GZ88cW...",\n "role": "assistant",\n "content": [\n {\n "type": "text",\n "text": {\n "value": "It appears there were no search results related...",\n "annotations": []\n }\n }\n ],\n "attachments": [],\n "metadata": {}\n}'

1 Like

same issue for me.
i’m using the openapi yaml and swift’s openapi generator.
the absence of status in the response is throwing an exception.

will try modifying my copy of openai’s openapi spec

1 Like