TokenGuard

Your AI bill is not a surprise
you should discover at month end.

A gateway between your users, your agents, and the LLM provider APIs. Calls that pass through it are attributed to a user, team, and cost center, checked against a budget before they are sent, and logged.

3 Actions on an over-budget call: block, throttle, alert
5 Enforcement layers in v1
On-prem Self-hosted option: keys and logs stay in your environment

LLM budget control, rate limiting, and token middleware

TokenGuard sits between the application and the provider API. Over-budget calls throttle, block, or alert. The keys and the logs stay in your environment when you self-host. The limit applies on the call, before the invoice arrives.

Four ways AI spend gets out of control

These are common once several teams and agents share LLM keys. TokenGuard is built for all four.

Agentic loops burn a month of budget in hours

Autonomous agents running in a loop — a misconfigured retry, an infinite planning cycle, a context window overflow that triggers repeated calls — can consume a month's token budget in hours. Monthly budget checks catch this weeks after the damage is done. You need a circuit breaker that fires in minutes, not a finance review that fires at billing time.

Employees use corporate AI keys for personal projects

Corporate API keys are powerful and convenient. Employees route personal coding projects, side hustles, and family document drafting through corporate AI credentials. This is a cost problem, a data exposure problem, and an acceptable-use policy violation. Without token-level attribution and anomaly detection, it is also invisible until someone notices the bill.

No team-level visibility means no accountability

Many companies share one or two LLM API keys across all teams and all applications. Finance sees a total bill. No team lead knows what their team is spending. No cost center is accountable. Optimization conversations cannot happen because the data to have them does not exist. TokenGuard produces the attribution layer that makes AI spend manageable.

Budget enforcement happens outside agent code — or not at all

Putting budget logic inside agent code is fragile: it is easy to bypass, hard to audit, and inconsistent across teams. The gateway is the single point that LLM calls pass through, so a limit there applies to every team the same way. Enforcement that lives outside agent code cannot be circumvented by agent code.

Five enforcement layers, one gateway pass

Each LLM call routed through the gateway goes through the same five layers.

01

Attribute

The gateway identifies the user or agent making the call, maps it to a cost center and team, and estimates the token cost of the request before it is sent. A call with no identity is not forwarded.

02

Budget check

The attributed cost is evaluated against per-request ceilings, per-session rolling budgets, and per-key monthly caps. If any limit is exceeded, the enforcement action (block, throttle, or alert) is applied before the call reaches the LLM provider. When a threshold is close, the call can be routed to a cheaper model tier instead.

03

Circuit breaker

Rate-of-spend is evaluated against each key's rolling 7-day baseline. A key consuming tokens at 5x its baseline within a 15-minute window triggers the circuit breaker: the key is suspended, an alert is sent, and a human review is required to reinstate. This catches runaway agent loops before they consume material budget.

04

Anomaly score

Signal analysis runs asynchronously: time of day, volume pattern, model selection, session metadata, and role-based baseline deviation are combined into a personal-use anomaly score from 0 to 100. Scores above 70 are flagged for human review. This layer runs in parallel and does not add to request latency.

05

Log & attribute cost

Each call through the gateway, forwarded or blocked, is written to an immutable audit log. After the LLM provider responds, the actual token counts and cost are recorded and attributed to the user, agent, team, and cost center. This is the record behind for monthly chargeback reports.

What TokenGuard delivers

What each of the five layers gives you, in a single gateway deployment.

Capability What it does Enforcement layer
Identity attribution Map each call to a user or agent, a team, and a cost center, and estimate its cost before it is sent Layer 1 — attribute
Per-request ceiling Block requests whose estimated token cost exceeds a configurable ceiling per call Layer 2 — budget check
Per-session budget Track rolling token spend within a session and enforce a session-level budget cap Layer 2 — budget check
Monthly key cap Enforce a hard monthly spend limit per API key, with configurable alert thresholds (80%, 95%, 100%) Layer 2 — budget check
Model-tier routing Redirect requests to a lower-cost model tier when budget thresholds are approached, without blocking Layer 2 — budget check
Circuit breaker Suspend keys showing anomalous rate-of-spend against their rolling baseline, to stop runaway agent loops early Layer 3 — circuit breaker
Personal-use detection Probabilistic anomaly scoring for personal-use misuse patterns; flags for human review, never auto-blocks Layer 4 — anomaly score
Cost attribution Per-user, per-agent, per-team, per-cost-center attribution of actual token costs after the provider responds Layer 5 — log & attribute cost
Chargeback reports Monthly spend reports by team and cost center, schedulable delivery, CSV export and API access Layer 5 — log & attribute cost

