Why AI Model Calls Need a Budget Row in Your Database, Not a Browser Key
A software engineering opinion piece argues that wiring AI model calls directly through the browser — with provider keys stored in local storage — creates uncontrolled write authority over stored data such as invoices and comments. The author contends that every model call capable of affecting stored state must be validated against a tenant budget row before any write is permitted, with the server returning a 402 status if the budget is insufficient. Without this constraint, successful model responses and user auth checks alone can silently allow unintended or duplicated writes to persist in the database. The piece proposes a reference schema using two tables — one tracking inference budgets per tenant and purpose, and another logging spend events with a unique idempotency key to prevent duplicate charges from network retries. The core argument is that missing budget enforcement is a database constraint problem, not an AI or vendor SDK problem, and must be solved at the only layer that can refuse a write.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in