Skip to content

Economics & Budgeting

Layerr does not just route to the cheapest model. It routes to the most cost-effective model for the specific workload, and tracks every penny saved in the process. The economics system is built into the runtime, not bolted on as an afterthought.

FilePurpose
src/features/providers/economics/ProviderEconomicsOverlay.tsxProvider cost overlay UI
src/replay/ReplayEconomicOverlay.tsxPer-trace cost breakdown
EndpointWhat it does
GET /api/economics/trace/:traceIdCost breakdown for a single trace
GET /api/economics/profilesAvailable cost profiles
GET /api/economics/simulate/:traceIdSimulate cost with a different strategy
GET /api/economics/simulationsList past simulations
GET /api/economics/savingsTotal savings summary
GET /api/economics/savings/providersSavings broken down by provider
GET /api/economics/savings/strategiesSavings broken down by strategy
GET /api/economics/savings/monthlyMonthly savings trend
GET /api/economics/insightsCost intelligence and recommendations
GET /api/budgetsBudget configuration
GET /api/budgets/eventsBudget threshold events
GET /api/cost/dashboardCost dashboard data
GET /api/cost/intelligencePricing intelligence feed
  1. Baseline: What would the request have cost with the default provider (e.g., GPT-4o)
  2. Actual: What the routed request actually cost
  3. Savings: baseline - actual

If the routed request costs more than baseline (rare, but happens for quality-critical tasks), it is recorded as a premium spend with an explicit rationale.

  • Soft limits: Warnings when budget thresholds approach
  • Hard limits: Request rejection when budgets are exhausted
  • Profile-based budgets: Different budgets per workspace profile
  • Provider-level budgets: Cap spend on expensive providers

The system tracks:

  • Provider pricing changes: Detects when a provider changes their pricing
  • Model deprecation: Warns when a model is being phased out
  • Cheaper alternatives: Suggests cheaper models for previously expensive workloads
  • Trend analysis: Monthly/weekly cost trends with predictions