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.
Key Files
Section titled “Key Files”| File | Purpose |
|---|---|
src/features/providers/economics/ProviderEconomicsOverlay.tsx | Provider cost overlay UI |
src/replay/ReplayEconomicOverlay.tsx | Per-trace cost breakdown |
API Endpoints
Section titled “API Endpoints”| Endpoint | What it does |
|---|---|
GET /api/economics/trace/:traceId | Cost breakdown for a single trace |
GET /api/economics/profiles | Available cost profiles |
GET /api/economics/simulate/:traceId | Simulate cost with a different strategy |
GET /api/economics/simulations | List past simulations |
GET /api/economics/savings | Total savings summary |
GET /api/economics/savings/providers | Savings broken down by provider |
GET /api/economics/savings/strategies | Savings broken down by strategy |
GET /api/economics/savings/monthly | Monthly savings trend |
GET /api/economics/insights | Cost intelligence and recommendations |
GET /api/budgets | Budget configuration |
GET /api/budgets/events | Budget threshold events |
GET /api/cost/dashboard | Cost dashboard data |
GET /api/cost/intelligence | Pricing intelligence feed |
How Savings Are Computed
Section titled “How Savings Are Computed”- Baseline: What would the request have cost with the default provider (e.g., GPT-4o)
- Actual: What the routed request actually cost
- 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.
Budget Protection
Section titled “Budget Protection”- 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
Cost Intelligence
Section titled “Cost Intelligence”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