Separate costs per customer: Track AI API consumption in shared n8n environments
Cleanly separate AI API costs per customer in a shared n8n instance: separate key per tenant, Usage and Cost APIs, pitfalls.

When you operate multiple customers on a shared n8n instance, you don't separate their AI costs in n8n, but at the model provider: one separate API key per customer in a separate OpenAI project or a separate Anthropic workspace, retrieved via the Usage and Cost APIs of the providers. n8n counts executions and runtime, not euros per tenant. Cost allocation is created at the moment you create the credential, not only when writing the invoice. As of: August 2026.
Why n8n doesn't split AI consumption per customer itself
n8n measures its own operations, not the bill of the model provider. According to the n8n documentation, the Insights Dashboard shows successful executions, failed executions with error rate, saved time, and average runtime. All four metrics describe workflows, not tokens and not amounts. Additionally: The dashboard is only available in the Pro, Business, and Enterprise plans, while the summary banner with the last seven days is available in all plans. Self-hosted instances retain Insights data according to the same documentation by default for 365 days, with a maximum of 730 days via N8N_INSIGHTS_MAX_AGE_DAYS.
For an agency, this means: The question "What AI costs did customer B incur in July?" cannot be cleanly answered from n8n alone. You need a second data source, and that lies with the model provider.
One API key per customer: this is where the assignment is created
The key level of cost allocation is the API key, not the workflow. Both major providers offer a separate container for this, and both reporting APIs can group by it.
OpenAI: Create a separate project in the organization for each customer and generate a project API key within it. Consumption can then be grouped by
project_id.Anthropic: One separate workspace per customer, with a separate API key within it. Consumption and costs can be evaluated by
workspace_idandapi_key_id.Important pitfall: With Anthropic, consumption from the default workspace appears in reports with
workspace_idequal tonull. If even one customer runs there, their share falls into an anonymous pool and can no longer be assigned retroactively.Similarly: Usage from the Anthropic Workbench is not tied to any API key,
api_key_idremains empty there. So do not test in the customer context via the console.
How do I read consumption per customer programmatically?
Both providers provide admin endpoints for this that require a separate admin key, not the normal API key from your n8n credential. This is intentional: whoever builds workflows should not automatically be able to read the billing data of the entire organization.
Anthropic consumption: The endpoint
/v1/organizations/usage_report/messagesprovides, according to the Usage and Cost API documentation, time buckets of 1m, 1h, or 1d and allows filtering and grouping by API key, workspace, model, and service tier.Anthropic costs: The endpoint
/v1/organizations/cost_reportreturns amounts in US dollars, exclusively in daily buckets, groupable byworkspace_idanddescription.OpenAI consumption: The endpoint
/v1/organization/usage/completionsknows, according to the OpenAI Cookbook on Usage API, the same three time buckets and the groupingsproject_id,api_key_id,user_id,model, andbatch.OpenAI costs: The endpoint
/v1/organization/costsalso works only in daily buckets.
Two details determine whether the evaluation will work in a monthly run. Anthropic states that consumption and cost data typically appear within five minutes: that's sufficient for an invoice, but not for a hard real-time lock. And in the daily bucket, the Anthropic Usage API provides 7 buckets by default, maximum 31. A calendar month thus just fits into one query, a quarterly report requires pagination.
Without grouping, both APIs return the assignment fields empty. The OpenAI documentation explicitly notes that fields like project_id come as null without group_by. Anyone who overlooks this has a correct total in hand and mistakes it for a customer breakdown.
What you must keep clean in n8n anyway
The provider side carries the numbers, the n8n side carries the order. Projects in n8n group workflows and credentials and allow different roles per user. That's exactly why the customer credential belongs in the customer project and not in the personal area of a consultant: otherwise, next quarter a workflow accidentally moves to the wrong key, and the breakdown no longer adds up.
However, this comes at a plan cost. The n8n pricing page lists for Starter 1 shared project at 20 euros per month (annual payment), for Pro 3 projects at 50 euros, for Business 6 projects at 667 euros, and for Enterprise unlimited projects at terms by agreement (as of August 2026). Role-based rights are available in all plans except the Community Edition according to n8n documentation. If you fit seven customers in a Pro instance, you have three projects for seven tenants and must build the separation via naming conventions and tags, which works but requires discipline.
In NordFlux projects, a simple principle has proven effective: keep customer abbreviations in the names of project, credential, and provider workspace identical. Then the monthly reconciliation between provider report and n8n inventory is purely textual, and an abbreviation that only appears in the provider report reveals a forgotten old key. The licensing question of who is allowed to operate a shared instance at all is independent of this and is described in Can my agency host n8n for customers?.
What does this mean for invoicing the customer?
Two billing models work in practice, a third does not. Pass-through with markup honestly reflects fluctuation and fits when the customer controls usage themselves, such as with a chat assistant. A flat fee with usage cap works when the workflow runs event-driven and the volume is predictable, such as with classifying incoming emails. The flat fee without cap does not work: a customer who doubles their volume doubles your costs, not theirs.
Which model becomes how expensive in the workflow depends on the model choice per step. The necessary information on this and setting up the credentials themselves can be found in Connect Claude/OpenAI: Credentials, model selection, cost control. If you don't want to build a multi-tenant environment yourself, we support you as part of our n8n consulting.
Frequently asked questions
Is it enough to tag the n8n workflow per customer?
No. Tags organize workflows, but they don't reach the model provider's billing. Without separate API keys, you get a total bill that can only be estimated afterwards. Tags are useful as a second level of organization, not as a substitute for separate keys.
Can I use a single key and separate via the "user" field?
With OpenAI, grouping by user_id is possible and works technically. But it's the weaker separation: a typo in the field creates a new pseudo-customer, and a compromised key immediately affects all tenants. Separate projects or workspaces are more robust and can additionally be disabled individually.
How often should I retrieve consumption data?
A monthly run is sufficient for billing. For a budget alert, a daily retrieval makes sense, which you can build yourself as an n8n workflow. Anthropic states that retrieval once per minute in continuous operation is supported and results should be cached for dashboards.
Do I necessarily need an Enterprise license from n8n for this?
Not for cost allocation itself, which happens at the model provider and is independent of the n8n license. For clean project and rights separation within a shared instance, you need at least a plan with role-based rights, so not the Community Edition, and from about a handful of customers, more projects than Starter and Pro offer.
Simon Glowik
Founder of NordFlux. Spent four years automating processes at enterprise scale at Dräger, and now brings that depth to the mid-market — pragmatic and with full data sovereignty.
Certifications
- Microsoft certified — PL-900 and AZ-900
- UiPath certified — Automation Developer Associate
- UiPath zertifiziert — Automation Developer Associate
Concrete questions about automation or AI?
In a free initial analysis we discuss your case directly. No strings attached.