Alexandria is a local daemon that turns your AI subscriptions (Claude Max, ChatGPT/Codex, SuperGrok, Gemini) into one OpenAI/Anthropic-compatible endpoint on 127.0.0.1:4100 — with a credential vault, automatic token refresh, model routing, format translation, full trace capture, and usage/limit tracking.
Point any coding harness (Claude Code, Codex CLI, grok, opencode, …) at it and every request is authenticated with the right subscription, billed to the right bucket, and captured to SQLite for inspection.
Features
- Credential vault — imports OAuth tokens from Claude Code, Codex, grok, and gemini CLIs; stores them in
~/.alexandria/accounts/(0600); refreshes them itself (Anthropic, OpenAI, xAI) - One endpoint, every provider —
/v1/messages,/v1/chat/completions,/v1/responseswith cross-format translation and model routing (claude-*→ Anthropic,gpt-*→ Codex,grok-*→ xAI) - Login flows built in —
alex auth login claude|codex|grok(PKCE paste, loopback, and xAI device-code flows); also exposed over HTTP so GUIs can drive re-auth - Trace capture & sessions — every request/response stored with tokens, cost, latency; group runs with
x-session-id, tag withx-alexandria-*headers, search body text, stitch transcripts - Trace Browser & TUI — a two-pane live trace browser in the menu bar app,
alex tuiin the terminal,alex traces --jsonfor scripts - Limits & health — subscription plan windows (5h/7d) with utilization and reset times, per-provider heartbeats,
alex ping,alex status - Cost analytics — per-model requests/tokens/cost with subscription-vs-API billing buckets (
/admin/analytics) - Dario mode — optional generational supervisor for the
@askalf/darioAnthropic upstream with health probes, npm auto-update, and rolling restarts - macOS menu bar app — live gauges, re-auth windows, ping checks, window-reset alerts in
macos/(AlexandriaBar) - Harness smoke tests —
alex harness runexecutes frozen CLI harnesses (claude, codex, grok, …) in Docker against the proxy and verifies traces land - Zero-downtime upgrades —
./install.sh --upgradeblue-greens the daemon on a shared port (SO_REUSEPORT) - Cross-platform CLI — Linux, macOS, and Windows binaries on every release (
cargo install alex)
Install
# or from a checkout:
Quick start
Re-auth a subscription any time with alex auth login claude|codex|grok, watch live traffic with alex tui, and check window utilization with alex limits.
Sessions & trace tagging
Generate client credentials for the proxy, then tag requests so every trace from a run lands in one named session:
SESSION="experiment-42"
Every response carries an x-alexandria-trace-id. Typed headers (x-alexandria-harness|task|model|job) and free-form x-alexandria-trace-tag: key=value tags are captured with each trace. Collect a session back out:
Trace Browser
The menu bar app's Trace Browser gives the same data a UI: two-pane sessions + live transcript, an omni bar combining free text with model:, harness:, task:, job:, tag:key=value, status:, run: and session: filters, live/pin modes, and per-turn token/cost breakdowns.
macOS menu bar app
macos/ contains AlexandriaBar, a Swift menu bar app that shows daemon health, subscription limit gauges, and account status — with in-app re-auth (device codes, paste flows), ping checks, and notifications when a subscription needs attention.
&&
Re-auth helpers
When a subscription expires you get a notification and a one-click fix. Each provider gets the flow that suits it: Codex opens the browser and finishes automatically via the localhost callback (above), Grok shows an xAI device code you can enter from any device, and Claude takes the pasted code#state. The same flows are served by the daemon (POST /admin/auth/login/start, poll GET /admin/auth/login/<id>), so any UI can drive them — the terminal equivalent is alex auth login <provider>.
Crates
| Crate | What it is |
|---|---|
alex |
The daemon + CLI (binaries: alex, alexandria) |
alex-core |
Routing, translation, usage & pricing logic (pure, no I/O) |
alex-auth |
Credential vault, OAuth/device login flows |
alex-store |
SQLite trace store & analytics |
alex-proxy |
axum ingress, admin API, upstream clients |
Development
&&
License
Dual-licensed under MIT or Apache-2.0, at your option.