{"product_id":"track-llm-spend-in-n8n-workflows-budget-alerts","title":"Track LLM Spend in n8n Workflows + Budget Alerts","description":"\u003ch3\u003eTrack LLM Spend in n8n—and get budget alerts before costs spike\u003c\/h3\u003e\n\u003cp\u003eThis n8n workflow automatically monitors your recent executions, extracts LLM token usage, estimates per-call USD cost, logs usage in an n8n Data Table, and sends Slack\/email\/Telegram\/custom webhook alerts when spend goes over budget or suddenly spikes.\u003c\/p\u003e\n\n\u003ch3\u003eWhat this workflow does\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cb\u003eRuns every 15 minutes\u003c\/b\u003e on a schedule to keep spend tracking near real-time.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cb\u003eFetches execution data from the n8n Public API\u003c\/b\u003e since the last saved checkpoint.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cb\u003eExtracts LLM usage\u003c\/b\u003e from AI-related activity, including token usage from chat model sub-nodes and raw provider responses captured from nodes like \u003cb\u003eOpenAI\u003c\/b\u003e, \u003cb\u003eAnthropic\u003c\/b\u003e, \u003cb\u003eGoogle Gemini\u003c\/b\u003e, and \u003cb\u003eHTTP Request\u003c\/b\u003e.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cb\u003eCalculates token totals and estimates cost in USD\u003c\/b\u003e using configured per-model pricing, including flags for \u003cb\u003eunpriced models\u003c\/b\u003e.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cb\u003eLogs only new LLM-call rows\u003c\/b\u003e into an \u003cb\u003en8n Data Table\u003c\/b\u003e using a unique \u003cb\u003ecallKey\u003c\/b\u003e to deduplicate across runs.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cb\u003eAnalyzes the last 8 days\u003c\/b\u003e of usage to detect:\n    \u003cul\u003e\n      \u003cli\u003eBudget overruns per workflow\u003c\/li\u003e\n      \u003cli\u003eSpend spikes vs the prior 7-day daily average\u003c\/li\u003e\n      \u003cli\u003eExcessive calls per execution (looping behavior)\u003c\/li\u003e\n      \u003cli\u003eModels missing pricing\u003c\/li\u003e\n    \u003c\/ul\u003e\n  \u003c\/li\u003e\n  \u003cli\u003e\n\u003cb\u003eOptionally unpublishes over-budget workflows\u003c\/b\u003e when configured, then routes alerts to Slack, SMTP email, Telegram, or a custom webhook.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eUse cases\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003eCatch LLM cost overruns in production automations before invoices arrive.\u003c\/li\u003e\n  \u003cli\u003eDetect runaway loops that trigger excessive LLM calls inside n8n executions.\u003c\/li\u003e\n  \u003cli\u003eMonitor provider usage across OpenAI\/Anthropic\/Gemini—especially when prompts or routing logic changes.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eTechnical details\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003eIntegrates with \u003cb\u003en8n Public API\u003c\/b\u003e (via n8n API key + base URL) to read executions (and optionally unpublish workflows).\u003c\/li\u003e\n  \u003cli\u003eWrites to an \u003cb\u003en8n Data Table\u003c\/b\u003e with columns such as \u003cb\u003ecallKey\u003c\/b\u003e, execution\/workflow metadata, token counts, \u003cb\u003ecostUsd\u003c\/b\u003e, estimated flags, and \u003cb\u003efinishedAt\u003c\/b\u003e.\u003c\/li\u003e\n  \u003cli\u003eUses core n8n nodes including \u003cb\u003eif\u003c\/b\u003e, \u003cb\u003eswitch\u003c\/b\u003e, \u003cb\u003eset\u003c\/b\u003e, and \u003cb\u003ecode\u003c\/b\u003e, plus \u003cb\u003eSlack\u003c\/b\u003e for notifications.\u003c\/li\u003e\n\u003c\/ul\u003e","brand":"N8N Commerce","offers":[{"title":"Default Title","offer_id":46359710335155,"sku":"N8N-22244","price":47.99,"currency_code":"GBP","in_stock":true}],"thumbnail_url":"\/\/cdn.shopify.com\/s\/files\/1\/0749\/6279\/6723\/files\/veeSVILrGlM9O6JScUcpZ_pi56gu4D.png?v=1793696564","url":"https:\/\/buyflowscripts.com\/products\/track-llm-spend-in-n8n-workflows-budget-alerts","provider":"N8N Commerce","version":"1.0","type":"link"}