AI Ledger
Overview
AI Ledger is a self-hosted logger for AI usage, raw transcript archive, and monitoring dashboard for my coding sessions. I built it so that every conversation, thinking block, tool call, and token count from my macOS and Linux machines is saved in one local database without proxying or modifying API traffic to providers.
How It Works
Instead of intercepting requests, a lightweight background collector (ai-ledger-collector) monitors the local session logs that AI harnesses already write to disk. It supports Claude Code, Codex, Antigravity, T3 Code, and Hermes Agent, and it uploads incremental chunks over LAN or Tailscale to a single self-hosted server (ai-ledger-server).
- Lossless archive first: Every byte from every device is written untouched to disk, and overwritten snapshots are versioned automatically. The SQLite index can be rebuilt completely from the archive at any time with
ai-ledger-server reparse. - Fast, compact SQLite snapshots: For tools that store state in SQLite, the collector creates WAL-safe online snapshots and compresses them with deterministic Zstd. For T3 Code, it extracts only the 24 tables for metadata and orchestration rather than redundant UI projections, shrinking a ~990 MB local database to ~1.5 MB in under 100 ms.
- Single static binaries and minimal Docker image: Both the server and collector compile as
CGO_ENABLED=0static Go binaries using pure-Go SQLite (modernc.org/sqlite) with FTS5. The server embeds the React + Vite dashboard, versioned SQL migrations, and timezone data into an ~18 MB multi-archFROM scratchcontainer image.
Sessions, Inspector, and Full-Text Search
You can filter sessions by preset or custom date ranges, harness, model, device, and project. Date filters match sessions by their last activity so that resumed multi-day threads still appear. Opening a session displays the full conversation, collapsible reasoning and thinking blocks, paired tool inputs and outputs, and telemetry for token counts and rate limits on each call. You can also download the raw log file or export redacted JSONL for training and analysis.
Transparent Model Pricing & Overrides
Token costs are calculated separately for uncached input, discounted cache reads, 5-minute and 1-hour cache writes, and output tokens so that cache hits are priced accurately and never double-counted. A dedicated Settings view shows where each model's rate comes from in priority order: manual overrides, a custom rates file, synced T3 or LiteLLM rates, or built-in defaults. From that view, you can override the rate per million tokens for any model and recalculate historical costs right away.