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

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

Ready for 3.0

by Kishan Makani ✓ · 4 views · created 2026-11-07

Ready for 3.0. This template uses no nodes that n8n 3.0 removes. No removed nodes, versions or helpers found. Static check, last run 2026-12-01.

📬 Weekly n8n 3.0 breakage alerts, free

What this workflow does

This AI workflow has 38 nodes and runs when another workflow calls it (plus 2 other triggers). Along the way it connects Google Sheets, Slack, Guardrails and Anthropic Chat Model and 1 more.

How it runs

Trigger: When another workflow calls it (plus 2 other triggers).

  1. Workflow Configuration (Edit Fields (Set)): sets 12 fields: cost_alert_usd, block_when_over_cost_limit, pricing_per_million_tokens…
  2. Sample Guard Requests (Code): runs custom JavaScript code
  3. Route by Guard (Switch): routes items into 4 branches
  4. Call AutoGuard (Execute Sub-workflow): calls another n8n workflow
  5. Calculate AI Cost (Code): runs custom JavaScript code
  6. Validate Workflow Output (Code): runs custom JavaScript code
  7. Mask Personal Data (Guardrails): sanitize
  8. Read Cost Ledger (Google Sheets): uses Google Sheets
  9. Return Unknown Guard Error (Edit Fields (Set)): sets 4 fields: guard, allowed, verdict…
  10. Log to Cost Ledger (Google Sheets): append

…plus 24 more steps. See the full node list below.

Services it uses

Google SheetsSlackGuardrailsAnthropic Chat ModelGmail

Before you upgrade to n8n 3.0

Nothing in this workflow is removed in n8n 3.0, so it should import and run after the upgrade.

Check at runtime on n8n 3.0
  • Code node: the task timeout drops from 300s to 60s. Test with a realistic data volume.
Informational: a static scan can't see the data, so test these on your own instance. Status above is unchanged.

Nodes used (15)

From the author

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…

Excerpt from Kishan Makani's description on n8n.io.

View the original on n8n.io → Check your own copy

Get the weekly “what broke” email

New templates, newly broken ones, and n8n release changes. One short email a week.

Form not loading? Subscribe here.