Usage tracking API
The usage tracking system records per-event token consumption and tool execution metrics. You can query aggregated data by agent, model, or time period.The usage tracker records events to a PostgreSQL database whenever an AI completion or tool call is made. The endpoints below are read-only query APIs for retrieving aggregated usage data.
The live, user-facing endpoints on this page are
GET /api/dashboard/data, GET /api/dashboard/analytics, GET /api/dashboard/bootstrap, GET /api/dashboard/cost, and GET /api/dashboard/stats. The lower query endpoints are roadmap/spec documentation only and are not linked from the main navigation.Dashboard data
s-maxage=5, stale-while-revalidate=30).
Response
Response fields
Caching
Responses include CDN caching headers:Browser caching is prevented — only CDN-level caching is applied. Stale responses are served for up to 30 seconds while the CDN revalidates in the background.
Errors
Dashboard analytics
Query parameters
Response
Response fields
Errors
Dashboard bootstrap
gatewayToken returned is the authenticated user’s own token, enabling automatic pairing with their agent instance. The dashboard renders skeleton cards for runtime-dependent data while the full runtime probe completes in the background.
Response
Errors
Test usage logging (deprecated)
Cost dashboard
Query parameters
Response
Response fields
Errors
Dashboard stats
Response
Response fields
Plan-based agent limits
Theagents.limit value is determined by the user’s subscription plan:
Error handling
On failure, the endpoint returns a fallback response with zeroed-out values instead of an error status code:Errors
All query endpoints below require bearer token authentication and are served by the backend API.
Usage summary
Query parameters
Response
Response fields
Usage by agent
Path parameters
Query parameters
Response
Response fields
Usage by model
Query parameters
Response
Response fields
Daily totals
Query parameters
Response
Response fields
Tool stats
Query parameters
Response
Response fields
Usage event schema
Each usage event is intended to be stored as a row in theusage_logs table (Prisma model name: UsageLog). Events will be recorded automatically whenever an AI completion is made (for example, from the demo chat endpoint or agent chat). Cost is calculated at write time using per-model pricing rates.
Server-side logging
Every usage event emits a structured log line to the server console when it is recorded. This makes it possible to verify that the usage tracking pipeline is working without querying the database. Success log format:Because usage recording is fire-and-forget (it never blocks the API response), these log lines are the primary way to diagnose write failures. Monitor your server logs for
[UsageLogger] Failed to log usage entries if usage data appears to be missing from the cost dashboard.Cost dashboard logging
The cost dashboard endpoint emits its own diagnostic log lines prefixed with[Cost API]. These help you verify that the aggregation query is running and returning data.
Query result log:
The cost dashboard now sources plan subscription costs from the database and AI token usage from the backend metrics service. If the backend is unavailable, plan-based cost data is still returned.
500 response is returned:
When accessing the table through the Prisma ORM, use the camelCase field names (
userId, agentId, inputTokens, etc.). When writing raw SQL queries, use the snake_case column names shown above (user_id, agent_id, input_tokens, etc.).user_id, agent_id, created_at, and the composite pairs (user_id, created_at) and (agent_id, created_at) for efficient time-range queries.