Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.literalai.com/llms.txt

Use this file to discover all available pages before exploring further.

Thread

class Thread(Utils)

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:
with literalai_client.thread() as thread:
    # do something
You can also continue a thread by passing the thread id to the thread method:

previous_thread_id = "UUID"

with literalai_client.thread(thread_id=previous_thread_id) as thread:
    # do something

Using the Literal AI API client

You can also create Threads using the literalai_client.api.create_thread() method.
thread = literalai_client.api.create_thread(
    participant_id="<PARTICIPANT_UUID>",
    environment="production",
    tags=["tag1", "tag2"],
    metadata={"key": "value"},
)

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.