Scheduled workflows are the quiet ones. Nobody clicks anything, so nobody watches them, and every day they make a few model calls with prices attached. The bill lands a month later and the only question left is "which of these did that?". This post answers it with arithmetic you can check, a small ledger pattern for per-workflow attribution, and a free calculator that runs the math in your browser.
I maintain a pack of n8n workflows for salons and clinics, and the same confusion keeps showing up in automation threads: people see AI spend going up and start guessing at the cause. Measure first. Here is the full method.
Two meters run at once
Before any math, split your spend in two, because they have different fixes:
- Build-time spend. The in-app assistant you use while wiring nodes. It runs when you debug, not when the workflow runs. A subscription caps this one.
- Runtime spend. The AI nodes inside scheduled or webhook-triggered workflows. This one scales with executions, and no subscription changes it.
If most of your bill is meter 1, buy the cap. If it is meter 2, the rest of this article is for you.
The arithmetic
Per run, one AI call costs:
(prompt tokens x price in + completion tokens x price out) / 1,000,000
So for a whole workflow:
cost per run = AI calls per run x the line above + other metered cost per run
cost per month = runs per day x 30 x cost per run
Three multipliers decide the outcome: how often the workflow fires, how many tokens each call moves, and which model you picked. Rough public list prices per 1M tokens, the same defaults my calculator ships with (edit them to what you actually pay):
| Model | Price in | Price out |
|---|---|---|
| GPT-4o | $2.50 | $10.00 |
| GPT-4o mini | $0.15 | $0.60 |
| Claude Sonnet | $3.00 | $15.00 |
| Gemini Flash | $0.10 | $0.40 |
Example A: a daily digest
Three AI calls per run (summarize, classify, format), one run per day, 2,000 prompt tokens and 500 completion tokens per call.
| Model | Per run | Per month | Per year |
|---|---|---|---|
| GPT-4o | $0.0300 | $0.90 | $10.80 |
| GPT-4o mini | $0.0018 | $0.05 | $0.65 |
Same workload, 16.7x the price, because the model multiplier compounds across every call. A dollar a month is not a problem. This example exists as the baseline.
Example B: reply triage every 15 minutes
One AI call per run, 800 prompt tokens, 120 completion tokens, 96 runs per day. This is the shape that surprises people.
| Model | Per run | Per day | Per month | Per year |
|---|---|---|---|---|
| Claude Sonnet | $0.0042 | $0.40 | $12.10 | $145.15 |
| GPT-4o mini | $0.000192 | $0.0184 | $0.55 | $6.64 |
| Gemini Flash | $0.000128 | $0.0123 | $0.37 | $4.42 |
The per-run numbers look like pocket lint: $0.0042, less than half a cent. The schedule turns them into $145 per year, and the same triage on a small model costs $6.64. That 21.9x gap (32.8x against Flash) is the entire business case for per-workflow cost attribution: you cannot right-size what you never measured.
Where the numbers come from
You do not have to estimate token counts. The response carries them. On OpenAI-compatible APIs, the chat completion includes a usage object with prompt_tokens, completion_tokens and total_tokens (this is in OpenAI's published API spec, and the other vendors mirror the shape). Most model nodes in n8n surface that usage in the item's output when you use raw or JSON output mode. Check one execution of your own node before wiring anything below.
The nine-line ledger
Put this Code node after each AI step. It turns every response into a priced ledger row:
// Cost ledger: one row per AI item. Prices are USD per 1M tokens.
const PRICES = {
'gpt-4o': [2.50, 10.00],
'gpt-4o-mini': [0.15, 0.60],
};
const out = [];
for (const item of $input.all()) {
const u = item.json.usage ?? {};
const model = String(item.json.model ?? 'unknown');
const [pin, pout] = PRICES[model] ?? [0, 0];
out.push({ json: {
workflow: $workflow.name,
model,
prompt_tokens: u.prompt_tokens ?? 0,
completion_tokens: u.completion_tokens ?? 0,
cost_usd: Number((((u.prompt_tokens ?? 0) * pin
+ (u.completion_tokens ?? 0) * pout) / 1e6).toFixed(6)),
day: new Date().toISOString().slice(0, 10),
}});
}
return out;
Feed the rows into a Google Sheets node or Postgres and after one day you know which workflow eats the budget, down to the step. If you do not want an external store, keep a running total in workflow staticData instead; getWorkflowStaticData('global') persists between production executions, which is the same mechanism my own workflows use for their send logs and dedup guards.
The classic silent multipliers this ledger will surface:
- a retry loop re-running a large prompt on every failure
- context bloat from re-sending the whole conversation each turn
- a frontier model doing classification a small model does fine
The fix for the last one is boring: route one repeated step to a smaller model for a day and compare the rows.
The calculator
If you want the totals before building the ledger, I made a free tool for exactly this: the n8n AI workflow cost calculator. You list your workflows (calls per run, tokens, model, runs per day, any other metered cost), edit the model prices to your real ones, and it shows cost per run, per month and per year for each workflow plus a total, an AI-versus-other split, and the biggest spender. It runs entirely in your browser, has an English and a Dutch mode, and sends nothing anywhere.
I also have a no-show cost calculator and a waitlist fill-rate calculator for the scheduling side of the same house.
What to do with the numbers
- Right-size per step, not per stack. Classification and routing almost never need the big model. Keep the frontier model where the output quality is the product, and put the small model on the high-frequency steps.
- Cap the retries. An unbounded retry loop multiplies the cost of a failing step until it succeeds or you notice. Bound it and log the failures.
- Trim what you re-send. If each turn re-sends the full history, the prompt grows linearly with the conversation. Send the summary, not the transcript, unless the step truly needs it.
One honest note from my own shop: the workflow pack I sell (€29, Afspraakpack for n8n) deliberately ships without AI nodes, so it adds zero runtime model spend. The cost methods above are for the AI workflows you build yourself. The reminders article that covers the pack's flagship is here, and the weekly KPI digest pattern that gives you a per-workflow measurement habit every Monday is here.
Measure, then switch. The other order just moves the surprise to next month's invoice.
Top comments (0)