AAU Billing
What is an AAU?
An Agentic Activity Unit (AAU) is a dimensionless measure of the governance cost of a single LLM tool call. Not every tool call carries equal risk or infrastructure cost — a read-only SELECT against a governed schema deserves a lighter weight than a cross-system data mutation or an admin-level operation. AAU gives operators one number they can reason about, rate-limit, and eventually price.
Weight table
| Intent category | Example operations | AAU weight |
|---|---|---|
| Read | read_select | 1× |
| Write | write_insert, write_update, write_delete | 3× |
| Governed | admin, cross-system transactions | 5× |
The weight is resolved from the intent context key that the SCHEMABOUND middleware attaches to every LlmToolCallAuditRecorded event. When no explicit intent is present the weight is heuristically derived from the tool/function name (see aau_weight_from_tool_name in services/backend/src/billing.rs).
How an AAU is recorded
LLM agent
└─▶ gRPC tool call (e.g. execute_query / insert_record)
└─▶ schemabound interceptor middleware
└─▶ EventBus::publish(LlmToolCallAuditRecorded { tool_name, context })
└─▶ BillingMeterRecorder::handle()
└─▶ tokio::spawn ──▶ INSERT INTO usage_events
-
Event source — Every tool invocation that passes through the SCHEMABOUND gRPC server emits a
LlmToolCallAuditRecordedevent on the globalEventBus. The event carriestool_nameplus acontextmap that includesorg_id,session_id,orm_model, andintent. -
Handler —
BillingMeterRecorder(registered insrc/grpc.rs) subscribes to the bus. Itshandlemethod is synchronous and non-blocking; the actual database write is dispatched as a fire-and-forgettokio::spawntask so the gRPC hot path is never stalled. -
Storage — Each event becomes one row in the
usage_eventstable:Column Type Notes idVARCHAR(36)UUIDv4 org_idVARCHAR(36)From request context session_idVARCHAR(255)Optional — agent session tool_nameVARCHAR(255)Raw gRPC/MCP tool name intentVARCHAR(64)read_select/write_*/adminaau_weightDOUBLE1.0 / 3.0 / 5.0 orm_modelVARCHAR(64)ORM model name, if known cost_usdDOUBLEReserved for future pricing; currently 0.0created_atTIMESTAMPServer timestamp
REST API
All billing endpoints require the caller to be authorised as billing admin (see Authorization below).
GET /billing/usage
Returns daily AAU totals for the authenticated organisation.
Query parameters
| Parameter | Format | Default |
|---|---|---|
from | YYYY-MM-DD | 1970-01-01 (all-time) |
to | YYYY-MM-DD | 9999-12-31 (all-time) |
Response
{
"data": [
{
"date": "2026-04-30",
"action_count": 42,
"total_aau": 87.0,
"total_cost_usd": 0.0
}
]
}
GET /billing/usage/heatmap
Returns AAU totals grouped by ORM model × intent — the matrix consumed by the D3 heat map on the AAU Dashboard.
Response
{
"data": [
{
"orm_model": "Person",
"intent": "write_insert",
"aau_weight": 3.0,
"total_aau": 9.0,
"action_count": 3
}
]
}
POST /billing/setup-intent
Creates a Stripe SetupIntent so the frontend can securely collect card details. Requires STRIPE_SECRET_KEY in the server environment.
Request body
{ "customer_id": "cus_abc123" }
Response — returns id, client_secret, and customer from Stripe.
GET /billing/payment-methods
Lists saved Stripe payment methods for the authenticated admin session.
DELETE /billing/payment-methods/<pm_id>
Detaches a Stripe payment method by its pm_… identifier.
Authorization
Billing endpoints are protected by the BillingAdmin request guard. A request is accepted when either condition is true:
X-User-Roleheader equalsadmin(case-insensitive), orX-User-Permissionsheader containsmanage:billing(comma-separated list).
Requests that satisfy neither condition receive 403 Forbidden.
AAU Dashboard
The AAU Dashboard (/aau-dashboard) in the frontend provides a live view of billing activity:
- Agentic Activity Heat Map — a D3-rendered matrix of ORM model × intent weight category. Cell colour intensity reflects the cumulative AAU total so operators can immediately spot which models and intent types are driving the most governance cost.
- Daily Usage Table — a chronological breakdown of
action_count,total_aau, andtotal_cost_usdper day. - Billing Panel — Stripe card management (add/remove payment methods) wired to the setup-intent and payment-method endpoints above.
Navigate to the dashboard via the AAU Dashboard link in the top navigation bar. The frontend sends X-User-Role: admin and X-User-Permissions: manage:billing automatically for the demo environment.
Extending pricing
The cost_usd column is reserved for future use. To enable per-unit pricing:
- Define a pricing schedule (e.g.
$0.001 per AAU). - Populate
cost_usdinsideBillingMeterRecorder::handlebefore theINSERT. - Surface the total in the Daily Usage Table — the
total_cost_usdfield is already returned byGET /billing/usage.