/ db / migrations / 079-llm-cost-budgets.sql
079-llm-cost-budgets.sql
 1  -- LLM cost budget estimates per call type
 2  -- Used for variance monitoring: alert when actual cost deviates >3x from expected
 3  CREATE TABLE IF NOT EXISTS llm_cost_budgets (
 4    call_type TEXT PRIMARY KEY,          -- matches llm_usage.stage
 5    expected_cost_per_call REAL NOT NULL, -- average expected cost in USD
 6    max_cost_per_call REAL NOT NULL,      -- 3x expected, triggers alert
 7    expected_model TEXT NOT NULL,         -- expected model name
 8    updated_at TEXT DEFAULT (datetime('now'))
 9  );
10  
11  -- Seed with known budgets based on current usage patterns
12  INSERT OR IGNORE INTO llm_cost_budgets (call_type, expected_cost_per_call, max_cost_per_call, expected_model) VALUES
13    ('scoring',              0.003,  0.009,  'openai/gpt-4o-mini'),
14    ('rescoring',            0.005,  0.015,  'openai/gpt-4o-mini'),
15    ('enrichment',           0.004,  0.012,  'openai/gpt-4o-mini'),
16    ('proposals',            0.0003, 0.001,  'anthropic/claude-3.5-haiku'),
17    ('overseer',             0.01,   0.03,   'anthropic/claude-sonnet-4-6'),
18    ('replies',              0.001,  0.003,  'openai/gpt-4o-mini'),
19    ('outreach',             0.001,  0.003,  'openai/gpt-4o-mini'),
20    ('keywords',             0.001,  0.003,  'openai/gpt-4o-mini'),
21    ('error-classification', 0.001,  0.003,  'anthropic/claude-3.5-haiku'),
22    ('agents',               0.002,  0.006,  'anthropic/claude-haiku-4-5');