How-to · Claude and Anthropic

How to Track Claude API Costs Per User

By Ghiles Asmani, founder of Weckr

You open the Anthropic console, see one number for the month, and close the tab. Claude is doing great work in your product, and it is also quietly your largest variable cost. But which of your users is behind that number? The console cannot tell you, because it has never heard of your users.

The usage API is account-level and workspace-level. Every request you send arrives under one API key, so from Anthropic’s side it all looks like your app. If you want Claude cost per user, you attribute it yourself, and Anthropic gives you exactly what you need to do it on every response.

One Claude total hides who is unprofitableAnthropic console$1,240one number$29 plan priceu1$2u2$5u3$9u4$34u5$41

Why the Anthropic console stops at the total

Anthropic is not withholding the per-user data. It does not have it. When your backend calls the Messages API, it sends one request with one key, and there is no field that says this spend belongs to a specific customer on a specific plan. So the console reports at the two levels Anthropic actually knows: your account, and your workspaces. You can slice by model and by day. You cannot slice by your customer, because that dimension only exists on your side of the wire.

This is the exact same structural gap you hit with OpenAI cost per user. The moment you multiplex thousands of end users through one credential, the per-user view has to be built by you.

Claude API pricing in 2026

You cannot turn tokens into dollars without the rates. Here are current published Claude prices per million tokens, input and output. Confirm on the Anthropic pricing page before you rely on any number, because they change.

Model               Input $/M    Output $/M
-------------------------------------------------
Claude Haiku 4.5    (cheapest tier, see pricing page)
Claude Sonnet 4.6   3.00         15.00
Claude Opus 4.6     5.00         25.00

All figures per 1,000,000 tokens. Current as of 2026.

Read the output column as much as the input one. Opus charges $25 per million output tokens, more than 40x the $0.60 that a cheap model like GPT-4o-mini charges for the same generated text. Since output tokens usually dominate a real bill, the model you pick for a chatty, high-volume feature is the single biggest lever on your Claude cost. For the full cross-provider picture, see DeepSeek vs OpenAI vs Gemini cost.

Get token usage from the Anthropic API

Every Messages API response carries the token counts for that call on a usage object. Read it right after the request returns:

import Anthropic from '@anthropic-ai/sdk'
const anthropic = new Anthropic()

const message = await anthropic.messages.create({
  model: 'claude-sonnet-4-6',
  max_tokens: 1024,
  messages,
})

console.log(message.usage)
// { input_tokens: 812, output_tokens: 143 }

Those two fields, input_tokens and output_tokens, are the raw material for per-user cost. Note the naming: Anthropic uses input/output, while OpenAI uses prompt/completion. If you track both providers, normalize them to one shape so your numbers line up.

Attribute the cost to a user

Anthropic does not attribute the usage to a user, but you can, because you know who made the request. Capture the counts with the user id attached, turn tokens into dollars, and you have the per-user record the console will never give you:

const PRICES = {
  'claude-sonnet-4-6': { in: 3,  out: 15 },   // USD per 1M tokens
  'claude-opus-4-6':   { in: 5,  out: 25 },
}

function costUsd(model, inputTokens, outputTokens) {
  const p = PRICES[model]
  return (inputTokens * p.in + outputTokens * p.out) / 1_000_000
}

await db.aiUsage.insert({
  userId: req.user.id,          // you have this. Anthropic does not.
  feature: 'assistant',
  model: 'claude-sonnet-4-6',
  inputTokens: message.usage.input_tokens,
  outputTokens: message.usage.output_tokens,
  costUsd: costUsd('claude-sonnet-4-6', message.usage.input_tokens, message.usage.output_tokens),
  createdAt: new Date(),
})

Group that by userId for the month and sort descending. The users at the top are where your Claude bill actually comes from, and the ones whose cost exceeds what they pay are the accounts you need to check the margin on.

Why the manual version stops scaling

It works until it does not. Anthropic reprices and your hardcoded table drifts from the real bill. You add an OpenAI model for one feature and now maintain two pricing tables and two token-accounting rules. Then you want margin, not just cost, so you join subscriptions, prorate plan changes, and lose an afternoon to a mid-month upgrade edge case. This is the point most founders quietly abandon and go back to the account total.

Track Claude cost per user with Weckr

Weckr wraps your existing Anthropic client in two lines and does the whole layer for you. Same call, same Claude response, plus a per-user cost and margin record calculated server side from current pricing:

import Anthropic from '@anthropic-ai/sdk'
import { Weckr } from '@weckr/sdk'

const anthropic = new Anthropic()
const wk = new Weckr({
  apiKey: process.env.WECKR_API_KEY,
  plans: { free: 0, pro: 29, business: 99 },
})

const message = await wk.chat(anthropic, {
  model: 'claude-sonnet-4-6',
  max_tokens: 1024,
  messages,
  userId: user.id,
  feature: 'assistant',
  plan: user.plan,
})

Every call records cost and margin per user and per feature, across OpenAI, Anthropic, and Gemini in one dashboard, with token counts normalized so the providers compare fairly. You also get per-user spending caps that block or downgrade a heavy user before they run your Claude bill past what they pay. See it on seeded data, no signup, at useweckr.com/demo, and model your plan against real Claude costs with the break-even calculator.

FAQ

Does Anthropic show Claude cost per user?

No. The Anthropic console and usage API report spend at the account and workspace level, not per your end user. Anthropic has no concept of your customers because every request goes through one API key on their behalf. To get Claude cost per user you attribute it yourself from the token counts on each response.

How much does the Claude API cost in 2026?

As of 2026, Claude Sonnet 4.6 is about $3 per million input tokens and $15 per million output tokens, and Claude Opus 4.6 is about $5 input and $25 output. The Haiku tier is cheaper still. Output tokens dominate most real bills, so the output price matters more than the input price. Always confirm current numbers on the Anthropic pricing page before you rely on them.

How do I get token usage from the Anthropic API?

Every Messages API response includes a usage object with input_tokens and output_tokens for that call. Read message.usage right after the request returns and store those two numbers alongside your user id. That is all you need to compute per-user cost.

How do I calculate Claude API cost per user?

Multiply the input and output token counts from message.usage by the per-million-token prices for the model, then sum per user over the period. The formula is (input_tokens * inputPrice + output_tokens * outputPrice) / 1,000,000. Recompute from live pricing rather than a hardcoded table, because Anthropic reprices over time.

How do I track Claude and OpenAI cost in one place?

Normalize the token counts and apply each provider price, then aggregate by user across both. Doing this by hand means maintaining two pricing tables and two token-accounting rules. A wrapper like Weckr supports OpenAI, Anthropic, and Gemini in one dashboard with token counts normalized, so cost per user lines up across providers.

Turn the Claude total into a per-user answer

The Anthropic total will always just be a total. It cannot see your users, so it cannot tell you which one to upsell, which to cap, or which is quietly eating a month of margin. That answer only exists on your side, built from the token counts Claude already returns on every response. This is one step in the complete guide to AI cost and margin management. See your real per-user Claude cost at useweckr.com/demo.

See the dashboard with real data, no signup needed.

Try the demo →