KeyBark

Anthropic cost per API key: see which Claude key is spending

One API key per app, agent or customer only pays off if you can see what each key costs. Anthropic now reports dollars per key through the API, but not on the Console's Cost page, not in the old cost report, and not for the last few hours.

Last reviewed 13 Nov 2026

The short version

  • Dollars per key: GET /v1/organizations/analytics/cost?group_by[]=api_key_id with an Admin API key and the beta header anthropic-beta: analytics-usage-cost-2026-08-24 (Usage and Cost Analytics API). Claude Console organizations only.
  • Not the old cost report: /v1/organizations/cost_report groups by workspace or description only, so it can't split cost by key.
  • Not the Console Cost page: it filters by workspace and model. The Usage page filters by API key, but in tokens (Claude Help Center).
  • Hours behind: the Analytics data typically refreshes within 4 hours and can take up to 24. For today, read tokens per key from the legacy usage report (about 5 minutes behind) and estimate.
  • Some spend has no key: Console use, Claude Code signed in without an API key and federated tokens show api_key_id: null.
Want a heads-up before the bill does?

KeyBark checks your OpenAI, Anthropic or OpenRouter spend about every 15 minutes during the beta and emails you when it crosses a daily or monthly threshold you set, or jumps above its 7-day average. It doesn't set or enforce limits for you. Free for one key, no card.

Which view answers what

ViewPer key?UnitHow fresh
Console Usage pageYes (key filter)TokensHour and minute drill-down
Console Cost pageNo (workspace, model)USDDaily chart by month
GET /v1/organizations/analytics/costYes: group_by[]=api_key_id, api_key_ids[]USD (cents)Typically within 4 hours, up to 24
GET /v1/organizations/analytics/usageYesTokens and requestsSame as cost
/v1/organizations/usage_report/messages (legacy)YesTokensTypically within 5 minutes
/v1/organizations/cost_report (legacy)No (workspace, description)USD (cents)Daily buckets only

All four API endpoints need an Admin API credential: an sk-ant-admin01-… Admin key, an OAuth token with the org:admin scope, or a personal or service account key that isn't scoped to a workspace. Workspace API keys don't work. The Admin API isn't available to individual Console accounts until you set up an organization, and Claude Enterprise organizations use an Analytics API key instead, where api_key_id is always null.

1. Cost per key for a month

One row per API key, most expensive first. --globoff stops curl from treating the square brackets as a pattern:

curl -s --globoff "https://api.anthropic.com/v1/organizations/analytics/cost?\
starting_at=2026-10-01T00:00:00Z&\
ending_at=2026-11-01T00:00:00Z&\
group_by[]=api_key_id&\
limit=1000" \
  -H "anthropic-version: 2026-10-21" \
  -H "anthropic-beta: analytics-usage-cost-2026-08-24" \
  -H "x-api-key: $ANTHROPIC_ADMIN_KEY" \
  | jq -r '.data[] | [(.group.api_key_id // "no API key"), ((.cost.amount | tonumber) / 100)] | @tsv'
  • Cents, six decimals: amount is a decimal string in cents, so "41280.000000" is $412.80. Divide by 100.
  • Which number: amount is after discounts and before any credits; list_amount is at list prices. Your invoice can differ from both if you have credits.
  • Range rules: starting_at must be on or after 1 January 2026 and within the last 365 days, and one request covers at most 31 days. Split a quarter into months.
  • More than 1,000 keys: if has_more is true, pass next_page as page with the same parameters. A cursor can expire when the data refreshes (HTTP 410); start again from page one.
  • Per key and model: add group_by[]=model (up to five dimensions). Add group_by[]=cost_type to split tokens from web search, code execution and Managed Agents session time.

2. One suspicious key, hour by hour

Find the key's ID first (step 3), then ask for hourly buckets in time order:

