KeyBark

OpenRouter usage per API key: see which key is spending

OpenRouter gives you one key per app or agent, so the first question when the balance drops is which key did it. There are four ways to answer that through the API, and they don't count the same things.

Last reviewed 12 Nov 2026

The short version

  • One key, right now: GET /api/v1/key with that key returns its spend for the current UTC day, week and month (reference). No special key needed.
  • Every key at once: GET /api/v1/keys with a Management API key returns the same usage fields for each standard key in a workspace, 100 per page.
  • Per key over a date range, by hour or day: POST /api/v1/analytics/query grouped by api_key_id, metric total_usage (Management key).
  • Per key per model, finished days only: GET /api/v1/activity?api_key_hash=… covers the last 30 completed UTC days, so today is missing.
  • Watch BYOK: the key fields count OpenRouter credits only; total_usage in Analytics includes BYOK inference. Pick one and stick to it.
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 method answers what

MethodKey neededWindowBYOK
GET /api/v1/keyThe key itselfCurrent UTC day, week (Mon–Sun), month, lifetimeSeparate byok_usage_* fields
GET /api/v1/keysManagementSame fields, every standard key in one workspaceSeparate fields
POST /api/v1/analytics/queryManagementAny range: day buckets up to 367 days, hour buckets up to 31 daystotal_usage includes it; credits_usage is credits only
GET /api/v1/activityManagementLast 30 completed UTC days, per model endpointusage and byok_usage_inference per row
usage.cost in each responseAnyOne request, as it finishesis_byok flag

Prefer clicking? The Activity page ranks your top API keys and lets you group spend by key in Explore, then export CSV or PDF.

1. One key: GET /api/v1/key

Any key can read its own usage and limit. This is what you'd call from inside the app or agent that owns the key:

curl -s https://openrouter.ai/api/v1/key \
  -H "Authorization: Bearer $OPENROUTER_API_KEY" \
  | jq '.data | {usage_daily, usage_weekly, usage_monthly, usage, limit, limit_remaining, byok_usage_daily}'

The reference describes usage_daily, usage_weekly and usage_monthly as OpenRouter credit usage in USD for the current UTC day, the current UTC week (Monday to Sunday) and the current UTC month; usage is lifetime. A key that has hit its own limit shows limit_remaining near 0, and its requests are refused (see OpenRouter 402 errors).

2. Every key: GET /api/v1/keys

With a Management API key you get every standard key in a workspace with the same fields. This ranks them by today's spend:

