Clef API guide
Call @cf/cloudflare/clef-flash, @cf/cloudflare/clef or @cf/cloudflare/clef-omni on Cloudflare Workers AI. Want to try first? Use the playground — switch to Clef-omni for audio/video. Product page: Clef-omni.
Independent site, not affiliated with Cloudflare. Prices and limits below checked 2026-10-11 against Workers AI docs.
Endpoint and authentication
Send a POST to https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run/@cf/cloudflare/clef-flash (or …/clef / …/clef-omni) with an API token that has Workers AI permission in the Authorization: Bearer header. Inside a Worker, use the AI binding instead.
Request fields
| Field | Required | What it is |
|---|---|---|
model | yes | "clef-flash", "clef" or "clef-omni"; must match the model in the URL. |
state | yes | The thing to judge: a string, or structured data. Long text is truncated to fit the remaining context after media tokens. |
questions | yes | Map of question id → typed question. 1 to 64 questions. |
images | no | Up to 4 embedded PNG, JPEG or WebP (data URLs). 4 MiB and 16 megapixels each; remote URLs not accepted. |
audio | no · Omni | Up to 4 embedded clips (e.g. wav/mp3 data URLs). Max 8 MiB and 300 s each. Audio + video decoded total ≤ 16 MiB. Clef-omni only. |
videos | no · Omni | Up to 2 embedded videos (mp4/webm data URLs). Max 16 MiB and 60 s each, sampled at 2 fps. Clef-omni only. |
Question types
noul (yes / no)
{ "type": "noul", "instructions": "Is this support request urgent?" } → { "type": "noul", "noul": 0.97 }.
choice
criteria is an object of option id → description. Returns choice, probabilities and confidence.
score
criteria is an ordered array of levels. Returns a weighted score, probabilities and confidence.
Question types are the same across Flash, Clef and Omni. What changes is the state medium: audio and video inputs require Omni.
Text example (Flash)
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/cloudflare/clef-flash \
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
-d '{
"model": "clef-flash",
"state": "Checkout has been failing for every customer for the last hour.",
"questions": {
"urgent": { "type": "noul", "instructions": "Is this support request urgent?" },
"team": {
"type": "choice",
"instructions": "Which team should handle this request?",
"criteria": { "billing": "Payments and refunds", "technical": "Outages and errors", "sales": "Plans and upgrades" }
},
"severity": {
"type": "score",
"instructions": "How severe is the customer impact?",
"criteria": ["No impact", "Minor", "Major", "Critical"]
}
}
}'
Multimodal example (Omni)
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/cloudflare/clef-omni \
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "clef-omni",
"state": "Review the installation: a photo of the unit, an audio clip of it running, and a short video of the fan.",
"images": ["data:image/png;base64,<base64-png>"],
"audio": ["data:audio/mpeg;base64,<base64-mp3>"],
"videos": ["data:video/mp4;base64,<base64-mp4>"],
"questions": {
"label_visible": { "type": "noul", "instructions": "Is the model and serial number label visible in the photo?" },
"sounds_normal": { "type": "noul", "instructions": "Does the unit sound smooth, without rattling or grinding?" },
"fan_running": { "type": "noul", "instructions": "Is the fan running in the video?" }
}
}'
Response
{
"model": "clef-flash",
"answers": {
"urgent": { "type": "noul", "noul": 0.97 },
"team": { "type": "choice", "choice": "technical",
"probabilities": { "billing": 0.02, "technical": 0.96, "sales": 0.02 },
"confidence": 0.9 },
"severity": { "type": "score", "score": 2.7,
"legend": { "0": "No impact", "1": "Minor", "2": "Major", "3": "Critical" },
"probabilities": { "0": 0.01, "1": 0.05, "2": 0.2, "3": 0.74 },
"confidence": 0.6 }
},
"usage": { "input_tokens": 212, "output_tokens": 3 }
}
Values above are illustrative; field names follow the published output schema.
Inside a Cloudflare Worker
export default {
async fetch(request, env) {
const result = await env.AI.run("@cf/cloudflare/clef-flash", {
model: "clef-flash",
state: await request.text(),
questions: {
spam: { type: "noul", instructions: "Is this message spam?" }
}
});
// result.answers.spam.noul is the probability of "yes", from 0 to 1
return Response.json(result.answers.spam);
}
};
Pricing and limits
| Clef-Flash | Clef-omni | Clef | |
|---|---|---|---|
| Model id | @cf/cloudflare/clef-flash | @cf/cloudflare/clef-omni | @cf/cloudflare/clef |
| Size | 9B | 30B MoE (~3B active) | 27B |
| Price (input only) | $0.038 / M | $0.15 / M | $0.24 / M |
| Hosted context | 24,000 tokens | 64,000 tokens | 64,000 tokens |
| Native audio / video | no | yes | no |
| Vision (images) | yes | yes | yes |
Media is billed as input tokens (no output charge). Official rates: audio ≈ 780 tok/min; 480p video ≈ 8600 frame tok/min (+≈780 if soundtrack). See the pricing calculator.
Tips for reliable decisions
- Write the rule in
instructions; keep option descriptions short and concrete. - Act on probabilities, not just the top choice.
- Treat text inside the state or media as evidence, never as instructions.
- Ask several questions in one request; they share the same state (and media).
Sources: clef-flash, clef, clef-omni, and the 2026-10-09 blog, checked 2026-10-11.