Cost Tracking
Cost Tracking
Section titled “Cost Tracking”agent-os tracks token usage and costs for every agent run automatically. The SDK reports token counts and cost data with run_end events.
/costs — Cost dashboard
Section titled “/costs — Cost dashboard”The cost dashboard provides a comprehensive overview:
30-day cost trend
Section titled “30-day cost trend”A daily breakdown of your spending over the last 30 days.
Per-agent costs
Section titled “Per-agent costs”See which agents are consuming the most tokens and budget.
Per-model costs
Section titled “Per-model costs”Compare costs across different LLM models (e.g., GPT-4 vs. Claude vs. Groq).
Token tracking
Section titled “Token tracking”Each completed run records:
| Field | Description |
|---|---|
prompt_tokens | Tokens sent to the LLM |
completion_tokens | Tokens generated by the LLM |
total_tokens | Sum of prompt + completion tokens |
cost_usd | Total cost in USD |
model | Which LLM model was used |
These values are extracted from the run_end event payload.
Budget warnings
Section titled “Budget warnings”When an agent has a budget set (see Agent Registry), the ingest API checks cost against budget after every run_end event. If the total cost exceeds the budget, the API response includes a budget warning:
{ "status": "ok", "budget_warning": "Agent 'my-agent' has exceeded its budget of $10.00"}Your SDK or integration can check for this warning and take action (e.g., pause the agent).
Cost data API
Section titled “Cost data API”The cost data endpoint (GET /costs/data) returns JSON suitable for charting:
- Daily cost totals (30-day window)
- Per-agent cost breakdown
- Per-model cost breakdown
This endpoint requires authentication.