Skip to main content

Ingest cost event

POST /api/v1/costs/events
No authentication required. Called automatically by quality.emit() when token counts are provided. Body:
{
  "agent_id": "invoice-processor-v2",
  "job_id": "job-001",
  "model": "gpt-4o",
  "provider": "openai",
  "input_tokens": 1247,
  "output_tokens": 312
}
Response:
{
  "event_id": "uuid",
  "cost_usd": 0.0343,
  "cost_display": 0.03,
  "display_currency": "USD"
}

Cost summary

GET /api/v1/costs/summary?days=30
{
  "period_days": 30,
  "total_cost_usd": 5481.89,
  "total_cost_display": 5481.89,
  "unattributed_cost_usd": 0,
  "display_currency": "USD",
  "daily_trend": [
    {
      "date": "2026-02-22",
      "cost_usd": 190.54,
      "cost_display": 190.54
    }
  ]
}

Agent cost detail

GET /api/v1/costs/agents/{agent_id}?days=30

Department costs

GET /api/v1/costs/departments
Returns this month’s spend grouped by department, with budget utilisation if budgets are set.

Set department budget

POST /api/v1/costs/budgets
{
  "department": "Finance",
  "month": "2026-03-01",
  "budget_amount": 5000.00
}