Skip to content

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.

The cost dashboard provides a comprehensive overview:

A daily breakdown of your spending over the last 30 days.

See which agents are consuming the most tokens and budget.

Compare costs across different LLM models (e.g., GPT-4 vs. Claude vs. Groq).

Each completed run records:

FieldDescription
prompt_tokensTokens sent to the LLM
completion_tokensTokens generated by the LLM
total_tokensSum of prompt + completion tokens
cost_usdTotal cost in USD
modelWhich LLM model was used

These values are extracted from the run_end event payload.

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).

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.