choicePick a category
Supply named options with descriptions. Read the selected option, confidence and per-option probabilities.
Decision model guide
Clef evaluates a shared state against questions you define, returning probabilities over allowed answers. Use it for routing, classification and checks inside an application.
A guide to Cloudflare's model. The example below runs on Workers AI with your Cloudflare account.
Incoming support message
“My account is locked after too many sign-in attempts. I need access before my meeting.”
choiceChoose the responsible team
scoreAssess urgency on an ordered scale
noulEstimate whether access is blocked
Illustrative questions; no live inference is performed here.
Workers AI specifications and pricing checked on October 3, 2026. See the official documentation for updates.
01 / How it works
Clef combines a Qwen backbone with a joint schema head. One forward pass scores the valid options across questions, without generating an intermediate text response.
choiceSupply named options with descriptions. Read the selected option, confidence and per-option probabilities.
scoreSupply ordered criteria. The answer includes a probability-weighted score over zero-based levels.
noulRead the probability of true. Set your application's threshold and decide when a person should review the result.
02 / Clef and Clef-flash
Cloudflare positions Clef for precision and Clef-flash for time-sensitive decisions. Evaluate both against representative examples from your own workflow.
| Model | Backbone | Reported median latency |
|---|---|---|
| Clef | Qwen3.8-27B | 209.3 ms |
| Clef-flash | Qwen3.5-9B | 38.8 ms |
Latency figures are from Cloudflare's published internal Decision Index evaluation. They are not a production latency guarantee.
Read the launch and evaluation details03 / Workers AI quick start
Add an AI binding named AI to your Worker, then call @cf/cloudflare/clef. The example evaluates three aspects of the same support message.
Pass model, state and questions. Workers AI accepts 1–64 questions and returns answers under the same question IDs.
The hosted API accepts up to four embedded PNG, JPEG or WebP images; remote image URLs are not accepted. Check the reference for payload limits.
Clef follows the typed request and answer format. When switching providers, update authentication and the endpoint, and check the provider's response envelope.
export default {
async fetch(request, env) {
const result = await env.AI.run("@cf/cloudflare/clef", {
model: "clef",
state: "My account is locked after too many sign-in attempts.",
questions: {
team: {
type: "choice",
instructions: "Which team should help?",
criteria: {
accounts: "Sign-in and account access",
billing: "Payments and invoices",
technical: "Service errors and outages"
}
},
urgency: {
type: "score",
instructions: "How urgently does this need attention?",
criteria: ["Low", "Medium", "High"]
},
blocked: {
type: "noul",
instructions: "Is account access blocked?"
}
}
});
return Response.json(result);
}
} satisfies ExportedHandler<{ AI: Ai }>;04 / Run it your way
Use Cloudflare's hosted endpoint from a Worker or the REST API. The published Clef price is based on input tokens.
View hosted model documentationThe Hugging Face release includes the backbone and joint schema head. Follow its load_release_model and systemone examples for self-hosting, including local image and video inputs.
Read the model cardCommon questions
Clef returns decisions constrained to your schema. Use those answers to choose the next action; use a text-generating model when your application needs a written reply.
No. Workers AI lists a 65,536-token context window and documents embedded image inputs. The local model card also describes video inputs, and encode_record defaults to 16,384 tokens. Follow the documentation for the deployment you use.
The weights are published under Apache-2.0. Review the included license and notices for self-hosting, and Cloudflare's service terms for hosted use.
Choose thresholds using labelled examples from your workflow. Measure incorrect actions and missed cases, and route uncertain decisions to a fallback or a reviewer.