clef driver connects Polyglot Decision to Cloudflare’s hosted
Clef and
Clef-flash
decision models on Workers AI. Both speak the System One protocol: a state
plus a map of typed noul, choice, and score questions in, one
probability distribution per question out.
Output tokens are not billed.
Configure the driver
Set the Cloudflare account ID and an API token with Workers AI access:https://api.cloudflare.com/client/v4/accounts/{account}/ai with the endpoint
/run/@cf/cloudflare/{model}. The driver substitutes the effective model into
{model}, so a per-request model override changes both the URL route and the
model field of the body.
Protocol notes
- Every question needs instructions. The driver rejects a question without them before sending the request.
- Clef accepts 1 to 64 questions, 2 to 255 Choice options, and 2 to 10 Score levels. Text, object, and list state keep their System One shape.
- Cloudflare wraps results in a
{result, success, errors, messages}envelope. The adapter unwraps it, fails closed whensuccessis nottrue, and also accepts an unwrapped System One body. - The
cf-rayresponse header becomes the provider request ID. - Probabilities are returned rounded to four decimals, so the adapter checks distribution sums and probability-weighted scores with a 0.02 tolerance.
- The optional Clef
imagesextension is not exposed by the Decision API.
Live smoke
CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in the environment.