Skip to main content

Cost Management

Modulo provides cost controls to help manage token spend across teams and pipelines. Admin users can set daily spend limits, view cost reports, detect anomalies, and schedule cost report exports.

Spend Limits

Admins can set org-level and team-level daily spend limits. When a spend limit is reached, new runs that would exceed the limit are rejected.

  • Org-level limit: applies to all runs across the entire organisation
  • Team-level limit: applies only to runs for pipelines owned by that team
  • Limits are checked atomically using SELECT FOR UPDATE
  • Setting a limit to null clears it (no limit)

Cost Reports

The cost report endpoint (GET /api/v1/admin/costs) returns aggregated spend data grouped by team or org, for day/week/month/year periods.

Export

Cost data can be exported as CSV via GET /api/v1/admin/costs/export.

Scheduled Reports

Admins can create scheduled cost reports that are delivered to specified email recipients:

  • Supports daily, weekly, and monthly periods
  • Supports one_time and recurring schedules
  • Reports are in CSV format

Spend Anomalies

The system detects spend anomalies by comparing daily org spend against a rolling 7-day average. A day is flagged as anomalous when spend exceeds 2x the 7-day average.

  • Computed anomalies are merged with stored anomalies from the database
  • Anomalies can be dismissed by admins

API Endpoints

All cost management endpoints require admin authentication.

API Endpoints
Endpoint Description
GET /api/v1/admin/costs Cost report (period, group_by)
GET /api/v1/admin/costs/limits Current spend limits
PUT /api/v1/admin/costs/limits/org Set org daily spend limit
PUT /api/v1/admin/costs/limits/teams/{id} Set team daily spend limit
GET /api/v1/admin/costs/controls Cost control settings
PUT /api/v1/admin/costs/controls Update cost control settings
GET /api/v1/admin/costs/export Export cost report as CSV
POST /api/v1/admin/costs/reports Create scheduled report
GET /api/v1/admin/costs/reports List scheduled reports
DELETE /api/v1/admin/costs/reports/{id} Delete scheduled report
GET /api/v1/admin/costs/anomalies List spend anomalies
GET /api/v1/admin/costs/anomalies/dismiss/{id} Dismiss an anomaly