Building n8n automations for several clients: how do you split and rebill the AI costs?

Hi all,

I’m a freelance AI engineer in Germany, and I keep hearing the same pain from people who build n8n automations for several clients: the build is fine, but month-end is messy. Working out what each client actually cost in OpenAI/Anthropic calls, so it can go on their invoice, seems to be a lot of manual digging.

There was a good thread on this in July (“How do you track which client’s workflows are burning your API credits?”), and the point about Execute Workflow not carrying the client tag stuck with me. I’m curious how people handle it a few months on:

  1. One credential/project per client, or do you log tokens per execution (Sheets, Postgres, Airtable…) and add them up?
  2. If you also run voice agents for the same clients, do the per-minute costs go on the same invoice as the LLM costs?
  3. Pass-through at cost, a % markup, or folded into a flat monthly fee?
  4. Has a looping workflow or retry storm ever surprised you on the bill? What catches it now?

“I eyeball it and add 20%” is a perfectly good answer.

For transparency: I’m exploring a small read-only tool for this, which is why I’m asking. Replies here are the most useful, and I’ll post a summary of what I learn back in this thread. If you’d rather answer privately, there’s a 2-minute survey: How do AI agencies bill AI usage? (2 minutes, results shared)

For the billing side, the simplest approach that actually survives contact with real usage is a per-client API key plus a logging step in the workflow itself.

  1. Separate keys, not separate credentials. Create a separate OpenAI/Anthropic project or API key per client. The provider’s usage dashboard already breaks down by key, so your month-end is a CSV export, not a digging session. If a client’s workflow goes haywire (retry storm, looping agent), you can revoke just their key without touching anyone else’s.

  2. Log tokens inside the workflow anyway. Even with separate keys, you want per-execution data for invoices. A Code node right after the LLM call that writes to a Postgres table or Google Sheet with: client_id, execution_id, model, input_tokens, output_tokens, timestamp. Takes 5 minutes to add and makes disputes trivial to resolve.

  3. Voice costs: same invoice, separate line item. Per-minute charges are already itemized by the provider (Twilio, Vapi, etc.), so treat them as a pass-through line on the same invoice. Clients understand “LLM: $12.40, Voice: $8.15” better than a single blended number.

  4. Retry storms: the catch is a per-client daily cap in the workflow, not at the provider level. A simple IF node checking a Postgres counter (client_id, date, token_count) against a threshold, with an Error Trigger that emails you when it trips. The provider’s rate limit is too high to protect your margin.

On pricing: pass-through at cost plus a fixed % markup (15-20%) is the cleanest for trust. Flat monthly fees work but you eat the margin on heavy months. The worst option is folding it in silently, because one retry storm and you’re subsidizing a client’s bug.

I went back and forth on a credential per client too. Separate keys are clean for the bill, but they don’t tell you which workflow or which step cost what, and they get messy once a workflow serves several clients.

What I ended up with is one row per AI call in Postgres: client_id, workflow, model, input and output tokens, cost. Cost is computed from a small price table, and the month-to-date total per client is one SQL query, which is what goes on the invoice. A few things that bit me:

  • Pass client_id explicitly into every sub-workflow. Execute Workflow won’t carry it for you, and untagged calls are where the money disappears.
  • Log per call, not per execution. One execution can make 1 call or 40.
  • Check the client’s budget before the call, not after. If they’re over, stop there. It’s not atomic, so parallel runs can each slip one call past the limit, and setting max_tokens on every request keeps that overshoot small.
  • Keep the price table updated, or the numbers slowly drift away from the real invoice.

On pricing, I’d pass usage through with a markup or put it in a flat fee with a cap, rather than at cost. At cost you’re absorbing the tracking work and any overage for free.

I put the workflow and schema up as a free template if it helps: n8n workflow: log each OpenAI call's cost per client, and stop when the monthly budget is used up · GitHub

Thanks, super clear. Separate keys per client for a clean month-end export, plus the per-execution log for disputes, makes a lot of sense. And “LLM: $12.40, Voice: $8.15” as separate lines is a nice touch I hadn’t thought of.

Really helpful, thanks for sharing the template. Logging per call instead of per execution, and passing client_id explicitly into every sub-workflow, are the two things I’d have gotten wrong. The tip about setting max_tokens to limit the parallel overshoot is a smart one.

Glad it helps! One more that’s easy to miss: log the failed and timed-out calls too, with a status column. Providers often still bill for a call that errored partway, so if you only log successes, the month-end total ends up a bit under the real invoice.