A session groups events related to long-term user interactions and can include multiple traces, with each trace potentially having many LLM requests. In a chatbot, a session might represent the whole conversation, while for an agent, it might cover a single task execution. The session’s scope depends on your application’s needs. Baserun uses a session identifier to organize traces and LLM requests into sessions.

OpenAI(session: Optional[str], **kwargs) -> OpenAI:

Arguments

session
string

An identifier for the current session. For example, you might user a session ID from your application framework or authenticiation library.

Instructions

To create a session, simply pass the session when creating the client, or set the property post-instantiation.

client = OpenAI(session="session123")
# Alternatively
client.session = "session123"