Files
9628b5f868 fix(ai): give text analysis a real multi-vendor fallback chain (#238)
llm-analysis.js and aiAnalysisService.js each constructed their own
OpenAI client, hardcoded model: 'gpt-4', and threw/skipped outright
whenever OPENAI_API_KEY was unset — a single vendor, single model, with
no recovery path. The moment OpenAI has a billing hiccup, an outage, or
retires gpt-4, every text-analysis feature in this app goes dead until
someone notices and redeploys.

backend/lib/aiChain.js gives both services a real chain via ai-kit
(Groq -> OpenRouter free tier, same package already adopted fleet-wide
for this exact failure mode), plus a health tracker exposed
informationally on /health (never gates the endpoint's status — a dead
vendor key can't be fixed by a restart).

Vision/image analysis (imageIngestionService.js, video frame analysis,
openaiVisionService.ts) and Whisper audio transcription stay on OpenAI
directly: ai-kit's free chain carries no vision- or audio-capable free
models, so forcing those onto it would silently degrade output quality
rather than provide a real fallback. Documented as a known limitation
in .claude/CLAUDE.md's env var list.


Claude-Session: https://claude.ai/code/session_01HVwg8DKHQktxJuHeLM3xpG

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-02 09:16:38 +00:00
..