Cost Tracking
InitRunner estimates USD cost for every agent run using the genai-prices library (a transitive dependency of pydantic-ai). Cost data is derived from token counts already stored in the audit trail -- nothing extra to configure.
Supported providers: OpenAI, Anthropic, Google, Groq, Mistral, xAI, DeepSeek, OpenRouter, Together, Fireworks.
CLI Commands
The initrunner cost command group provides cost analytics from the audit database.
cost report
Cost breakdown by agent.
initrunner cost report
initrunner cost report --agent my-agent
initrunner cost report --since 2026-04-01T00:00:00Z --until 2026-04-07T00:00:00ZOutput:
Cost Report
┏━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━┓
┃ Agent ┃ Requests ┃ Tokens In ┃ Tokens Out ┃ Est. Cost ┃ Avg/Request ┃
┡━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━┩
│ code-review│ 142 │ 890,200 │ 312,400 │ $4.82 │ $0.0340 │
│ support │ 38 │ 210,500 │ 95,300 │ $1.22 │ $0.0321 │
└────────────┴──────────┴───────────┴────────────┴───────────┴─────────────┘
Total: 180 requests, $6.04 estimatedFilters: --agent, --since, --until, --audit-db.
cost summary
High-level spend overview with time breakdowns and top agents.
initrunner cost summaryShows today, this week, this month, and all-time totals. Lists the top 5 costliest agents and a 7-day daily trend.
cost by-model
Cost grouped by model and provider.
initrunner cost by-model
initrunner cost by-model --since 2026-04-01T00:00:00Zcost estimate
Predict per-run cost from a role YAML before deploying.
initrunner cost estimate role.yaml
initrunner cost estimate role.yaml --prompt-tokens 1000Output:
Cost Estimate
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┓
┃ Metric ┃ Value ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━┩
│ Model │ openai:… │
│ Est. input tokens │ 3,400 │
│ Est. output tokens (typical) │ 1,228 │
│ Est. output tokens (max) │ 4,096 │
│ Per-run cost (typical) │ $0.0098 │
│ Per-run cost (max) │ $0.0241 │
│ Trigger firings/day │ 24.0 │
│ Daily estimate │ $0.2352 │
│ Monthly estimate │ $7.0560 │
└───────────────────────────────┴───────────┘The estimator uses the raw system prompt only (skills are excluded and labeled conservative). If the model is unresolved (no provider/name in the role config), token estimates are shown but USD projections are skipped.
USD Cost Budgets
In addition to token budgets, daemon and bot modes support USD-based cost limits via guardrails.
spec:
guardrails:
daemon_daily_cost_budget: 5.00 # USD per day
daemon_weekly_cost_budget: 25.00 # USD per week| Field | Type | Default | Description |
|---|---|---|---|
daemon_daily_cost_budget | float > 0 | null | Maximum USD spend per calendar day |
daemon_weekly_cost_budget | float > 0 | null | Maximum USD spend per ISO week |
Cost is estimated after each run using genai-prices and accumulated in the tracker. Daily cost resets at midnight in the configured budget_timezone (UTC by default). Weekly cost resets when the ISO week number changes. Warnings are logged at 80% and 95% consumption. When the budget is exhausted, further trigger executions are skipped.
Budget counters are persisted to the audit database after each run. Restarting a daemon or bot restores the counters, so spend tracking survives process restarts (since v2026.4.11).
When a cost budget is configured, InitRunner validates at startup that pricing data is available for the role's model and provider. If genai-prices doesn't cover that model, the daemon exits with a clear error rather than silently skipping enforcement.
Budget Timezone
By default, daily and weekly resets use UTC. Set budget_timezone to use a different IANA timezone:
spec:
guardrails:
daemon_daily_cost_budget: 5.00
budget_timezone: "America/New_York"Or override from the CLI:
initrunner run role.yaml --daemon --budget-timezone America/New_YorkThe --budget-timezone flag works with --daemon, --autopilot, and --bot.
Token budgets and cost budgets are enforced independently. You can use both:
spec:
guardrails:
daemon_token_budget: 5000000
daemon_daily_token_budget: 500000
daemon_daily_cost_budget: 10.00
daemon_weekly_cost_budget: 50.00Either limit being hit will pause the daemon.
Dashboard
The /cost page in the dashboard provides visual cost analytics.
- Summary strip at the top shows today, this week, this month, and all-time spend totals.
- Period selector (7d / 30d / 90d) controls the chart and both breakdown tables below.
- Spend chart shows daily cost as a bar chart. Hover any bar for date, cost, and run count.
- By Agent table breaks down cost per agent with runs, tokens, avg cost/run, and total. Rows link to the agent detail page.
- By Model table breaks down cost per model/provider combination.
The audit log (/audit) also shows a per-run cost column and includes cost in the detail drawer.
All cost values show N/A when pricing data is unavailable for a model/provider.
Live Cost During Streaming
When streaming a run from the dashboard, the TokenMeter shows a running estimated output cost (prefixed with ~). The estimate uses a character-to-token heuristic (chars / 4) and is corrected by the final result event. Input cost is unknown mid-stream and only appears in the final total.
Budget Progress Bar
Agent detail pages show a budget progress bar for any daemon agent with cost or token budgets configured. Each configured budget (daily tokens, daily cost, weekly cost, lifetime tokens) gets a gauge showing current consumption, limit, and percentage. Colors: green (under 80%), yellow (80-95%), red (over 95% or exhausted). The bar auto-refreshes every 30 seconds.
Dashboard API
| Endpoint | Description |
|---|---|
GET /api/cost/summary | Today/week/month/all-time totals, top agents, daily trend |
GET /api/cost/by-agent | Per-agent cost breakdown. Filters: since, until, agent_name |
GET /api/cost/daily | Daily cost time series. Params: days (default 30), agent_name |
GET /api/cost/by-model | Cost grouped by model/provider. Filters: since, until |
GET /api/agents/{id}/budget-progress | Live budget gauges (consumed/limit/percent/warning level) per budget type |
How Cost is Calculated
- Every agent run records
tokens_in,tokens_out,model, andproviderin the audit database. - Cost queries aggregate tokens via SQL (
GROUP BY agent/model/day) and applygenai-pricesper group. - If any group in a rolled-up total is unpriceable (unknown model/provider), the aggregate total shows
N/Arather than a misleading partial sum.
Per-Tool Cost Attribution
Since v2026.4.12, the audit trail also records cost at the individual tool-call level. This happens automatically — no configuration needed.
Each tool call tracks:
| Field | Description |
|---|---|
tool_name | Name of the tool invoked |
usage_count | Total number of individual calls |
run_count | Distinct runs that used this tool |
tokens_in | Input tokens attributed to the tool |
tokens_out | Output tokens attributed to the tool |
total_cost_usd | Aggregated USD cost |
avg_cost_per_use | Average cost per invocation |
The dashboard cost page includes a Tool Cost table showing this breakdown. Use it to identify which tools drive the most spend (e.g., shell calls that produce large outputs vs. lightweight datetime lookups).