List Threads
Get a list of threads within your project.
Before using the Threads API, make sure you have set up the REST API integration.
Threads are a fundamental component of the Langtail API, designed to manage and maintain the state of conversations with AI assistants. Here’s how the Threads API works:
-
Creation: A thread can be created either as a new conversation or by referencing an existing thread ID.
-
Message Storage: Threads store all messages exchanged during a conversation, including both user inputs and assistant responses.
-
Conversation Continuity: By using thread IDs, you can maintain context across multiple interactions, allowing for coherent, ongoing dialogues.
Pagination
This endpoint supports pagination in the same way as the OpenAI API. Specifically, it follows the pagination mechanism described in the OpenAI API documentation for listing Assistants.
Here’s how it works:
-
The
limit
parameter allows you to specify the maximum number of threads to return in a single request. The default and maximum value is 100. -
The
after
parameter is used as a cursor for pagination. It should be set to any thread ID from which you want to retrieve the next set of results. -
To fetch the next page of results, make a new request with the
after
parameter set to the ID of the last thread in the current response. -
The response includes a
has_more
parameter, which indicates whether there are more results available.
This pagination approach allows you to efficiently retrieve and process large numbers of threads in manageable chunks.
Headers
Your Langtail API Key
Query Parameters
The maximum number of threads to return. Default is 100.
A cursor for use in pagination. 'after' is a thread ID that defines your place in the list. For instance, if you make a list request and receive 100 threads, ending with thread 'xyz', your subsequent call can include after='xyz' in order to fetch the next page of the list. Pagination works the same as in the OpenAI API https://platform.openai.com/docs/api-reference/assistants/listAssistants.
Response
list
The ID of the first thread in the list, or null if the list is empty.
The ID of the last thread in the list, or null if the list is empty.
Whether there are more threads available after this batch.
Was this page helpful?