Reference Spec · v1 (SaaS & AI Monetization)1 REQ -> 1 TC · 0 Orphans
Usage-Based AI Token Metering & Hard Spend Caps
Meter prompt/completion token costs in an append-only Postgres ledger and block upstream inference within 15ms once a tenant's hard monthly cap is reached.
Actor: Tenant AdminActor: AI Proxy Gatewayv1 Non-Goals: Multi-currency FX conversion · Prepaid crypto wallets
Locked Scope Assumptions
ASM-001Record immutable ledger entries keyed by request_id to prevent double-charging on retries.
US-001 · Slice #1FEAT-01
Enforce Pre-Flight Monthly Spend Cap
As a Tenant Admin, I want LLM proxy calls blocked immediately when monthly spend reaches 100% of my cap so that runaway agent loops cannot generate surprise invoices.
Entry SurfacePOST /v1/chat/completions Proxy + Budget Settings UI
Domain LogicSpendCapGuardService
Persistence / ExternalPostgreSQL token_ledger_entries & tenant_budgets