Decision Models, Extraction Models and Agent Routing
When to use Clef decision models versus Clairic extraction on Workers AI, how typed questions and fields work, and how routing fits agent workflows.
This page summarises Cloudflare Workers AI documentation on decision models (the Clef family), extraction models (Clairic), and how they differ from generative text and JSON-mode outputs. The goal is the same problem many agent builders hit: get structured, actionable results without parsing free-form LLM text on a latency-sensitive path.
Decision models versus extraction models: which API when?
Section titled “Decision models versus extraction models: which API when?”A decision model picks from options you define up front. An extraction model returns typed values you could not list beforehand (totals, dates, estimates). A generative model produces open-ended content.
Extraction models compares the three with invoice examples:
| Model type | Use when you need | Invoice example |
|---|---|---|
| Extraction | Extract, compute, estimate, or forecast values | Read the total and due date from an invoice |
| Decision | Select from a predefined set of options | Determine if an invoice requires approval, manual review, or rejection |
| Generative | Produce open-ended content | Summarise discrepancies between invoice, PO, and receipt |
Decision models such as Clef choose among options you define up front. Many structured-output tasks do not have answers you can list in advance: an invoice total, a delivery date, the number of days a shipment is late, or what a repair will cost. Clairic handles these.
— Cloudflare, Introducing Clairic
Common conclusion: Route tickets, guard tools, and classify intent with decision APIs; pull numbers, dates, and forecasts into application logic with extraction; reserve generation (or JSON mode on chat models) for prose, summaries, and schemas that do not map to System One questions or fields.
Clef decision models: structured probabilities without token generation
Section titled “Clef decision models: structured probabilities without token generation”Clef models answer typed questions about a state. They score allowed answers in one pass instead of generating text.
Instead of generating text, it reads an input state and a set of typed questions, then returns a probability for every allowed answer. Your agent gets a structured decision it can act on immediately, for example: route the ticket, block the request, or escalate to a human. There is no free-form output to parse and no reasoning tokens to wait for.
— Cloudflare, Introducing Clef
Clef follows the System One API (same shape as Typesafe Jev): call via env.AI.run() or REST /ai/run, optionally through AI Gateway. Up to 64 questions per request.
Question types: noul, choice, and score
Section titled “Question types: noul, choice, and score”| Type | Plain-language use | Returns |
|---|---|---|
noul |
Yes/no or “should we…?” guardrails | Probability the answer is yes (0–1) |
choice |
Route to team, category, or workflow branch | Highest-probability option, per-option probabilities, confidence |
score |
Severity, risk, or policy rubric | Probability-weighted level index, per-level probabilities, confidence |
Definitions match Clef model reference and the Clef launch post.
Which Clef variant: latency, context, and modality
Section titled “Which Clef variant: latency, context, and modality”| Model ID | Best for | Hosted context (docs) | Pricing (per M input tokens) |
|---|---|---|---|
@cf/cloudflare/clef-flash |
Hot-path, latency-critical decisions | 24K tokens on Workers AI | $0.038 |
@cf/cloudflare/clef |
Highest-precision decisions | 64K tokens | $0.24 |
@cf/cloudflare/clef-omni |
Text, images, audio, and video in one request | 64K tokens | $0.15 |
Clef is designed to be fast so decisions come back in milliseconds. Across our 43 benchmark runs, we achieved speeds where Clef is 2.5x faster than Jev at the median, and Clef-flash 13x faster.
— Cloudflare, Introducing Clef
Hosted Clef-flash context was reduced to 24K to match the lower price; self-hosted weights on Hugging Face can still use up to 256K. Clef models bill input tokens only for media; images (and for Clef-omni, audio and video) are converted to tokens—see each model page.
Clef-omni: one request for photo, audio, and video
Section titled “Clef-omni: one request for photo, audio, and video”Previously, video decisions often meant transcribing and chaining models. Clef-omni reads modalities together; a video’s soundtrack aligns with frames.
Clef-omni reads every modality directly in one request. A video’s soundtrack is aligned with its frames, so the model can reason over what is seen and heard at the same time.
— Cloudflare, Clef-omni announcement
Pass base64 data URLs in images, audio (WAV or MP3), and videos (MP4 or WebM). Documented latencies include roughly 20 ms for text, under 100 ms for image or audio, and about 300 ms for a 21-second video with sound (same post). Remote media URLs are not accepted (Clef-omni parameters).
What to build with decision models on the hot path
Section titled “What to build with decision models on the hot path”Typical patterns from Introducing Clef:
- Support triage — urgency + owning team, then route without a human.
- Agent guardrails — “Should I take this action?” in tens of milliseconds before a tool call.
- Trust and safety — score submissions against your rubric using
scorequestions. - Threat intelligence — classify rendered page content (Clef supports up to four images).
You can put Clef directly in the request path of your agent, then hand off to an LLM on Workers AI to take action.
— Cloudflare, Introducing Clef
Clairic extraction models: typed fields instead of questions
Section titled “Clairic extraction models: typed fields instead of questions”Clairic (@cf/cloudflare/clairic, preview) is a System One extraction model: it returns values, not chat text.
Clairic does not generate tokens. It reads your input in one pass and decodes each answer under the rules of its type, so every answer is a valid value of the type you asked for, or null when the input does not determine it.
— Cloudflare, Introducing Clairic
Send a string state (and optionally up to four embedded images) plus a fields map. Scalar answers include p_null and confidence; estimates and forecasts add median and an 80% interval (p10–p90). Details: Clairic model reference.
Field types supported today
Section titled “Field types supported today”type |
Returns |
|---|---|
text |
Exact span in state with character offsets |
number |
Number read or computed; decimals, unit |
date, time, datetime |
ISO calendar values |
duration |
Length in chosen unit |
list |
All matches in input order |
estimate |
Distribution within min/max/step |
forecast |
One estimate per future step (up to 64 steps) |
Many fields may be split across parallel passes when they do not fit one 8,192-token pass with the state—there is no fixed upper limit on field count (changelog, parameters).
Preview limits: when Clairic is not enough alone
Section titled “Preview limits: when Clairic is not enough alone”Arithmetic: One- and two-step calculations, such as totals, differences, conversions, and date arithmetic, are reliable. Long chains of dependent steps and aggregations across many table rows are not yet. Extract the inputs with Clairic and do the math in code.
— Cloudflare, Introducing Clairic
Same source notes wide estimate intervals without evidence, basic forecasting (no holiday awareness), and that well-formed output is not necessarily correct—use confidence, p_null, and intervals to choose automation vs human review. For date fields that depend on “today”, set reference_date or add an explicit line to state.
Extraction models adds general guidance: constraints bound the answer type, not correctness; consequential actions need extra checks.
Agent routing: classify then branch (generative pattern)
Section titled “Agent routing: classify then branch (generative pattern)”For workflows that still use a text-generating model, Agentic patterns – Routing describes classifying input and sending it to specialised follow-up tasks—“separation of concerns.”
That pattern fits decision models when classification is a fixed enum (for example general / refund / technical): Clef choice plus noul for complexity can replace fragile “reply with JSON only” prompts. Use Clef-flash on the edge of the request path, then a larger model only for the branch that needs long-form replies.
Alternatives on Workers AI and elsewhere
Section titled “Alternatives on Workers AI and elsewhere”Typesafe Jev and Cloudflare Clef
Section titled “Typesafe Jev and Cloudflare Clef”Jev uses the same noul / choice / score question map. Clef is positioned as faster and often higher on published decision benchmarks (Introducing Clef). Jev 1.14 adds beta image and box questions—different from Clef-omni’s native audio/video path.
OpenAI openai/decisions on Workers AI
Section titled “OpenAI openai/decisions on Workers AI”Decisions exposes predicate, choice, and score style questions with probabilities—conceptually parallel to System One, with a different request shape (input + named questions array).
JSON mode on chat models
Section titled “JSON mode on chat models”For generative models, Workers AI JSON mode supports response_format with json_schema, compatible with the OpenAI SDK structured outputs pattern. That still produces parsed JSON from token generation; it is not the same as Clef’s single-pass scoring or Clairic’s typed decoders.
This makes it much easier to retrieve structured data from your AI models, and avoids the (error prone!) need to parse large unstructured text responses to extract your data.
— Cloudflare, Workers AI structured JSON outputs
Use JSON mode when the task is arbitrary schema-shaped blobs; use Clef when answers are categorical or rubric-scored; use Clairic when the application needs numbers, dates, or forecasts with uncertainty metadata.
Perplexity Decisions API (conceptual overlap)
Section titled “Perplexity Decisions API (conceptual overlap)”Perplexity’s Decisions quickstart documents the same three question families (noul, choice, score) with probabilities and confidence on choice/score. The ideas transfer when designing Clef questions; wire format differs from Workers AI.
Common mistakes
Section titled “Common mistakes”- Using Clef for open-ended totals when the answer is not in your option list—use Clairic
number/estimateor extract then compute in code. - Using Clairic for “billing vs technical” routing—use Clef
choice(or Jev) instead; extraction models states this split explicitly. - Treating high
confidenceas ground truth—both families document uncertainty signals; automate only above thresholds you validate. - Exceeding Clef-flash 24K hosted context—switch to
@cf/cloudflare/clefor self-host Clef-flash for 256K (Clef-omni changelog). - Sending remote image URLs to Clef or Clairic—embedded data URLs only (Clef parameters).
- Long dependent arithmetic in Clairic preview—extract operands, run aggregations in application code (Clairic preview notes).
How to check this on your site
Section titled “How to check this on your site”-
Confirm the model you need is listed on Workers AI models (
clef,clef-flash,clef-omni, orclairic). -
Reproduce a minimal call using the examples on @cf/cloudflare/clef or @cf/cloudflare/clairic via
env.AI.run()or the documentedcurlto/ai/run. -
For routing, verify
choiceprobabilities andconfidenceon several real tickets match your thresholds before turning off human triage. -
For extraction, check
p_null, spans ontextfields, and estimate intervals against known invoices or logs. -
You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”If something on this page does not match the linked Cloudflare documentation, email yimasynthetic@gmail.com with the page URL and the exact sentence you believe is wrong.