Common questions

TokenGuard deploys as a transparent gateway between your users and agents and the LLM provider APIs. If you are currently calling OpenAI, Anthropic, Google, Azure OpenAI, or Mistral directly, you point your SDK base URL at the TokenGuard gateway — one configuration change, no application logic changes. TokenGuard issues per-user or per-agent synthetic API keys that route through the gateway; the gateway translates to your real provider credentials, which are stored in a secrets vault and never exposed to end users or agents. For LangChain, LlamaIndex, and other orchestration frameworks, we provide pre-built callback handlers and middleware that require no changes to agent logic.

The enforcement action is configurable per budget policy: Block (the LLM call returns an error), Throttle (the call is queued and rate-limited), or Alert (the call goes through but the budget owner and administrator are notified immediately). A common start is Alert on first breach, moving to Block after a review period. Budget violations produce an immutable audit log entry with the full context of the blocked or alerted call — who made it, which model, how many tokens were estimated at request time, and the actual cost recorded after the response. Budget resets are explicit administrative actions, not automatic — preventing end-of-month budget renewal surprises.

The circuit breaker monitors rate-of-spend rather than cumulative spend — catching runaway loops before they exhaust a monthly budget in hours. If a user or agent key shows token consumption exceeding a configurable multiple of its rolling baseline (default: 5x the 7-day rolling average within a 15-minute window), the circuit breaker fires: the key is suspended, an alert is sent to the administrator, and a human review is required to reinstate. This catches the agentic loop where one misconfigured agent burns through a month of budget before a monthly check would notice. The circuit breaker is per-key, so a single runaway agent does not affect other users or teams.

TokenGuard uses probabilistic signal analysis rather than content reading. Signals include: time of request (outside business hours), request volume pattern (single-user sustained high-volume sessions characteristic of personal projects), model selection (higher capability models with no business justification on record), session metadata (request diversity patterns inconsistent with role-based use cases), and volume baseline deviation. These signals are combined into an anomaly score from 0 to 100. Scores above 70 are flagged for human review — they are never auto-blocked, because the signals are probabilistic, not deterministic. A reviewer sees the supporting signals and decides: dismiss or confirm. This approach avoids content analysis, preserving user privacy while still detecting systematic misuse.

Monthly chargeback reports are generated per billing period and include: total cost by user, by team, by cost center, by model, and by provider; request counts and average cost per request; month-over-month trend; top consumers ranked by spend; and a detailed event log available for download as CSV or via API. Reports are available in the TokenGuard dashboard and can be scheduled for automated delivery to finance and team leads. The cost attribution model is configurable: you can attribute by the API key used, by the user identity propagated in request headers, or by the project or cost center tag set in the request metadata.

Yes. TokenGuard is available as a fully self-hosted deployment for organizations in regulated industries that cannot route LLM call metadata through a cloud-hosted governance product. The on-premise deployment runs on standard Linux infrastructure, requires no external service dependencies at runtime, and stores all audit logs, budget policies, and anomaly events within your environment. Deployment is supported on Kubernetes, Docker Compose, or bare-metal Linux. For organizations already using GDPR Oversight, the two products share an infrastructure layer — reducing deployment footprint when both governance capabilities are needed.

The person this product assumes

TokenGuard enforces a budget and flags a runaway loop. AI Ops is the seat on call when the bill or the behavior moves. Someone still has to decide what happens when a budget fires or a loop trips the breaker. TokenGuard does not replace that person.

Book the AI Ops seat

Named seats

Put the budget on the call, not the invoice

Tell us your LLM provider setup, your team structure, and your biggest cost concern. On the call we go through what TokenGuard would check in your environment and what it takes to get team-level attribution in place.