Server mode

One Xi server holds many chats, and any number of terminals and browsers join them. Run it on your workstation to use your phone, or on a box that is always on.

Starting it

xi server              # server + a terminal client in the same process
xi server --headless   # server only; join from elsewhere

The server listens on port 1414 (--port or XI_PORT change it) and on every network interface, so other devices on your LAN or your Tailscale network can reach it. Loopback is always included.

xi server --headless --host 100.64.0.10    # also bind one specific address

A terminal joins with:

xi join              # the most recent chat
xi create            # a new chat
xi join host:1414    # a server elsewhere

A plain xi in a directory joins a running local server on its own; pass --no-auto-join to stay standalone.

Pairing

Every client proves itself with a key. The terminal on the server's machine is trusted automatically. A new browser gets a four-digit code and waits until it is approved:

xi clients pending          # code, device name
xi clients approve 1234
xi clients                  # approved devices
xi clients revoke iPhone    # by name or key prefix

An already-paired browser shows a banner for the request and can approve it too. The server picks approvals up within two seconds. Revoking a device applies to its next connection.

A browser page from another site can never reach the server: the key is required before any message is processed, and the server refuses connections from other origins. The device name and platform shown with a code are what the device claims; the code is the check.

FileWhat
~/.config/xi/client-keyThe key of the terminal on this machine, created on first run and trusted as is
~/.config/xi/clients.ednApproved devices, each with an optional :user assignment
~/.config/xi/pending-clients.ednRequests waiting for approval

The web client keeps its key in the browser's storage, so each browser pairs once. A server started with --agent does not pair at all.

Users

Several people can share one server. Every connection belongs to a user, a short id such as root, alice or team-ops. Xi uses it to tell people apart: a prompt someone else sent shows their id above it, the chat's top bar shows who else is in the room, and live chats in the list show an avatar for each other user in them (once the server knows more than one user). Nothing is verified. Pairing decides whether a device may connect at all; the user id only says who it is.

The default user is root. A terminal picks another with --user:

xi join --user alice               # this terminal acts as alice
XI_USER=alice xi                   # the same, from the environment

A paired browser or phone is assigned on the server:

xi clients                          # devices, with their user if assigned
xi clients user iPhone alice        # by name or key prefix
xi clients user iPhone -            # back to unassigned

An assignment applies the next time the device connects and wins over whatever the device claims. A browser without one can claim an id itself by setting the xi-user key in its local storage; otherwise it is root.

When the config declares users besides root, the web client's sidebar shows the current user's avatar left of the Claude usage. Clicking it lists every user; picking one sets xi-user and reloads the page as that user. A device with an assignment from xi clients user stays on that user. There is no login: anyone who can connect can pick any user, and the config is the only list of who exists. Checking who may be whom is left to extensions.

What each user's chats may do is up to your rules: a rule can name users by id or by their :meta, for example a role. Pin each device with xi clients user first, or anyone can pick a user with more rights. Tutorial: users and roles walks through a setup with admins, guests and a role an extension grants.

An id is lowercase letters, digits, ., _ or -, up to 64 characters. Anything else counts as root.

To give people a profile, declare them in the config file:

:users {"alice" {:name "Alice" :avatar "https://example.com/alice.png"
                :meta {:team "ops"}}
        "bob"   {:name "Bob"}}

That is optional. A user nobody declared works the same, and shows as a circle with their initials; the declaration adds a display name, an avatar image and metadata that extensions can read. The name and avatar are visible to every client, the metadata is not. See Configuration.

A user's web client choices, such as the theme and which sidebar groups are collapsed, are kept per user on the server, so they follow the user from one device to the next. So are which chats they have read and which they hid from the Recent list. See The web client. Configuration is not per user: the config file, rules, MCP servers and extensions are the same for everyone.

That is all the server does with users. Roles and real authentication are left to extensions: every event a client sends carries the sender's user id, a room's member list is part of its state, and extensions can read a user's profile and keep their own data about each user. See Users and their state.

Chats keep running

A chat whose agent is working stays open with nobody watching. Close the laptop, and the task finishes; the result waits in the chat list. A chat only closes when it is idle and empty.

A restart does not lose a working chat either. When the server is back it continues every chat it cut off mid-turn, whether or not anyone has it open, and sends the messages that were queued behind that turn. A chat cut off more than a day earlier waits until you open it.

Starting a chat over HTTP

Another program can start a chat without a client attached:

curl -sX POST http://localhost:1414/api/rooms \
  -H "Authorization: Bearer $(cat ~/.config/xi/client-key)" \
  -H 'Content-Type: application/json' \
  -d '{"prompt":"Run the tests and fix what fails","cwd":"/home/me/my-app"}'
{"room-id": "r-…", "session-id": "01a0…", "cwd": "/home/me/my-app",
 "url": "http://localhost:1414/chat/01a0…"}

The key goes in Authorization: Bearer <key> or X-Xi-Client-Key; any approved key works, and the local client-key file is one. The body is JSON, every field optional:

FieldDoes
promptThe first message; with it, the agent starts at once
imagesAttachments for the first message, shown in it like pasted ones: [{"data": "<base64>", "media_type": "image/png"}]; a non-image file also takes a name
cwdThe directory to work in; default the server's
modelA model; default the server's

401 is a bad key, 405 a method other than POST, 400 a body that is not JSON. The same endpoint is served on the HTTPS port. Open the returned URL to watch, or to continue the chat.

HTTPS

Over plain HTTP an iPhone forgets a home-screen app's pairing on most launches. Give the server a certificate and it serves https:// on port 1443 as well:

mkdir -p ~/.config/xi/tls
# put xi.crt and xi.key there (mkcert works well for a home network)
xi server --headless

The phone needs to trust the certificate once. HTTPS walks through it.

Keeping it up

The server is a long-lived process, so run it under a supervisor: a systemd user service, launchd, or a tmux session. If a stray error escapes, the server logs it to ~/.config/xi/crash.log and keeps running rather than dropping every client.

The terminal client never leaves your shell broken. An error while handling one key press is recorded in the same file and dropped, so the next key still works. An error it cannot recover from restores the terminal (cursor, mouse, normal screen), prints the error and exits.

Reference

Every flag: Command line. How rooms, broadcast and the wire protocol work inside: docs/architecture.md in the repository.