Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.toktra.dev/llms.txt

Use this file to discover all available pages before exploring further.

Toktra gives you two complementary tools for controlling AI usage: policies for event-driven rules, and budgets for spending limits. Both are configurable from the dashboard and available via the Public API.

Policies

A policy is a rule that watches the event stream and takes an action when specific conditions are met. You define what to look for (conditions) and what to do about it (actions).

Policy conditions

Each policy has a trigger type and one or more conditions that narrow when the policy fires. Trigger types:
TriggerWhen it fires
Token budget exceededA user or department crosses a usage threshold
IP risk eventGitHub integration detects a potential IP leakage event
Unusual usage patternUsage deviates significantly from a user’s baseline
Department thresholdA department’s aggregate usage crosses a configured limit
Condition fields let you filter further — matching on risk level, user ID, department, token count, time of day, or model ID. Multiple conditions can be combined with AND (all must match) or OR (any must match). Example: a policy that fires only for high-severity IP risk events from the Engineering department:
Trigger: IP risk event
Conditions (AND):
  risk_level = high
  department_id = engineering

Policy actions

When a policy fires, it can take one or more actions:
ActionWhat it does
Send email to userNotifies the user whose activity triggered the policy
Send email to managerNotifies the user’s manager
Block LLM access (hard cap)Immediately stops the user’s LLM requests
Create incidentOpens a new incident in Toktra’s incident tracker
Webhook POSTSends a JSON payload to a URL you configure
You can stack multiple actions on a single policy — for example, create an incident and send an email to the manager.

Policy lifecycle

Policies are created as drafts and must be published to become active. You can test a policy against historical data before publishing — the test shows how many events in the last evaluation window would have triggered the policy. Active policies can be disabled without deleting them.
Use the test function to tune condition thresholds before publishing. A policy with overly broad conditions can generate noise that drowns out real signals.

Budgets

Budgets set limits on how many tokens — or how much money — a department or the whole organization can spend in a given period. When a budget is reached, Toktra can warn, alert, or hard-block further requests.

Department hierarchy

Budgets are organized around your department hierarchy. Departments can be nested: a parent department’s budget is the aggregate of its children. If Engineering has a budget of 10 million tokens and has sub-departments (Backend, Frontend, Data), each sub-department has its own budget that rolls up to the Engineering total. You configure the hierarchy in Budget Management → Department Hierarchy. The dashboard shows a collapsible tree view of departments with live usage gauges.

Soft caps vs. hard caps

Each budget can be configured as a soft cap or a hard cap.
Cap typeWhat happens at the limit
Soft capAn alert is triggered. Requests continue.
Hard capAll LLM requests from users in that department are blocked until the budget resets or an exemption is granted.
Hard caps enforce at the agent level — the Chrome extension performs a sub-200ms preflight check before sending requests. Requests that exceed the cap are blocked before they reach the LLM provider. Ensure your team is aware before enabling hard caps on production departments.

Budget rollovers

Budgets can be configured to roll over unused tokens month-to-month. You set a rollover cap percentage — for example, 50% means that up to half of the unused monthly budget carries forward. This prevents departments from losing tokens they didn’t use without incentivizing wasteful end-of-month spending. Rollover history is visible in Budget Management → Rollover History.

Budget exemptions

When a hard cap blocks a user who has a legitimate need, they or their manager can submit a budget exemption request through the dashboard. Exemption requests route to an admin approver. Approved exemptions temporarily raise or lift the cap for the specified user and period. Manage exemptions at Budget Management → Exemptions.
Exemption requests are logged in the audit trail regardless of outcome. Admins can see who requested exemptions, who approved them, and for what period.

Policies vs. budgets

Both policies and budgets can trigger alerts, but they serve different purposes:
PoliciesBudgets
Primary purposeEvent-driven governance rulesSpending limit enforcement
EvaluatedIn real time, per eventContinuously against cumulative totals
ScopeFlexible (user, department, model, risk level)Department or org
ActionsAlert, block, create incident, webhookAlert (soft cap), block (hard cap)
ResetsNever (stateless per evaluation)Monthly (with optional rollover)
In practice, most organizations use both: budgets to enforce overall spending limits, and policies to respond to specific events like IP risk detections or unusual usage spikes.