curl -s --globoff "https://api.anthropic.com/v1/organizations/analytics/cost?\
starting_at=2026-11-10T00:00:00Z&\
ending_at=2026-11-13T00:00:00Z&\
api_key_ids[]=apikey_01Rj2N8SVvo6BePZj99NhmiT&\
time_bucket_width=1h&\
order_by=time&order=asc&\
limit=1000" \
  -H "anthropic-version: 2026-10-21" \
  -H "anthropic-beta: analytics-usage-cost-2026-08-24" \
  -H "x-api-key: $ANTHROPIC_ADMIN_KEY" \
  | jq -r '.data_refreshed_at, (.data[] | [.starting_at, ((.cost.amount | tonumber) / 100)] | @tsv)'
  • ending_at is required with time_bucket_width, and 1m buckets can span at most 24 hours.
  • Empty hours have no row. Fill gaps with zero yourself.
  • A typo returns nothing, not an error. An unknown apikey_ ID simply matches no rows, which looks exactly like a key that spent $0. Copy IDs from the key list.
  • api_key_ids[] vs actor_ids[]: api_key_ids[] matches every request the key authenticated. actor_ids[]=apikey_… matches only requests attributed to the key itself, so it misses traffic from personal or service account keys, which are attributed to the user or service account.

3. Turn key IDs into names

Cost rows give you apikey_… IDs. List API Keys returns each key's id, name, partial_key_hint, workspace, status, created_by and expires_at:

curl -s "https://api.anthropic.com/v1/organizations/api_keys?limit=1000" \
  -H "anthropic-version: 2026-10-21" \
  -H "x-api-key: $ANTHROPIC_ADMIN_KEY" \
  | jq -r '.data[] | [.id, .name, .status, (.partial_key_hint // "")] | @tsv'

Filter with status= (active, inactive, archived, expired) or workspace_id=. Keys in an archived workspace stay listed as archived, so old spend still gets a name. Keys that Claude Code creates at sign-in live in the Claude Code workspace, which is how you tell developer spend from app spend.

4. Today, before the Analytics data catches up

When you need to know whether a key is running away now, the Analytics endpoints can be hours behind. The legacy usage report still filters and groups by api_key_id and typically shows usage within about 5 minutes, but it reports tokens:

curl -s --globoff "https://api.anthropic.com/v1/organizations/usage_report/messages?\
starting_at=2026-11-13T00:00:00Z&\
group_by[]=api_key_id&\
group_by[]=model&\
bucket_width=1h&\
limit=24" \
  -H "anthropic-version: 2026-10-21" \
  -H "x-api-key: $ANTHROPIC_ADMIN_KEY"

Multiply each model's uncached input, cache write, cache read and output tokens by the rates on the pricing page for a rough figure. Treat it as an estimate: batch, long-context, data-residency and fast-mode usage have their own rates, Priority Tier usage is covered by a commitment, and code execution isn't in the usage report at all. Use step 1 for the real number once the data has refreshed.

Why the totals don't match

  • Usage with no key. The per-key rows won't add up to the Cost page if part of the spend has api_key_id: null: Console and Workbench, Claude Code after a sign-in without an API key, Workload Identity Federation tokens, and some Managed Agents sessions. Add api_key_ids[]= (an empty entry) to include them.
  • Late data. Anything after data_refreshed_at is missing or partial, and a month can be revised until about 7 days after it ends. Compare final totals only for months that ended at least a week ago.
  • Priority Tier. Requests under a Priority Tier commitment show zero token cost in amount; the commitment fee isn't in this data.
  • Credits. amount is before credits, so a key's cost can be higher than what left your balance.
  • Default workspace. In the Analytics API the Default workspace has its real wrkspc_ ID; in the legacy endpoints it shows as null.

