RFC-0010: Cost Tracking

Track token usage, API costs, and budgets.

Abstract

This RFC defines cost tracking mechanisms for monitoring resource usage and enforcing budgets.

Cost Record Structure

{
  "id": "uuid",
  "intent_id": "uuid",
  "cost_type": "tokens",
  "amount": 1500,
  "unit": "tokens",
  "provider": "openai",
  "metadata": {
    "model": "gpt-4",
    "input_tokens": 500,
    "output_tokens": 1000
  },
  "recorded_at": "2024-01-15T14:30:00Z"
}

Budget Enforcement

Portfolios can have budgets. Cost tracking enables:

Aggregate Costs

GET /api/v1/intents/:id/costs returns total costs with breakdown by type and provider.