Overview

bind_session attaches an existing session to the current context for the duration of the with block. The session is not ended on exit — end it explicitly later.

Syntax

with lai.bind_session(session_id: str):
  ...

Parameters

  • session_id (string, required): An existing session id to bind.

Returns

None. Sets the active session for the context.

Example

import lucidicai as lai

sid = lai.init(session_name="request-123", providers=["openai"], auto_end=False)

with lai.bind_session(sid):
    do_work()

lai.end_session()

See Also