Python package missing option to list all Threads

Hi,

I have been browsing for a couple of days, but can’t seem to find a way to get a list of all my active threads via python package.
There is no OpenaAI().threads.list() function and OpenaAI().threads.retrieve() returns only one given thread.
Any idea how to get all of them listed?

1 Like

Hi - as far as I can tell, there is no way to list all current threads for an assistant. One solution is making sure you store the thread id upon creation, allowing you to retrieve and manage it later.

1 Like

Do you know for how long the threads exist? There is no thread “status” field.
I’d definitely need threads list endpoint.

So far seems that threads don’t have any TTL set so I’d assume foreverish(?).
There is no explicit status parameter on threads, but there is metadata which can be used to access and read and update custom key-value pairs. So perhaps this could work in your use case?
For now I’m sticking with run status which is all I require to make sure my runs happen sequentially one after another.

Now I do store them. A pitty some of the older ones are inaccessible for now. Also would like to keep the space tidy and not leave threads just hanging around.

Just tested, calling HTTP GET https://api.openai.com/v1/threads does return a list of threads that the api key can access. For some reason, it’s just not present in the package and not in the documentation either :person_shrugging:

:point_up: @BernardasJuzumasB

3 Likes

Please be carful of reliance on undocumented return payloads from API calls, they cannot be guaranteed to exist after updates or fixes, by all means experiment and test your use cases, but unless a feature is documented do not build commercial applications upon it.

Understood. Though listing threads would be a quite useful feature (and it’s a central feature in almost any REST API that creates, reads, updates and deletes items).

Another useful one would be the possibility to search a thread by metadata set to it. This would allow building bots against the Assistant API without the need to set up a database on the client side. One could store the user id or some hash to metadata, and later fetch the user’s thread(s) with a simple API call.

4 Likes

Surprised that we cant get list of threads when they form the basis/foundation of the conversation. The thread is effectively the conversation history that assistants and users contribute to. hopefully its fixed/addressed relatively soon.

I’d be curious to learn who at openai was on point to deliver on threads and fell behind keeping up with the 11/6 dev day deployment?

Hi, thanks, but it doesn’t seem to work with API key I generated. Do you suggest using bearer from platform UI?

{
    "error": {
        "message": "Your request to GET /v1/threads must be made with a session key (that is, it can only be made from the browser). You made it with the following key type: secret.",
        "type": "invalid_request_error",
        "param": null,
        "code": "missing_scope"
    }

@BernardasJuzumasB Something has changed on the OpenAI side, the call i made earlier doesn’t work anymore. So I guess all we can do is hope such a method will be officially added at some point :person_shrugging:

UI session key still works though :slight_smile:

1 Like

So maybe there’s a ‘all my threads’ UI in the works :crossed_fingers:

Any update on this? Listing all threads belonging to an assistant via the API seems like it should be standard. Am I missing something?