curl -s "https://openrouter.ai/api/v1/keys?include_disabled=true&include_expired=true" \
  -H "Authorization: Bearer $OPENROUTER_MANAGEMENT_KEY" \
  | jq -r '.data | sort_by(-.usage_daily) | .[]
      | [.name, .hash[0:12], .usage_daily, .usage_monthly, .byok_usage_monthly, (.limit // "no limit")]
      | @tsv'

Things the list reference and OpenRouter's key audit cookbook point out:

  • Disabled and expired keys are left out unless you pass include_disabled=true and include_expired=true. A key you just disabled after a leak drops out of your totals without them.
  • One workspace per call. Without workspace_id you get the default workspace. To cover everything, list workspaces and call once per workspace_id.
  • 100 keys per page. Pass offset and stop when a page has fewer than 100.
  • Standard keys only. Management keys and keys created through OAuth aren't in the list.
  • The hash field is how you name a key in the other endpoints below.

3. Over time: the Analytics API grouped by api_key_id

The Analytics query endpoint is the API version of the Activity page's Explore tab. Group by api_key_id and the rows come back with the key's name:

curl -s https://openrouter.ai/api/v1/analytics/query \
  -H "Authorization: Bearer $OPENROUTER_MANAGEMENT_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "metrics": ["total_usage", "request_count"],
    "dimensions": ["api_key_id"],
    "granularity": "hour",
    "time_range": { "start": "2026-11-12T00:00:00Z", "end": "2026-11-13T00:00:00Z" }
  }' | jq '.data.metadata, (.data.data[] | select(.total_usage > 0))'

From OpenRouter's cost-control cookbook and analytics schema notes (read 12 Nov 2026):

  • Set time_range yourself. Without it the API uses a recent default window. Timestamps need seconds (…T00:00:00Z); minute-precision values are rejected.
  • Limits on the window: most cost metrics go back up to 367 days at day granularity or coarser; hour granularity is capped at 31 days and minute needs a window of 3 hours or less. Going over returns a 400, not a partial result.
  • Check metadata.truncated. If it's true you hit the row limit (default 1,000) and your totals are partial. Count fields such as request_count can come back as strings.
  • Two dimensions at most. For key × model, add model as the second dimension; for key × model × time, use granularity instead of a third dimension.
  • Filtering on one key: use its hash from the keys list in a filters entry on api_key_id, not its name. An unknown hash returns zero rows, not an error, so an empty result isn't proof the key is idle.
  • Metrics: total_usage is credits plus BYOK inference cost; credits_usage is what was charged to your OpenRouter credits (including BYOK fees). The query endpoint is rate-limited to 64 requests a minute.

4. Per key per model: GET /api/v1/activity

The older activity endpoint returns rows per day and model endpoint. Filter it to one key with api_key_hash and sum the rows per day:

curl -s "https://openrouter.ai/api/v1/activity?api_key_hash=$KEY_HASH" \
  -H "Authorization: Bearer $OPENROUTER_MANAGEMENT_KEY" \
  | jq -r '.data | group_by(.date) | .[]
      | [.[0].date, (map(.usage) | add), (map(.byok_usage_inference) | add), (map(.requests) | add)]
      | @tsv'

It covers the last 30 completed UTC days, so today never appears, and it needs a Management key. Use date=YYYY-MM-DD for a single day, user_id for an organization member, and workspace_id or group_by=workspace for workspaces. A workspace-scoped Management key needs activity:view_all and only sees its own workspace.

5. Per request: log usage.cost yourself

Every OpenRouter response now carries a usage object with cost (what was charged), token counts and is_byok; the old usage: { include: true } parameter is deprecated and has no effect (usage accounting). If you log cost with your own job, tenant or agent ID, you get a per-request breakdown finer than any per-key view. Later lookups by generation ID go through GET /api/v1/generation?id=….

Why the totals don't match

  • BYOK: key fields count credits only (BYOK in byok_usage_*); Analytics total_usage adds BYOK inference; the Activity page estimates BYOK spend at market rates, without your provider discounts.
  • Time zones: every window is UTC. “Today” in Lisbon or San Francisco isn't OpenRouter's day.
  • Missing keys: disabled and expired keys, other workspaces, Management and OAuth keys aren't in a default keys list.
  • Account vs key: GET /api/v1/credits (Management key) gives total credits bought and used for the whole account, not per key, so it won't equal the sum of your keys if anything else spends (Analytics labels chatroom use as its own “Chatroom” bucket).

What these views don't do

  • They don't stop anything. Reading spend per key doesn't cap it. The cap is the key's own credit limit with a daily reset, a workspace budget or a guardrail: see OpenRouter API key limits.
  • They don't warn you. Nothing here sends a message when a key's daily spend jumps; you'd have to poll and compare yourself.
  • The Management key is powerful. It can't make model calls, but it can read your whole spend breakdown and disable or delete keys. Give it an expiration date and keep it out of the app.

Checklist

  1. One key per app, agent or customer, so per-key numbers mean something.
  2. A credit limit with a daily reset on every automated key.
  3. A scheduled job calls GET /api/v1/keys (with include_disabled and include_expired, every workspace) and flags keys whose usage_daily is far above normal.
  4. A monthly Analytics query grouped by api_key_id and model to find which workload drives the bill.
  5. Decide whether BYOK counts in your numbers, and use matching fields everywhere.

Also on OpenAI or Anthropic? The free AI key limit audit checks whether your limits across all three providers would stop a runaway loop or a leaked key (no sign-up, no key needed). Related: OpenRouter key limits, OpenRouter 402 insufficient credits, OpenAI cost per API key, runaway AI agent cost.

Where KeyBark fits (and where it doesn't)

KeyBark does the polling part of step 3 of the checklist for keys you connect. It reads a key's OpenRouter usage from our servers about every 15 minutes during the beta (through /api/v1/key, or /api/v1/keys/{hash} with a Management key) 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. On paid plans you can opt in to a kill switch (beta) that disables a key you name through OpenRouter's API when a threshold is crossed.

Limits, honestly: KeyBark watches the keys you connect one by one (the free plan covers one key), not every key in your account; it doesn't use the Analytics API, so there is no per-model breakdown; it counts OpenRouter credit usage, not BYOK; checks run on a schedule, so an alert can come after money has been spent; and it doesn't set OpenRouter limits for you. Set the key's own credit limit first. KeyBark is a second line of warning on top of it.

FAQ

How do I see how much each OpenRouter API key has spent?

In the dashboard, open the Activity page and group by API key. Through the API, call GET /api/v1/keys with a Management API key: every standard key in the workspace comes back with usage_daily, usage_weekly, usage_monthly and lifetime usage in USD. For a breakdown over a date range, POST /api/v1/analytics/query with dimensions ["api_key_id"] and the total_usage metric.

Can a normal OpenRouter API key see its own spend?

Yes. GET /api/v1/key with the key itself returns its usage for the current UTC day, week (Monday to Sunday) and month, plus lifetime usage, its limit and limit_remaining. Listing other keys, /api/v1/activity, the Analytics API and /api/v1/credits all need a Management API key; a regular key gets a 403.

Why doesn't /api/v1/activity show today's spend?

OpenRouter's reference says it returns activity for the last 30 completed UTC days, so the current day isn't in it. For today, read usage_daily from /api/v1/key or /api/v1/keys, or run an Analytics API query with granularity hour and a time range starting at 00:00 UTC today.

Why don't the per-key numbers match my OpenRouter Activity page?

They measure different things. The key fields usage_daily, usage_weekly and usage_monthly count OpenRouter credit usage only, with BYOK usage in separate byok_usage_* fields. The Analytics metric total_usage includes BYOK inference cost, and OpenRouter says BYOK spend on the Activity page is estimated at market rates. Windows are UTC, and the keys list skips disabled and expired keys unless you ask for them.

Sources (read 12 Nov 2026): OpenRouter API reference Get current API key, List API keys, Query analytics data, Get user activity, Get remaining credits, Get a generation; guides Activity, Control costs with the Analytics API, analytics schema, Usage accounting, API key audit and Management API keys. KeyBark is not affiliated with OpenRouter.

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.