Skip to content

Cost & budgets

Every workflow step records tokens in/out, latency (ms), external API calls, and USD cost from env pricing.

Pricing (env)

COST_TRACKING_ENABLED=true
COST_PRICE_INPUT_PER_1K=0.03
COST_PRICE_OUTPUT_PER_1K=0.06
COST_PRICE_EXTERNAL_API_CALL=0.001

UI

Open Cost in the dashboard to see per-agent spend, set monthly budgets, and watch alert thresholds.

API

Agent cost for a period:

curl "http://localhost:8001/api/v1/cost/agent/$AGENT_ID?period=last_7_days" \
  -H "Authorization: Bearer $JWT" \
  -H "X-API-Key: $TENANT_API_KEY"

Set a budget (hard stop when exceeded):

curl -X POST http://localhost:8001/api/v1/cost/budget \
  -H "Authorization: Bearer $JWT" \
  -H "X-API-Key: $TENANT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"agent_id":"'"$AGENT_ID"'","limit_usd":50,"period":"monthly","alert_threshold":0.8}'

Alerts

Budget warnings / exceeded events are published on the realtime WebSocket channel cost.budget.alert. Prometheus metric budget_exceeded_total backs the BudgetExceeded alert rule.

See also: Workflows · Dashboard