LLM Pipeline
Editorial enrichment (editorial._llm_complete) with a free-first provider chain and
per-feature cost accounting.
Provider order
Groq → OpenRouter → DeepSeek → Ollama
Free tiers first, paid DeepSeek third, local Ollama last. (Racing + RSSSPORTS editorial
must stay free-first; see deepseek-token-harness for DeepSeek-Pro usage.)
Cost tracking
- Every successful completion appends to
/opt/sportstlm/data/llm_usage.jsonlvia
app/services/llm_log.pywith: provider, model, feature label, tokens, estimated cost. - Feature labels in use:
paraphrase:sportsmole,preview:scraper,debrief,draft. - Any new tool that calls
_llm_complete(..., feature="x")appears automatically.
Reporting
/opt/ops/llm_cost_report.py [--days N] [--telegram]→ console table +
/opt/ops/llm-cost.json.llm-cost-report.timerrefreshes every 15 min.llm-cost-digest.timersends daily summary at 21:00 SGT.- The 08:00 health digest also carries the cost line.
Pricing
llm_log.PRICES holds the per-1M-token table. Unpriced models are counted and
flagged, not silently zeroed.
Provider health / balance
provider_balance.py/provider_guard.py+provider-balance.timertrack provider
health, thresholds and balance (see/opt/ops/provider-state/).
Guardrail
Public site copy must never reveal AI/LLM/paraphrasing usage — neutral wording only.