Walt

AI Proxy + Savings Ledger

Transparent OpenAI-compatible proxy to Sibyl/Carousel with SQLite cost ledger + SSE feed.

AI Proxy + Savings Ledger (v2026-08-02T101544Z-ab2bbdebf5) 2026-08-01 | Transparent OpenAI-compatible proxy to Sibyl/Carousel with SQLite cost ledger + SSE feed. Request Handling Client POST /proxy/v1/chat/completions GET /proxy/savings ai_proxy_router.py openai_proxy() _forward_to_sibyl() request payload Sibyl Interaction Sibyl Carousel http://localhost:{_daemon_port}/api/carousel/ask ai_proxy_router.py _forward_to_sibyl() translated req… Data Storage SQLite Ledger ai_proxy_savings.db ai_proxy_router.py _record() savings record 1. Client sends request to proxy 2. Proxy translates and forwards req… 3. Sibyl processes the request and r… 4. Proxy calculates savings and reco… 5. Proxy returns response to client Request Payload (OpenAI chat) { "messages": [{"role": "user", "content": "Hello!"}], "stream": false } Savings Record (SQLite) { "id": "123e4567-e89b-12d3-a456-426614174000", "ts": 1672531200.0, "target": "openai", "model": "gpt-3.5-turbo", "tokens_in": 100, "tokens_out": 200, "direct_usd": 0.75, "sibyl_usd": 0.60, "saved_usd": 0.15, "latency_ms": 123.45, "status": "ok" } The proxy does not handle SSE streaming directly; it forwards the stream to the client. Legend actor = initiates work · process = code path · store = state on disk · bus = durable queue · dashed = separate process cyan = request flow · pink = state read/write · dashed green = pull / return path · red = refusal

Provenance

This drawing is generated, not drawn. It is rebuilt from the source files below, so when they change the picture changes — a diagram here cannot quietly describe a system that no longer works this way.

Owner
Walt
Slug
ai-proxy-savings
Rendered
2026-08-02T101544Z
From commit
ab2bbdebf5
Watches
1 path
  • daemon/src/ai_proxy_router.py