# Track AI costs, guard prompts and rebill clients with Claude and Google Sheets

> Quick overview This workflow acts as a shared governance sub-workflow that other n8n workflows call to track per-run AI costs, validate workflow outputs, and screen inputs for prompt injection using Anthropic Claude plus Guardrails. It logs to Google Sheets and sends alerts and reports to Slack and Gmail. How it works 1. Receives a request from another workflow (or a daily scheduled run) and routes it based on the guard value: cost, output, security, or daily report. 2. Calculates estimated cost from model token counts, appends a row to the Google Sheets “Cost Ledger,” and posts a Slack alert if the run exceeds the configured USD limit. 3. Validates outputdata against minimum item count, required fields, and error flags, then logs failures to the Google Sheets “Dead Letter” tab and alerts Slack. 4. Sanitizes incoming text to mask PII, checks for blocked phrases and jailbreak signals using Guardrails backed by Anthropic Claude, and compiles a final allow/block/review security verdict. 5

- **Domain**: `n8n-workflow-22481.n8n.io`
- **Provider**: n8n.io (https://n8n.io)
- **Kind**: workflow
- **Live-responds (last probe)**: None
- **Signed card**: False
- **Streaming**: False
- **Quality score**: 40%

## URLs
- Agent card: https://n8n.io/workflows/22481
- Page (HTML): https://agenstry.com/agents/n8n-workflow-22481.n8n.io
- Documentation: https://n8n.io/workflows/22481
