Repository navigation
Add Vercel and Cloudflare as Jev providers with an ordered fallback chain - #3
Merged
Merged
Conversation
…hain TypeSafe ran out of credit and every search failed with HTTP 402. Jev is also served by Vercel AI Gateway (typesafe-ai/jev) and Cloudflare Workers AI (typesafe/jev), so the client now speaks all three dialects behind the same TypeSafe-shaped interface and tries them in order. - JEV_PROVIDERS secret lists the enabled providers in order of preference; unset means typesafe only. Unlisted providers stay off even when their credentials exist, so the committed defaults stay TypeSafe-only while a deployment can run e.g. "vercel,typesafe,cloudflare". - A request moves to the next provider only on 402, 429 or 5xx, never on client errors or after cancellation. Each hop is logged. - Vercel: POST /v4/ai/evaluation-model; noul questions become boolean, TypeSafe's confidence is read from provider metadata. - Cloudflare: Workers AI binding; "Insufficient AI Gateway credits" and similar binding errors map to 402 so the chain continues. - The intent event carries `judge`, the provider that answered. - README documents every variable, the switch semantics and provider billing notes; .dev.vars.example lists all secrets. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
jev-search | c0c8be1 | Commit Preview URL Branch Preview URL |
Sep 19 2026, 09:34 AM |
`wrangler versions upload` refuses to deploy when a secret listed in `secrets.required` is missing, which broke Workers Builds on the PR because JEV_PROVIDERS and AI_GATEWAY_API_KEY are optional. Without the list, local dev injects every key from .dev.vars, so fallbacks remain testable. Type generation now reads `.dev.vars.example` via `--env-file`, so the committed worker-configuration.d.ts no longer depends on a developer's private .dev.vars and matches in CI. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
Why
TypeSafe ran out of credit on 2026-09-19 and every search failed with HTTP 402, even though Search1API was healthy. Jev is also served by Vercel AI Gateway (
typesafe-ai/jev) and Cloudflare Workers AI (typesafe/jev). This PR lets a deployment use any of the three and fall back between them.What changes
src/lib/typesafe.tsspeaks all three dialects behind the existing TypeSafe-shaped interface. The chain tries providers in order and moves on only for HTTP 402 (no credit), 429 (throttled) or 5xx. Client errors such as 400/401 are not retried, and nothing is retried after the request is cancelled. Each hop is logged.JEV_PROVIDERSsecret lists the enabled providers in order of preference. Unset meanstypesafeonly, so the committed defaults are unchanged; unlisted providers stay off even when their credentials exist.src/lib/judge-config.tsbuilds the chain from the environment.POST https://ai-gateway.vercel.sh/v4/ai/evaluation-model(the AI SDK evaluation-model protocol, read from@ai-sdk/gatewaysource).noulquestions becomeboolean; TypeSafe's confidence is read from provider metadata.AIadded towrangler.jsonc; idle unless listed. Binding errors such as "Insufficient AI Gateway credits" map to 402 so the chain continues.intentevent carriesjudge, the provider that answered..dev.vars.examplelists every secret.Behaviour after merge
No change for the hosted demo until secrets are uploaded: with no
JEV_PROVIDERSsecret the Worker uses TypeSafe alone, as today. Enabling fallbacks is twowrangler secret putcommands and needs no redeploy.Verification
pnpm build,pnpm cf-typegendiff clean,wrangler deploy --dry-runpass.JEV_PROVIDERS=vercel,typesafe,cloudflarereportedjudge: vercel.🤖 Generated with Claude Code