AI Cost & Token Usage Dashboard
AI Cost & Token Usage Dashboard
The AI Cost & Token Usage Dashboard gives you per-project visibility into every credit your agents consume. It surfaces spend by agent type, tracks trends over time, identifies the most expensive pipeline runs, and lets you set monthly budget thresholds with automatic visual alerts.
Accessing the Dashboard
Navigate to any product and select Operations → AI Cost & Budget in the left sidebar, or go directly to:
/dashboard/products/<project-id>/ai-cost
KPI Cards
At the top of the page, four KPI cards summarise the current month at a glance:
| Card | What it shows |
|---|---|
| Total Spend | Credits consumed this month in dollars |
| Token Usage | Aggregate input + output tokens across all agent runs |
| Agent Jobs | Total number of agent jobs completed this month |
| Budget Used | Percentage of the configured monthly limit consumed |
Budget Alert Bar
If you have configured a monthly budget limit, a progress bar appears beneath the KPI cards:
- 🟢 Green — below 80% of budget consumed
- 🟡 Yellow — 80–99% consumed; consider reviewing high-cost agents
- 🔴 Red — 100% of budget consumed; guidance text is shown
To set or update a budget limit, use the aiCost.setBudgetLimit tRPC procedure (see API Reference below).
Dashboard Tabs
By Agent Type
Horizontal bar chart ranking each agent type by total credit spend for the current month. Each row shows:
- Agent label and color indicator
- Number of runs
- Total token usage (input + output)
- Dollar cost
- Percentage of total monthly spend
Agent types covered include: Implementation, Research, Testing, Release, Security, Documentation, Design, Marketing, UI/UX, Performance, Compliance, Revenue, Dependency, and more.
Monthly Trend
A 6-month CSS bar chart of historical spend, rendered from the getMonthlyTrend procedure. Each bar represents one calendar month of aggregate credit deductions.
Top Pipelines
A table of the 5 most expensive pipeline runs this month, showing:
- Run ID (linked to the pipeline run detail page)
- Trigger type and start time
- Number of agent jobs in the run
- Total token usage
- Total cost
A proportional cost bar makes it easy to spot outlier runs at a glance.
Recent Runs
A chronological list of the last 50 individual credit deductions, enriched with:
- Agent type label and color badge
- Pipeline run reference
- Token breakdown (input / output)
- Cost per deduction
- Timestamp
Daily Spend Chart
A day-by-day bar chart for the selected time range (7d / 14d / 30d / 90d) appears above the tabs. Hover over any bar to see a tooltip with:
- Date
- Dollar cost
- Token count
- Job count
API Reference
All procedures are available under the aiCost namespace via tRPC.
aiCost.getMonthlySummary
Returns the current month's total spend, a breakdown sorted by cost per agent type, the top 5 pipeline runs by cost, and the configured budget limit with percentage consumed.
Input:
{ projectId: string }
Key response fields:
{
totalCost: number, // dollars
totalTokens: number,
totalJobs: number,
agentBreakdown: [
{
agentType: string,
totalJobs: number,
cost: number,
pctOfTotal: number,
inputTokens: number,
outputTokens: number,
successRate: number
}
],
topRuns: [ { runId, status, trigger, startedAt, jobCount, totalTokens, cost } ],
budgetLimit: number | null,
budgetPct: number | null
}
aiCost.getMonthlyTrend
Returns the last 6 months of spend as a time series.
Input:
{ projectId: string }
Key response fields:
[
{ month: string, cost: number, totalTokens: number, jobCount: number }
]
aiCost.getCrossProjectSummary
Returns aggregated monthly spend across all projects owned by the authenticated user. Useful for portfolio-level cost governance.
Input: (none — scoped to the authenticated user)
aiCost.setBudgetLimit
Upserts a monthly credit budget threshold for a project. Stored in billingSettings under the key ai_budget_monthly_limit.
Input:
{ projectId: string, limitDollars: number }
aiCost.getRecentTransactions
Returns the last 50 agent-run credit deductions for a project, enriched with agent type metadata.
Input:
{ projectId: string }
Data Model
All queries join three tables to scope data to the correct project:
creditTransactions
└─ agentJobs
└─ pipelineRuns (scoped by projectId)
Budget limits are stored as a row in billingSettings with:
key:"ai_budget_monthly_limit"value: dollar amount as a stringprojectId: the target project
Sidebar Navigation
The AI Cost & Budget link appears in the product sidebar under the Operations section, after Revenue & Growth. It uses the Coins icon.