guide
Key usage monitoring
Know whose key is whose, what normal looks like, and when something's off — for both your BYO LLM connection (the one that can burn provider budget) and your project API keys. Per-project under the Keys tab; viewer+ reads, admin+ configures.
How it works
- Inventory & assignment
- Every monitored key — the BYO LLM connection and each project API key — carries one owner: an org member or a free-text service label. Only display prefixes are ever shown; full key material is never stored in plaintext.
- Usage events
- Metadata-only: LLM calls record model/tokens/cost/latency; project-key requests record route/status and a coarse hashed IP (unsalted truncated SHA-256) — a fingerprint for novelty detection, not anonymization (an unsalted IPv4 hash is reversible; treat it as personal data). Retention defaults to 30 days.
- Baselines
- A nightly job snapshots each key's normal window (default 14-day lookback). It only counts as warm after ≥20 events AND ≥48h of history — until then, detection falls back to your static caps.
- Privacy
- Nothing phones home. Events, baselines, and digests live in your Postgres; alerts and digests carry display prefixes only.
The alerts
Real-time checks run as usage arrives; the hygiene sweep runs nightly. Each alert names the key's display prefix, project, and assignee — never key material — and repeats of the same type for the same key dedupe within 6 hours (except key.unassigned, which uses a 24-hour window matching the nightly sweep).
| Alert | Fires when | Basis |
|---|---|---|
| llm_key.cost_spike | 24h LLM spend exceeds your static daily cost cap. | static |
| llm_key.baseline_deviation | 24h cost or tokens exceed sensitivity × the baseline average. | warm baseline |
| llm_key.new_model | The connection called a model not in its baseline set. | warm baseline |
| api_key.rate_spike | Hourly requests exceed the static cap or sensitivity × the baseline hourly rate. | static / warm |
| api_key.new_network | A request arrived from a hashed IP not in the baseline. | warm baseline |
| api_key.auth_failures | A disabled key was used repeatedly within an hour. | static |
| key.unassigned | A key has no assignee (nightly hygiene sweep). | static |
| a2a.budget_approach | A2A usage ≥ soft % of an active hard cap (UTC day). | A2A budget |
| a2a.budget_breach | A2A hard cut-off fired (429 on /api/a2a only). | A2A budget |
Tuning it
New to a project? Set the static caps first — they protect you immediately, before any baseline warms up. Then let baselines fill in the nuance.
| Setting | Default | What it does |
|---|---|---|
| Sensitivity | 3 | Baseline-deviation multiplier — usage must exceed N× normal to fire. Range 1.1–100. |
| Static daily cost cap (USD) | off | Hard ceiling for cost_spike; the safety net while a baseline is cold. |
| Static hourly request cap | off | Alert-only ceiling for rate_spike (does not cut off A2A or REST). |
| Project A2A daily ceiling | 50,000 on | Hard A2A cut-off (UTC day); see /guides/a2a-usage. |
| A2A soft approach % | 80 | Approach banner/email before A2A hard reject. |
| Baseline lookback (days) | 14 | How far back the nightly baseline looks. Range 1–90. |
| Event retention (days) | 30 | How long raw usage events are kept. Range 1–365. |
Disabling a compromised key
Toggle disabled from the inventory. A disabled project key stops authenticating (requests 401), and continued use raises api_key.auth_failures so you see the leaked key still being tried. A disabled LLM connection pauses all judge calls and scheduled evals. This stops use inside AgentSentri — for a leaked provider key, also rotate it at the provider's console; AgentSentri can't revoke a key your provider issued.
Daily digests
Org admins enable a daily digest in org settings — a UTC hour and recipient emails. It leads with LLM-key spend, then other keys, anomalies, and hygiene flags. Always stored in-app; also emailed when the server has SMTP_URL configured. The scheduler recomputes baselines and sweeps hygiene at 02:30 UTC and checks digests hourly (disable with KEY_MONITOR_SCHEDULER=0).