Claude API Cost Tracking Per Project: A Practical Guide
If you're running multiple products, clients, or teams on top of Claude, the native Anthropic console gives you a single aggregate usage number. It doesn't break spend down by project out of the box. To track Claude API cost per project, you need to either tag requests with metadata and reconcile them yourself, or separate access at the API key level so each project's usage is isolated from the start.
This matters the moment you're billing clients, splitting costs between internal teams, or just trying to figure out which feature is burning through your budget. Below are the three practical approaches, from manual to fully automated, and how to pick the right one for your situation.
Why Per-Project Tracking Is Hard With a Single API Key
Anthropic's billing console reports usage at the account level. If every project, environment, and team shares one ANTHROPIC_API_KEY, the dashboard shows you a lump sum with no way to split it after the fact. You'd need to reconstruct cost attribution from your own application logs — assuming you logged token counts, model names, and a project identifier for every single request.
Most teams don't log this consistently from day one, which means retroactive cost attribution is often a guessing game based on timestamps and rough estimates.
Option 1: Manual Metadata Tagging
The lowest-effort fix is to attach a project identifier to every request you make and log token usage locally. Every Claude API response includes usage.input_tokens and usage.output_tokens, so you can compute cost per call if you know the model's per-token rate.
async function callClaude(projectId, prompt) {
const res = await fetch("https://api.anthropic.com/v1/messages", {
method: "POST",
headers: {
"x-api-key": process.env.ANTHROPIC_API_KEY,
"anthropic-version": "2023-06-01",
"content-type": "application/json",
},
body: JSON.stringify({
model: "claude-sonnet-4-5",
max_tokens: 1024,
messages: [{ role: "user", content: prompt }],
}),
});
const data = await res.json();
await logUsage({
projectId,
inputTokens: data.usage.input_tokens,
outputTokens: data.usage.output_tokens,
model: data.model,
timestamp: Date.now(),
});
return data;
}
This works, but you own the entire cost calculation pipeline: tracking model pricing changes, aggregating logs, building dashboards, and keeping the pricing table up to date whenever Anthropic adjusts rates. For a single internal project this is fine. For ten client projects billed monthly, it becomes its own maintenance burden.
Option 2: Separate API Keys Per Project
A cleaner approach is giving each project its own API key, so usage and billing are isolated at the source rather than reconstructed after the fact. This is the standard pattern for agencies and platforms serving multiple clients: one key per client means one line item per client, no manual tagging required.
The limitation with Anthropic's own keys is that creating and managing many keys, plus getting readable per-key usage breakdowns, still requires building your own admin layer. There's no built-in per-key spend dashboard designed for multi-project teams.
Option 3: Issue Scoped Keys Through SubToAPI
SubToAPI sits on top of your existing Claude access and lets you issue application-level API keys (sub_live_...) per project, client, or environment. Each key hits the same Claude models through a consistent HTTPS interface, but usage is tracked separately per key in one dashboard — so cost-per-project is visible without building your own logging pipeline.
A typical setup looks like this: one key for your staging environment, one for each client-facing product, and one for internal tooling.
curl https://api.subtoapi.app/v1/messages \
-H "Authorization: Bearer $SUBTOAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-5",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Summarize this ticket."}]
}'
Because each project gets its own key, usage metadata — token counts, request volume, model used — is already segmented when it reaches your dashboard. You're not reconciling logs after the fact; the separation happens at the request layer. This also makes it trivial to set different budgets or alerts per team without touching application code, and team seats mean your product leads can check their own project's spend without admin access to everything else.
Plans start at €9/month for Solo use, €19/seat for Team, and €49/seat for Scale, with a free trial available at signup. If you're already tracking costs manually across projects, moving to per-project keys usually pays for itself within the first billing cycle just in the time saved reconciling spreadsheets.
Choosing the Right Approach
- One internal project, low volume: manual metadata tagging is enough — don't over-engineer it.
- Multiple internal teams sharing a budget: separate keys per team, even with Anthropic's native console, gives you a cleaner split.
- Client billing, agencies, or multi-tenant SaaS: scoped keys per project with centralized dashboard visibility (like SubToAPI provides) remove the manual reconciliation step entirely and scale cleanly as you add clients.
Whichever path you choose, the core principle is the same: attribute cost at the point of the request, not after the fact. Trying to reconstruct per-project spend from a single aggregated bill is always harder than preventing the aggregation in the first place.
If you're setting this up for the first time, start with the quickstart guide to get your first scoped key issued, then check the messages API docs for the full request/response shape including usage fields.
FAQ
Does the Claude API report cost directly in the response? No. Each response includes token counts (input_tokens, output_tokens), not a dollar amount. You calculate cost by multiplying token counts by the current per-model rate, or use a layer like SubToAPI that surfaces usage per key in a dashboard.
Can I track costs per project without creating multiple API keys? Yes, by tagging every request with a project identifier and logging usage locally, but you're responsible for maintaining the pricing table and building your own reporting. Separate keys per project remove that maintenance burden.
Is per-project key separation good practice for client billing? Yes. Giving each client or project its own key means usage and spend are isolated from the moment the request is made, which makes invoicing and budget alerts far simpler than reconstructing costs from combined logs.