Walt

AI Proxy + Savings Ledger

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

AI Proxy + Savings Ledger (v2026-08-22T175604Z-b502e8bc6d) 2026-08-22 | Transparent OpenAI-compatible proxy to Sibyl/Carousel with SQLite cost ledger + SSE feed. 1 - REQUEST HANDLING - Handling incoming requests Client POST /proxy/v1/chat/completions POST /proxy/v1/completions POST /proxy/anthropic/v1/messages openai_proxy daemon/src/ai_proxy_router.py:150 x_target_url: Header anthropic_proxy daemon/src/ai_proxy_router.py:200 request payload request payload 2 - FORWARDING TO SIBYL - Forwarding requests to Sibyl _forward_to_sibyl daemon/src/ai_proxy_router.py:220 httpx.AsyncClient _SIBYL_CAROUSEL Sibyl Carousel http://localhost:{_daemon_port}/api/carousel/ask translated pay… 3 - SAVINGS CALCULATION - Calculating savings and recording _record daemon/src/ai_proxy_router.py:100 sqlite3.connect bus.publish ai_proxy_savings.db proxy_calls table graphify-out/*.json event_bus ai_proxy:saved savings data savings record 1. Client sends request 2. openai_proxy/anthropic_prox… 3. Forwards to Sibyl 4. Calculates savings 5. Records savings 6. Publishes savings event Request payload example { "messages": [ {"role": "user", "content": "Hello!"} ], "stream": false } Savings record example { "id": "123e4567-e89b-12d3-a456-426614174000", "ts": 1672531200.0, "target": "anthropic", "model": "claude", "tokens_in": 100, "tokens_out": 200, "direct_usd": 1.5, "sibyl_usd": 1.0, "saved_usd": 0.5, "latency_ms": 200, "status": "ok" } The system uses environment variables for configuration, such as KEVIN_PORT_DAEMON and SIBYL_CAROUSEL_URL. 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 As of 2026-08-22 22:15 UTC, from commit d94c202

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-22T175604Z
From commit
b502e8bc6d
Updated
22 Aug 2026, 22:15 UTC
Sources at
d94c202
Watches
1 path
  • daemon/src/ai_proxy_router.py