Skip to content

Support Cloudflare Workers AI (Clef) via pluggable providers - #2

Merged
kubukoz merged 3 commits into
mainfrom
workers-ai
Oct 1, 2026
Merged

kubukoz merged 3 commits into
mainfrom
workers-ai

Conversation

@kubukoz

@kubukoz kubukoz commented Oct 1, 2026

Copy link
Copy Markdown
Member

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, effectful authorize (runs on every attempt, retries included, so tokens can be refreshed) and unwrap for response envelopes.
  • Built-in Provider.typeSafe / typeSafeFromEnv and Provider.workersAI / workersAIFromEnv; env vars are read once at build time.
  • JevConfig is now JevConfig[F](provider, retry). Breaking: JevConfig.fromEnv is replaced by Provider.typeSafeFromEnv, MissingApiKey by MissingEnv(name).
  • A Noul without criteria now omits the field rather than sending null, which Clef rejects.
  • New example.ClefTriage; the triage example's core takes a Jev and is shared with Main.
  • Bumps sbt to 1.13.0 and http4s to 0.23.38.

Verified live: the triage example runs against both clef and jev-1.13.0.

🤖 Generated with Claude Code

kubukoz and others added 3 commits October 1, 2026 18:54
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>
@mergify mergify Bot added the core label Oct 1, 2026
@kubukoz
kubukoz merged commit 115df1f into main Oct 1, 2026
14 checks passed
@kubukoz
kubukoz deleted the workers-ai branch October 1, 2026 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant