Skip to content

feat: drop the bespoke Anthropic client for ai-kit's Groq -> OpenRouter chain - #49

Merged
github-actions[bot] merged 1 commit into
mainfrom
feat/ai-kit-migration
Sep 1, 2026
Merged

feat: drop the bespoke Anthropic client for ai-kit's Groq -> OpenRouter chain#49
github-actions[bot] merged 1 commit into
mainfrom
feat/ai-kit-migration

Conversation

@catomean

@catomean catomean commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • This app had the only hand-rolled AI client in the fleet — a plain Anthropic Messages API wrapper needing its own ANTHROPIC_API_KEY, a credential this fleet doesn't carry anywhere. Every deployment only ever sets GROQ_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: same callClaude/callLLM signature and null-on-failure contract every caller already handles, now backed by freeChain('SURF') + usableChain + tryChain across Groq -> OpenRouter instead of a single vendor.
  • Wires the same createHealthTracker pattern used fleet-wide onto /api/health as an informational llm field — never gates the 200/503 the deploy pipeline checks.
  • Does not touch lib/domain/embeddings.ts — that's OpenAI text-embedding-3-small for 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

…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
@github-actions
github-actions Bot merged commit bd7bc35 into main Sep 1, 2026
1 check passed
@github-actions
github-actions Bot deleted the feat/ai-kit-migration branch September 1, 2026 06:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant