Library / Monitoring, Ops & Incidents
Monitoring, Ops & Incidents
Cap daily AI spend per workflow with Data Table, Google Sheets and Slack
Sub-workflow that AI workflows call before and after each model call to check and record spend against a daily budget, stopping runaway usage and sending Slack alerts.
What it does
## Cap daily AI spend per workflow and alert in Slack n8n counts executions, not dollars. A looping agent, an unexpectedly busy day or a prompt that pulls in far more context than you planned can run up a large model bill overnight, and nothing in the platform stops it or tells you. This is a sub-workflow that gives every AI workflow its own daily ceiling. ### How it works An AI workflow calls this twice. Before the model, with action check, it gets back whether the call fits inside today's remaining budget, so a runaway is stopped at the next call rather than found on the invoice. After the model, with action record, it passes the usage object straight through and the call is priced and added to the day's total. Prices sit in a sheet rather than in the code, because they change every few weeks, and a model missing from that sheet is charged at a deliberately pessimistic fallback rate rather than counted as free, which is how budgets quietly stop working. Each workflow gets its own cap and its own Slack channel from a Budgets tab, with one row named default catching everything else. The day boundary follows the offset you set, not UTC midnight. Slack is told once when the warning line is crossed and once when the cap is reached, never on every call after. The next morning, one message reports what each workflow cost and which ones ran into their ceiling. ### Setup Connect Sheets and Slack, create the data table with the columns on the ledger node, and fill the Budgets and Model Prices tabs. ### Note This caps workflows that call it. It cannot police one that does not, so wire it into the expensive ones first.
The steps
- Called By Your AI Workflow
- Read The Request
- Load Budgets
- Load Model Prices
- Resolve Budget And Day
- Read Today's Ledger Row
- Check Or Record?
- Decide Allow Or Block
- Return The Decision
- Price The Call
- Update The Ledger
- Crossed A Threshold?
- Send The Budget Alert
- Return The New Total
19 steps in total.
Similar automations
Code, Git & Developer ToolsTrack LLM token spend per workflow with n8n API, data tables, and Slack alerts11 stepsMonitoring, Ops & IncidentsDetect ad spend anomalies and pacing issues across Google Ads, Meta and GA423 stepsEmail AutomationTrack LLM spend per workflow and send budget alerts via the n8n API16 stepsWeb Scraping & ResearchScrape Market Caps with Bright Data to Telegram Charts10 steps