Where can I see all the threads I've created with the API?

Inactive threads are maintained for 60 days.

This means that if you made a chat interface like ChatGPT for a user, and recorded all that user’s thread IDs (and maybe a topic title) for a “past chats” sidebar, they could go back to April and keep chatting, but prior chats would no longer exist or be maintained by OpenAI.

API inputs and outputs are not used for training new models.

The utility that I show is just for an owner with login rights to platform.openai.com that has enabled chat listings for organizations and projects. It is notable that it can simulate either the Playground or your own organization projects, retrieving all organizations and projects from login data, using web session credentials.

The way you should be using threads is to maintain a record of all of them in your own system, along with the user/customer that created them. Even adding customer metadata to the thread so you can be sure that the wrong thread is never displayed. You can then give your user interface a “delete chat” button that actually deletes the data.

In a production environment, the facilities that OpenAI alone offers to manage threads is inadequate, but they don’t seem to mind you leaving thousands of them forgotten.


Thank you for your detailed response.

  1. I appreciate OpenAI’s thoughtful service in retaining my past API personal data. What is the definition of inactive threads? Does it mean that if the API does not call the specific thread ID for two months, it will disappear from OpenAI’s official records, leaving only the thread data on the website?

  2. API inputs and outputs are not used for training new models. If using Playground, Assistant Playground, or GPTs with graphical interfaces, will the data be used as training material like ChatGPT?

  3. Regarding the code you provided, I’m stuck on the first step. I’m not sure what to fill in for OPENAI_OAUTH and OPENAI_API_KEY. If it requires information from the organizational account owner, then it’s not applicable to me since I’m just an invited member of the organization.

token = os.environ.get('OPENAI_OAUTH')
session = None
apikey = os.environ.get('OPENAI_API_KEY')
key = apikey[:7] + "..." + apikey[-4:]
  1. I have strong doubts about the ownership of the API keys I created in https://platform.openai.com/settings/profile?tab=api-keys. I am an invited member of Organization A, but I am an individual B. Can I create API keys that use Organization A’s resources?

How do I know if the generated key consumes personal or organizational usage? Is there a simple way to determine this?

Another issue is, I created an assistant and thread as a member of Organization A, and saved the IDs for the next run. However, it seems that I cannot use key2 to call that thread ID (though later tests showed it is possible, but it’s strange because key2 was created under my personal Default organization).

Sometimes, using different keys to call the same assistant ID and thread ID results in strange messages. I can call the assistant created by Organization A’s member, but the thread ID cannot be found.

This has troubled me for a long time. Now, I mostly set my account role to organization member since it’s free and doesn’t require personal payment.

[Assistant ID and thread stored in a txt file for later use]
Using existing assistant ID: asst_a…
Using existing thread ID: thread_1…

[Strange error message]
TypeError: 'NoneType' object is not subscriptable Traceback (most recent call last): File "c:\ \assistant2.py", line 99, in <module> client.beta.threads.messages.create( File "C:\Users\ \AppData\Local\Programs\Python\Python310\lib\site-packages\openai\resources\beta\threads\messages\messages.py", line 95, in create return self._post( File "C:\Users\ \AppData\Local\Programs\Python\Python310\lib\site-packages\openai_base_client.py", line 1208, in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) File "C:\Users\ \AppData\Local\Programs\Python\Python310\lib\site-packages\openai_base_client.py", line 897, in request return self._request( File "C:\Users\ \AppData\Local\Programs\Python\Python310\lib\site-packages\openai_base_client.py", line 988, in _request raise self._make_status_error_from_response(err.response) from None openai.NotFoundError: Error code: 404 - {'error': {'message': "No thread found with id 'thread_14k............q'.", 'type': 'invalid_request_error', 'param': None, 'code': None}}

An auto-deleted thread from inactivity (not adding new messages or perhaps metadata) should also disappear from the organization playground, as things that no longer exist tend to do. OpenAI doesn’t say what resets a thread inactivity, like if you merely retrieve a message from it.

“GPTs” is a term specifically for those agents created by users in ChatGPT Plus or ChatGPT Teams. They can be used for future training unless using a Team account or unless the creator picks the button not to submit to training (a good selection if the GPT has personal information as its purpose).

Anything API is not trained on since around March 2023. You’d have to go through an opt-in procedure.

I made the thread list utility code and included instructions terse so there is a bar of entry, requiring some knowledge beyond “skript kiddie”.

apikey = os.environ.get('OPENAI_API_KEY') uses a very standard way of employing API keys (safer than writing the API key value into code) - placing it into an operating system’s or virtual environment environment variable. This prevents code leaks from exposing your secrets.


In the API key web interface, you have an option to choose the default organization that is associated with all keys. You can also specify the organization you are a reader or owner of when making an API request, within the request. Keeping this straight is important to ensure that you are placing and employing files and threads in the correct organization - and also billing the right people.

You can see about adding organization ID and project ID to headers here.

The API is not free, you are billing somebody.

Thank you very much.

From my personal experience, my personal account on https://platform.openai.com/threads still retains thread IDs from over 4 months ago. At that time, I was testing content using the assistant playground. The retention period is quite long.

  1. Additionally, if I create an assistant as a member of an organization, can my personal account use that assistant?

Recently, I tested it but was unsure whether I should use “Switch organization” or change the “Default organization” to my personal interface. I’m not sure which action truly switches to my personal role to execute the API. However, when I called the organization’s assistant and created a thread ID, I encountered the following error. When I switched to the personal interface, I found the thread ID, but it had no content.

Using existing assistant ID: asst_.....
Created new thread ID: thread_14.....

raise self._make_status_error_from_response(err.response) from None
openai.NotFoundError: Error code: 404 - {'error': {'message': "No thread found with id 'thread_123456.....'.", 'type': 'invalid_request_error', 'param': None, 'code': None}}

I am understand how to specify the organization you are a reader or owner of when making an API request when writing the code.

  1. Also, if I want to delete a thread from my personal account, although I have the thread ID, it seems I need the key that was used when the thread ID was generated. Using a different key generated by the organization doesn’t work. So, it’s better to keep 1-2 sets of keys. Otherwise, if a key is lost, checking the account data on the website won’t help much, as they are all in the format sk-…XXX.

  2. As an organizational role, I can create Project API keys. How is this different from the old API keys?
    If I generate Project API keys, can all members of the organization see them? The project is always default, so what does this project refer to?

  3. Regarding the code you wrote, as a programming novice, I’m afraid simply changing some strings won’t make it work for me. I’m still not sure how to set up the OAuth token. Currently, I can only see the organization ID and API key.

token = 'org-XXXX'
session = None
apikey = 'sk-XXXXX'