Skip to content

Answer the owner-funded text AI with Anthropic first and Groq as fallback - #39

Merged
ankurmans merged 1 commit into
mainfrom
ai/anthropic-primary-groq-fallback
Nov 11, 2026
Merged

ankurmans merged 1 commit into
mainfrom
ai/anthropic-primary-groq-fallback

Conversation

@ankurmans

Copy link
Copy Markdown
Owner

The writing tools (rewrites, subject lines, preview text, social drafts), the support and account assistants, Reply Rules and reader-requested translations now go through one module, `lib/platform-ai.js`.

Order. FlockStack's own Anthropic key (Haiku 5.5 for routine text and classification, Sonnet 5.5 for social drafts and the account assistant), then its own Groq key (GPT-OSS-20B) on an error or timeout, then Workers AI. `AI_MODEL_FAST`, `AI_MODEL_STRONG`, `AI_MODEL_FALLBACK` rename models; `AI_PROVIDERS_DISABLED=true` is a kill switch. Budgets, the once-per-request daily count, schemas, tool permissions and tab-only chat history are unchanged.

Nothing changes until the owner acts. Anthropic and Groq are new sub-processors, so on FlockStack Cloud neither is used until `AI_PROVIDERS_NOTICE_SENT_ON` in `lib/legal.js` is 30 days old (same rule as ElevenLabs). A self-hosted server uses a key as soon as it is set. Keys are Worker secrets, never `vars` (a test checks `wrangler.jsonc`).

Stays as it was. Briefings' bring-your-own-key adapters (never given these keys, never given theirs here), BGE embeddings, image generation (Workers AI), email delivery and regional data routing.

Pages. Privacy policy, `/sub-processors` (Anthropic and Groq added), regions page, consent text in the dashboard, action descriptions, README, `.env.example`, docs and code comments now say what the code does, before and after the notice. Replaces the old "never the Anthropic API" comments.

Attribution. `AiUsage.spend` keeps calls, failures, input and output tokens and a cost estimate per account per day, provider, model and feature, plus a log line with the same fields. No prompt or answer is stored or logged.

Not done / for the owner.

  • Workers AI remains for images, the BGE embeddings and as the text path until the notice is over (or if no key is set).
  • `TRANSFER_SAFEGUARDS` on the privacy page has no entry for Anthropic or Groq: I did not verify their data processing agreements. Add them before the notice goes out.
  • No secret is set and nothing is deployed.

Tests. New: `tests/platform-ai.test.mjs`, `tests/ai-providers-notice.test.mjs`. Full suite run: 4,095 of 4,105 passed on the first pass; the failures were the API-worker target and `contacts` timing out under load, plus stale assertions I updated. Re-run and passing: legal, support, public parity (after `npm run build:public`), contacts, AI suites under `FLOCKSTACK_API_TARGET=worker`, api-worker, router, query budget. Lint has 0 errors; `build:public`, `build:api`, `build:readers`, `build:briefings` succeed. A real Anthropic or Groq call was not made.

…back

The writing tools, the support and account assistants, Reply Rules and reader
translations go through one module, lib/platform-ai.js: Claude Haiku 5.5 for
routine text and classification, Sonnet 5.5 for social post drafts and the
account assistant, Groq GPT-OSS-20B when Anthropic can't answer, Workers AI
only where neither key may be used. Briefings' own keys stay apart; embeddings
and images stay on Workers AI.

On FlockStack Cloud both providers wait for the 30 days' sub-processor notice
(AI_PROVIDERS_NOTICE_SENT_ON), so nothing changes until the owner sets it.
The privacy policy, sub-processors and regions pages say what is true before
and after. Per-account provider, model, token and cost counts are kept with
no text (AiUsage.spend).
@ankurmans
ankurmans merged commit 71b69da into main Nov 11, 2026
2 of 3 checks passed
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