Back to Blog
LLM Costs·6 min read

How to Track OpenAI Costs by Client

Managing AI features for multiple clients means tracking costs across different projects. Without attribution, you can't price accurately or spot profitability problems.

August 19, 2025

How to Track OpenAI Costs by Client

When you're building AI features for one client, tracking OpenAI costs is simple. You have one API key, one billing dashboard, and one bill at the end of the month.

When you're building for five clients, or ten, or twenty? That's when it gets messy.

The attribution problem

Most AI agencies hit the same wall: they're using OpenAI (or Anthropic, or both) across multiple client projects, but they can't easily answer the question "how much did Client X cost us this month?"

This matters for three reasons:

Profitability. If you're billing clients flat fees for AI features, you need to know if those fees actually cover your costs. One client's chatbot might cost $12/month in API calls. Another's might cost $400. Without attribution, you won't know until you're bleeding money.

Pricing accuracy. When you scope new projects, you need realistic cost estimates. Those estimates should come from actual data, not guesses.

Client conversations. Some clients want to understand what they're paying for. Being able to say "your RAG system processes about 2 million tokens per month, which costs roughly $40" is more useful than shrugging.

The obvious approaches (and why they don't scale)

One API key per client. This works in theory. Each client gets their own key, and their usage appears separately in OpenAI's dashboard. In practice, it's a pain. You're managing multiple keys, updating them in multiple places, and the OpenAI dashboard wasn't designed for managing dozens of projects.

Tracking via your app. If you're building custom applications, you can log token usage per request and attribute it to clients in your own database. This works, but it requires code changes in every project, and it doesn't help with n8n workflows or other tools where you don't control the integration layer.

Monthly estimation. Some agencies just estimate based on activity levels. "Client A uses the chatbot more, so they're probably 60% of the bill." This is better than nothing, but it's also wrong. A client with low volume but complex prompts might cost more than a high-volume client with simple queries.

What good attribution looks like

The goal is simple: you want to see a breakdown of AI costs by client, ideally by workflow or feature, without manual tracking.

For n8n workflows specifically, this means:

  • Knowing which workflows call which AI models
  • Capturing the token counts (or at least the model and rough request size)
  • Rolling up those numbers by client

This gives you a monthly view like:

Client Model Requests Est. Tokens Est. Cost
Acme Corp gpt-4o 2,340 4.2M $42.00
Acme Corp gpt-4o-mini 12,800 8.1M $8.10
StartupCo claude-3-sonnet 890 1.8M $13.50

That table tells you immediately that Acme's gpt-4o usage is the bulk of their cost, and that StartupCo's Anthropic usage is modest. You can price accordingly.

Practical approaches that work

Option 1: Structured API key management

If you're going to use separate API keys per client, do it systematically:

  1. Create a spreadsheet or database tracking which key belongs to which client
  2. Set up a monthly reminder to pull usage from each provider's dashboard
  3. Compile the data into a client cost report

This is manual, but it works for agencies with fewer than 10 clients. The overhead becomes painful beyond that.

Option 2: Middleware logging

If you control the code that calls OpenAI/Anthropic, you can add a logging layer:

def call_openai(prompt, client_id, workflow_id):
    response = openai.chat.completions.create(...)

    # Log for attribution
    log_usage(
        client_id=client_id,
        workflow_id=workflow_id,
        model=response.model,
        tokens_in=response.usage.prompt_tokens,
        tokens_out=response.usage.completion_tokens
    )

    return response

The challenge is that this only works for code you write. It doesn't help with n8n's HTTP nodes or other integrations.

Option 3: Provider-side tracking

Some providers have project-based tracking built in:

  • OpenAI has Projects (in beta) that let you organize usage
  • Anthropic has workspaces for team usage separation
  • Azure OpenAI lets you create separate deployments per client

These help, but they still require you to aggregate across providers manually.

Option 4: Centralized monitoring

The cleanest solution is a tool that pulls cost data from multiple providers and attributes it based on your client/workflow structure. You connect your OpenAI key, your Anthropic key, and your Azure credentials, and the tool maps usage to clients automatically.

This is something we're building into Administrate.dev—the ability to see LLM costs alongside your n8n execution data, broken down by client. If you're tracking workflows already, adding cost attribution to the same dashboard makes sense.

What to do today

If you're not tracking AI costs by client right now, here's a starting point:

  1. Pull your current bills. Log into OpenAI and Anthropic and export the last three months of usage. Just having the raw numbers is useful.

  2. Estimate allocation. Based on what you know about each client's usage, assign rough percentages. This won't be accurate, but it'll surface obvious imbalances.

  3. Pick a tracking method. Decide whether you're going with per-client API keys, code-level logging, or a monitoring tool. The method matters less than consistency.

  4. Review monthly. Put a recurring task on your calendar to review AI costs by client. The pattern recognition happens over time—you'll start noticing which clients are cost-heavy and which are efficient.

The pricing conversation

Once you have attribution data, you can make better pricing decisions.

Some agencies include AI costs in their flat fees and eat the variance. This is simple but risky—one client's usage spike can wipe out your margin.

Others pass through AI costs with a markup. "Your AI features cost $X this month in API fees, plus our 20% management overhead." This is transparent but requires more client communication.

A third approach is usage tiers: "Up to $50/month in AI costs is included, beyond that is billed at cost + 15%." This gives clients predictability while protecting you from outliers.

None of these approaches work without accurate cost data. That's why attribution matters—not just for understanding your business, but for pricing it correctly.

Moving forward

AI costs will only become a bigger part of automation projects. Clients are asking for smarter workflows, RAG systems, AI-powered analysis—all of which burn tokens.

The agencies that thrive will be the ones that understand their costs, price accurately, and can show clients exactly what they're getting for their money. Attribution is the foundation of all of that.

Start tracking now, even if it's rough. The data will pay for itself.

Last updated on January 31, 2026

Continue Reading

View all