Support Cloudflare Workers AI (Clef) via pluggable providers - #2
Merged
Merged
Conversation
JevConfig gets a provider: TypeSafe (default) or WorkersAI(accountId),
which posts to accounts/{id}/ai/run/@cf/cloudflare/{model} and reads the
answers from Cloudflare's result envelope. Listing models isn't
supported there. Adds JevConfig.workersAI/workersAIFromEnv and the
ModelId.clef/clefFlash constants.
A Noul without criteria now omits the field instead of sending null,
which Clef rejects.
The triage example's core now takes a Jev, shared by Main and a new
ClefTriage entry point.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Everything that differs between System One APIs now lives in a Provider[F]: the default model, endpoints, credentials and unwrapping the response body. The client no longer matches on providers, so a new API is just another implementation. authorize is effectful and runs under the retry middleware, so every attempt can fetch or refresh credentials. The TypeSafe and Workers AI providers read their env vars once, at build time. JevConfig shrinks to a provider plus retry settings. JevConfig.fromEnv and JevConfig.workersAI are replaced by Provider.typeSafeFromEnv and Provider.workersAI(FromEnv), and MissingApiKey by MissingEnv(name). Co-Authored-By: Claude Opus 5.5 (1M context) <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.
Adds support for Cloudflare's Clef models, which serve the System One format, and makes the API provider pluggable so other APIs can be added later.
Provider[F]trait: default model, evaluate/models endpoints, effectfulauthorize(runs on every attempt, retries included, so tokens can be refreshed) andunwrapfor response envelopes.Provider.typeSafe/typeSafeFromEnvandProvider.workersAI/workersAIFromEnv; env vars are read once at build time.JevConfigis nowJevConfig[F](provider, retry). Breaking:JevConfig.fromEnvis replaced byProvider.typeSafeFromEnv,MissingApiKeybyMissingEnv(name).null, which Clef rejects.example.ClefTriage; the triage example's core takes aJevand is shared withMain.Verified live: the triage example runs against both
clefandjev-1.13.0.🤖 Generated with Claude Code