There are multiple ways to log Threads in your Python applications.

Using the @literal_client.thread decorator

Use this decorator before a function to initiate a Thread. This method is a simple and straighforward way of logging Threads.

Using the with statement

If you prefer to have more flexibility in logging Threads, you can use the with statement. You can create a thread and execute code within it using the with statement:

You can also continue a thread by passing the thread id to the thread method:

Using the Literal AI API client

You can also create Threads using the literal_client.api.create_thread() method.

Using Chainlit

If you built your LLM application with Chainlit, you don’t need to specify Threads in your code. Chainlit logs Threads for you by default.

Thread API

Thread API

Manipulate threads directly using the API.

Was this page helpful?