What these views don't do

  • They don't stop anything. Anthropic's spend limits apply to workspaces and the organization, not to single API keys: see Anthropic workspace spend limits via the API and why not to rely on a Default Workspace limit. To cap a key, give it its own workspace.
  • They don't warn you. Nothing here sends a message when a key's spend jumps; you'd have to poll and compare yourself, and with hours of lag. For organization-level daily, spike and Slack alerts, see Anthropic API spend alerts.
  • The Admin key is powerful. It can read your whole organization's usage and cost, and list and change API keys and workspaces. Anthropic suggests giving the reporting job its own key with an expiry date, kept in a secrets manager, or using Workload Identity Federation with the org:admin scope so there is no long-lived key.

Checklist

  1. One API key per app, agent or customer, so per-key cost means something.
  2. Keys for risky workloads in their own workspace with a spend limit.
  3. A weekly or monthly analytics/cost query grouped by api_key_id (and model), joined to names from the key list.
  4. For same-day checks, the legacy usage report by key in hourly buckets, compared with that key's normal day.
  5. A dedicated, expiring Admin key (or a federated identity) for the reporting job.

Not sure your Anthropic limits would stop a runaway loop or a leaked key? The free AI key limit audit checks OpenAI, Anthropic and OpenRouter in a couple of minutes (no sign-up, no key needed). Related: OpenAI cost per API key, OpenRouter usage per API key, Anthropic API key leaked, Claude Code spend limit.

Where KeyBark fits (and where it doesn't)

KeyBark does the "warn you" part, not the per-key breakdown. With an Anthropic Admin key you connect, it reads your organization's daily cost from our servers about every 15 minutes during the beta (the Admin cost report, which includes Default Workspace spend) and emails you when a daily or monthly dollar threshold you set is crossed, or when today's spend jumps above its 7-day average. That tells you something is spending; the queries above tell you which key. On paid plans an opt-in kill switch (beta) can set one Anthropic key you name to inactive when a threshold is crossed.

Limits, honestly: KeyBark reports organization totals, not cost per API key or per model; it doesn't use the Analytics API; checks run on a schedule and depend on Anthropic's own reporting delay, so an alert can come after money has been spent; and it doesn't set Anthropic spend limits for you. Set workspace limits first. KeyBark is a second line of warning on top of them.

FAQ

How do I see how much each Anthropic API key has cost?

Call GET /v1/organizations/analytics/cost with group_by[]=api_key_id, an Admin API key and the anthropic-beta: analytics-usage-cost-2026-08-24 header. Each row is one API key with its cost in USD cents (amount, after discounts and before credits). In the Claude Console, the Usage page can filter by API key but shows tokens; the Cost page shows dollars by workspace and model, not by key.

Can the cost_report endpoint group by API key?

No. The legacy /v1/organizations/cost_report only groups by workspace_id or description, with daily buckets. The legacy usage report (/v1/organizations/usage_report/messages) can filter and group by api_key_id, but it returns tokens, not dollars. For dollars per key, use the Usage and Cost Analytics API.

Why is today's cost per key missing or low?

The Analytics API data typically refreshes within 4 hours of the usage and can take up to 24 hours; every response has a data_refreshed_at timestamp, and anything after it is missing or partial. Values can also be revised until about 7 days after the end of the month. For a same-day check, read tokens per key from the legacy usage report, which typically shows usage within about 5 minutes, and estimate the cost from the pricing page.

Why do some rows have api_key_id null?

Requests that no API key authenticated have a null api_key_id: Console and Workbench usage, Claude Code after a sign-in without an API key, Workload Identity Federation tokens, and some Claude Managed Agents sessions. To include them in an api_key_ids[] filter, add an empty entry (api_key_ids[]=).

Sources (read 13 Nov 2026): Claude docs Usage and Cost Analytics API, API reference analytics cost and analytics usage, Usage and Cost API (legacy), cost report, usage report, List API Keys, Admin API keys, Pricing; Claude Help Center Cost and usage reporting in the Claude Console. KeyBark is not affiliated with Anthropic.

Want a second line of defence?

KeyBark watches your OpenAI, Anthropic and OpenRouter spend from the server and flags a crossed threshold or spike by email and on your dashboard. Free for one key.