In this categoryIntegrations · 69
Chat Apps & Bots
Docs, Sheets & Email
IntegrationsAdvanced

How to Cap AI Spend on a Webhook Across Zapier, Make, and n8n

Add per-day request counters and short prompts so a busy webhook cannot blow past your AI budget.

9 minAdvanced

When a webhook calls a paid model on every request, a sudden spike or a runaway sender can cost real money fast. The defense is a simple daily counter plus disciplined prompting. The same idea works in Zapier, Make, and n8n; only the storage step differs.

What you need

  • An AI webhook already running in Zapier, Make, or n8n
  • A counter store: Storage by Zapier, a Make Data store, or n8n static data
  • A daily request limit you are comfortable paying for

Step 1: Read and bump a daily counter

At the start of the workflow, read a counter keyed by today's date, for example calls-2026-06-21. If it is at or above your limit, stop before the model call. Otherwise increment it and continue.

n8n Code node - daily cap
const day = new Date().toISOString().slice(0, 10);
const data = $getWorkflowStaticData('global');
const key = 'calls-' + day;
data[key] = (data[key] || 0) + 1;

if (data[key] > 500) {
  throw new Error('Daily AI limit reached - skipping model call');
}
return $input.all();
Make - Data store counter
Data store: ai_budget
key value
2026-06-20 500 (capped)
2026-06-21 137
Limit: 500 / day
A single record per day tracks how many model calls have run.
Set a hard limit at the provider too
Workflow counters are your first line, but also set a monthly usage limit in your OpenAI or Anthropic billing dashboard. That cap stops spend even if a workflow logic bug slips through.

Step 2: Shrink the prompt and output

Cost scales with tokens. Trim the input to only what the model needs, set a low max_tokens, and pick a smaller model when the task is simple. A classification job rarely needs a flagship model.

lean request body
{
  "model": "gpt-5-mini",
  "max_tokens": 60,
  "messages": [
    { "role": "user", "content": "{{trimmed_input}}" }
  ]
}

Step 3: Alert when you near the cap

Add a branch that sends a notification when the counter crosses, say, 80 percent of the limit. You find out before the cap kicks in rather than after requests start failing.

log - cap reached
calls-2026-06-21 = 500
Daily AI limit reached - skipping model call
request returns a friendly 'try again tomorrow'
$

Result: even a flood of webhook traffic stops at your chosen daily ceiling, so your AI bill stays predictable no matter what hits the URL.

Watch related tutorials

Free weekly email

New guides in your inbox

Fresh step-by-step how-to guides as we publish them. One email a week, no more.

Tags
#budget#rate-limit#webhooks#automation