Log the token cost of every LLM call to Postgres, tagged by client and project, and stop the workflow when a monthly budget is used up (workflow + SQL)
Say you run workflows for five clients on one OpenAI key. The usage page shows one total. It doesn't tell you which workflow or which client spent it, and if one of them loops overnight, the first place you'd notice is the invoice.
Here's a pattern you can put around any LLM call in n8n to fix that. Five nodes plus a trigger, Postgres for storage.
Workflow JSON, SQL and README: https://gist.github.com/jsangiuliano-ai/20f46eee0e48054d7121882ef4f4e188
Log the token cost of every LLM call to Postgres, tagged by client and project, and stop the workflow when a monthly budget is used up (workflow + SQL)
Say you run workflows for five clients on one OpenAI key. The usage page shows one total. It doesn't tell you which workflow or which client spent it, and if one of them loops overnight, the first place you'd notice is the invoice.
Here's a pattern you can put around any LLM call in n8n to fix that. Five nodes plus a trigger, Postgres for storage.
Workflow JSON, SQL and README: https://gist.github.com/jsangiuliano-ai/20f46eee0e48054d7121882ef4f4e188