Skip to main content
In Literal, the concept of a user is designed to seamlessly integrate with your application, allowing developers to create and manage user profiles that mirror their own application’s user base. It’s important to note that the concept of User only exists at the Thread level, not at the Step level.
The user filter on threads

Filtering Threads by User

Create a User

import os
from literalai import LiteralClient
literal_client = LiteralClient(api_key=os.getenv("LITERAL_API_KEY"))

@literal_client.step()
def my_step(input_message):
    # some code, llm call, tool call, etc.
    answer = "answer"
    return answer

async def run(input_message):
    with literal_client.thread() as thread:
        literal_client.message(content=input_message, type="user_message", name="User")
        user = await literal_client.api.create_user(identifier="John Doe")
        # user = await literal_client.api.get_user(identifier="John Doe")
        thread.user = user
        answer = my_step(input_message)
        literal_client.message(content=answer, type="assistant_message", name="Assistant")
    return answer
I