This example shows the websocket part of the Python SDK with a small terminal chat UI around it.
The important SDK flow is visible in main.py:
- Create an
AsyncPlatformClientwith the publishable API key and access token. - Open a websocket with
await client.open_socket(). - Join a thread with
ApiChatChannel.join_user_thread(...)orApiChatChannel.join_team_thread(...). - Wrap the generated channel in
ThreadChatSession. - Pass the session into
ThreadChatTui. - Keep websocket operations in
ThreadChatSessionand terminal rendering inThreadChatTui.
export ARCHASTRO_API_KEY=pk_...
export ARCHASTRO_ACCESS_TOKEN=sat_...
uv run python examples/thread_chat_tui/main.py thr_...For a team-scoped thread:
uv run python examples/thread_chat_tui/main.py thr_... --team team_...For local development or another environment:
export ARCHASTRO_PLATFORM_BASE_URL=http://localhost:4000
uv run python examples/thread_chat_tui/main.py thr_...Inside the UI, press Enter to send and Ctrl-D or Ctrl-C to exit.