feat: drop the bespoke Anthropic client for ai-kit's Groq -> OpenRouter chain - #49
Merged
Merged
Conversation
…er chain
This was the one hand-rolled AI client in a fleet where everything else
installs ai-kit — needing its own ANTHROPIC_API_KEY, a credential this
fleet doesn't otherwise carry. Every deployment only ever has
GROQ_API_KEY / OPENROUTER_API_KEY set, so the four callers (form-assist,
session-prep, ai-chat, digest) degraded on every single deployment,
silently, exactly as designed — which is a working fallback, not a
correct one.
lib/domain/anthropic.ts -> lib/domain/llm.ts: same callClaude/callLLM
signature and null-on-failure contract every caller already handles, now
backed by freeChain('SURF') + usableChain + tryChain across Groq and
OpenRouter instead of a single vendor's Messages API. Also wires the same
createHealthTracker pattern adopted fleet-wide onto /api/health as an
informational `llm` field — never gates the 200/503 the deploy pipeline
checks, since a dead key can't be fixed by a restart.
Does not touch lib/domain/embeddings.ts (OpenAI text-embedding-3-small,
needed for real vector embeddings — a different kind of call ai-kit's
chat-only chain doesn't cover).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HVwg8DKHQktxJuHeLM3xpG
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ANTHROPIC_API_KEY, a credential this fleet doesn't carry anywhere. Every deployment only ever setsGROQ_API_KEY/OPENROUTER_API_KEY, so all four callers (form-assist, session-prep, ai-chat, digest) have been silently degrading to their rule-based fallback on every deployment — a working fallback, not a correct one.lib/domain/anthropic.ts->lib/domain/llm.ts: samecallClaude/callLLMsignature and null-on-failure contract every caller already handles, now backed byfreeChain('SURF')+usableChain+tryChainacross Groq -> OpenRouter instead of a single vendor.createHealthTrackerpattern used fleet-wide onto/api/healthas an informationalllmfield — never gates the 200/503 the deploy pipeline checks.lib/domain/embeddings.ts— that's OpenAItext-embedding-3-smallfor real vector embeddings, a different kind of call ai-kit's chat-only chain doesn't cover. Separate, still-open gap.Test plan
npm run verify(format + lint + typecheck + test) — all green, 627/627 tests passing