One API Key per Client: How Agencies Split AI Coding Costs
Short answer: model providers report usage by API key, workspace or project, never by client. So give each client its own: an Anthropic workspace with its own key, an OpenAI project with its own key, or a Google Cloud project for Gemini. Make sure every coding agent uses that client's key while you work on their code (a subscription login doesn't count, because it has no key). At month end, the provider's usage or cost report for that key is the client's AI cost. Invoice it as its own line next to the hours, at cost or with a stated markup.
Where each provider draws the line
| Provider | Unit to create per client | Where you read the cost | Spend cap |
|---|---|---|---|
| Anthropic (Claude API) | A workspace, with a key scoped to it (up to 1,000 workspaces per organisation by default) | Console Usage page, filtered by API key or workspace; Cost page by workspace; CSV export (Anthropic help) | Monthly limit and email alerts per workspace |
| OpenAI | A project; a key created inside it is scoped to that project | Usage dashboard, filtered by API key and grouped by project; use Cost data for billed amounts (OpenAI help) | Per-project spend limit; a hard limit is optional |
| Google (Gemini API) | A Google Cloud project: keys live inside a project and have no billing of their own | AI Studio Dashboard > Usage; Cloud Billing cost pages | Project spend cap (experimental) |
On Google the project, not the key, is the unit: every key in a project counts towards the same project, so one client means one project.
Step 1: create the client's workspace or project and its key
- Anthropic: create a workspace named after the client and create the API key inside it, so the key can only reach that workspace. Set a monthly spend limit and an email alert. Avoid the default workspace for client work: Anthropic notes a spend limit there might not stop some usage, and its usage reports show the default workspace as a blank ID.
- OpenAI: create a project per client and create the key inside the project. Usage and billing can then be broken down by project.
- Google: create a Cloud project per client and its Gemini API key there.
Step 2: make each coding agent use that client's key
A per-client key only helps if the agent actually sends it. Each tool reads its key differently:
- Claude Code: by default Pro, Max, Team and Enterprise users sign in with their subscription, which has no API key and so no per-client split. When
ANTHROPIC_API_KEYis set, the docs say it is used instead of the subscription even if you are logged in (you approve it once in interactive mode). For credentials, the settings reference recommendsapiKeyHelper, a command that prints the key; put it in the client repo's.claude/settings.local.json(just you, this project) and have it read the key from your password manager. Signing in with a Console account instead creates a per-user key in a separate Claude Code workspace, which splits cost by person, not by client. - OpenAI Codex: signing in with ChatGPT uses your subscription; API-key use is billed through your OpenAI Platform account. For scripted runs, set
CODEX_API_KEYinline to use a different key for a singlecodex execrun, which makes a per-client key easy in CI. - Aider: reads a .env file in the root of your git repo (or the current directory, or
--env-file), so each client repo can carry its own key in a git-ignored.env. Details in our Aider billing guide. - Cline: keeps its key in a global settings file, not per project, so you switch keys when you switch client or give each client its own CLI configuration folder. See the Cline billing guide.
Whatever the tool, never commit a client's key to their repository.
Step 3: read the cost per client, after the month closes
For a handful of clients, the dashboards are enough: filter Anthropic's Usage page by the client's key, or OpenAI's usage dashboard by key or project, and export the month. At scale, both providers have admin APIs. Anthropic's usage report groups by API key and workspace (cost by workspace), and its newer analytics API breaks cost down by workspace, API key and model. OpenAI's Costs API groups by project and API key. All of these need an organisation admin key, not the client's key.
Mind the delay. Anthropic says usage typically appears within about 30 minutes in the usage report and cost data is daily; the analytics API refreshes within 4 hours and can take up to 24. OpenAI says recent usage may take time to appear. Invoice the previous month, not today's figure.
Pitfalls that break the split
- A subscription login or shared key sneaks in. Work done while signed in with a subscription, or with your agency's general key, never shows up under the client's key.
- Playground and console tests. Anthropic's usage report records Playground use with no API key, so it can't be attributed to a client.
- Spend limits are not instant. OpenAI's limits only monitor unless you turn on the hard limit, and even then enforcement can lag, so spend can slightly pass the cap. Keep an approval threshold in the contract.
- One key, many people. A per-client key tells you which client, not which developer. That is usually what the invoice needs; Console sign-ins give you the per-person view instead.
Step 4: put it on the invoice with eBRBe
On Pro and above, eBRBe's Anthropic and OpenAI usage sync reads your organisation's usage and cost reports with an admin key, grouped by API key and by workspace or project. You map each client's key or workspace to that client once; from then on the usage arrives as agent runs on the client's project, and re-syncs update rather than duplicate. eBRBe also compares the provider's total with what has been attributed, so spend on a key you forgot to map shows up. For Google, OpenRouter or other providers, add the month's cost per client with the CSV import or the REST API (POST /api/v1/agent-runs with cost_usd). The runs then sit on the client's invoice next to the hours, with your markup.
At cost, or with a markup?
Both are common. At cost is the most transparent; cost plus a stated percentage pays for choosing, running and reviewing the agent's work. Compare pricing models in our guide to billing AI agent costs, work out your numbers with the AI agent cost & markup calculator, and see what each Claude model costs per coding-agent run. Tool by tool: how to bill clients for Claude Code, OpenAI Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Aider and Cline usage.
A contract clause you can adapt
Agree the rule in the statement of work before the first invoice. A starting point (have it checked for your jurisdiction; this is not legal advice):
"We use AI development tools with model provider API keys dedicated to your project. The provider's charges for those keys are invoiced monthly as a separate 'AI usage' line at cost plus [X]%, with the provider's usage report available on request. We will not exceed [amount] of AI usage in a month without your written approval. If you prefer, you may supply your own API keys, in which case the provider bills you directly."
Frequently Asked Questions
Why use one API key per client?
Because model providers report usage by key, workspace or project, not by client. Anthropic's Console usage page can be filtered by API key and workspace, and OpenAI's usage dashboard can be filtered by API key and grouped by project. If each client has its own key or workspace, the provider's own report is already your per-client cost, with nothing to estimate.
Does this work if I use Claude Code with a Pro or Max subscription?
No. A subscription login has no API key, so there is nothing to split at the provider. Claude Code only bills a key when one is set: its docs say ANTHROPIC_API_KEY is used instead of a Pro, Max, Team or Enterprise subscription even if you are logged in (you approve it once in interactive mode). The same applies to Codex: signing in with ChatGPT uses your subscription, while an API key is billed through your OpenAI Platform account.
How do I make Claude Code use a different key in each client repo?
Claude Code's settings reference recommends apiKeyHelper for API credentials: a command that prints the key. It can go in any settings file, including the per-project .claude/settings.local.json, which is meant for you in one project and is kept out of git. Point it at the client's key in your password manager. Alternatively, export ANTHROPIC_API_KEY in the shell you open for that client. Never commit a key to the repository.
How quickly does the cost show up?
Not instantly. Anthropic's legacy usage report says usage typically appears within about 30 minutes and cost data is daily; its newer analytics API refreshes within 4 hours and can take up to 24. OpenAI says recent usage may take time to appear and to use Cost data for billed amounts. Invoice from the closed month, not from today's dashboard.
Can a spend limit stop a client's budget being overrun?
It helps but is not a hard guarantee. Anthropic lets you cap a workspace's monthly spend and set email alerts, though its docs warn a limit on the default workspace might not stop some usage. OpenAI project spend limits only monitor unless you turn on the hard limit, and even then enforcement is not instantaneous. Keep an approval threshold in the contract as well.
Does eBRBe read these per-key costs?
Yes. On Pro and above, eBRBe's usage sync reads your Anthropic and OpenAI usage reports with an admin key, grouped by API key and by workspace or project. Map each client's key or workspace to that client once and the costs arrive as agent runs on the client's project, ready for the invoice. For Google, OpenRouter or anything else, add the month's cost per client by CSV import or the REST API.
Next step on eBRBe
eBRBe puts Claude Code, Codex, Aider, Cline and other AI agent costs on the same client invoice as human hours, with your markup, and the client pays online. Free for up to 3 people; paid plans from $9 per member a month, with a 14-day trial. Want to see it first? Explore the demo: a read-only workspace with made-up data, no account needed.
Explore the demo or sign up free →