Architecture
Three realms, separate by design
| Surface | Credential | Protects |
|---|---|---|
Chat (/v1/*) |
Per-user inv_ key (hashed) |
BYOK failover routing |
Tools (/mcp) |
OAuth bearer (hashed, revocable) | 19 MCP tools + confirmations |
Account (/auth/*) |
Signed session cookie | Projects, keys, state |
Realms never merge and never fail open.
Request paths
- Chat: AI client -
inv_ key-> gateway (auto/pinned/chain over your credentials) -your order-> your providers. - Tools: MCP client -
Bearer->/mcp(denylist + confirmation) -agent routing-> paired machine (home-relative sandbox). - State: account -
owner scope-> PostgreSQL (sessions, memory, tasks) -projections-> dashboard (usage, history).
Single failover loop
Exactly one attempt loop exists (router._iter_attempts);
route_request/stream_open are thin wrappers. Run recording writes
one runs row per upstream attempt; the dashboard aggregates
attempts, failovers, and tokens by day and provider/model.