Cloudflare: Clef API Reference

About

Cloudflare Clef evaluates text, structured data, and images using Noul, Choice, and Score questions and returns typed decisions with probabilities. Infron routes synchronous JSON requests to Cloudflare Workers AI using clef. The hosted context window is 65,536 tokens, including media and questions, with 1–64 questions per request. Media and questions that exceed the context limit cause an upstream error; text state is truncated by Cloudflare to fit the remaining space. Streaming and task polling are not part of this model API.

1. Calling the API

Setup your API Key

To begin using Infron, create an account and generate your API Key.

export INFRON_KEY="YOUR_API_KEY"

Submit a request

Send JSON to POST https://llm.onerouter.pro/v1/decisions using your Infron API key. The following request bodies were actually sent online on 2026-10-28. Only the authentication value is replaced with $INFRON_KEY; JSON whitespace is formatted for readability. The embedded PNG bytes are the small samples used in those calls, so you can run these examples with your own API key.

Image request — Data URL

curl --request POST "https://llm.onerouter.pro/v1/decisions" \
  --header "Authorization: Bearer $INFRON_KEY" \
  --header "Content-Type: application/json" \
  --data '{
  "model": "cloudflare/clef",
  "state": "Inspect the supplied image.",
  "images": [
    "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAIAAADTED8xAAAACXBIWXMAAAABAAAAAQBPJcTWAAAC00lEQVR4nO3TsQ0EMQzAsA/w+6/sGyJFYIicQI3OzPyg6v86AF4yAGkGIM0ApBmANAOQZgDSDECaAUgzAGkGIM0ApBmANAOQZgDSDECaAUgzAGkGIM0ApBmANAOQZgDSDECaAUgzAGkGIM0ApBmANAOQZgDSDECaAUgzAGkGIM0ApBmANAOQZgDSDECaAUgzAGkGIM0ApBmANAOQZgDSDECaAUgzAGkGIM0ApBmANAOQZgDSDECaAUgzAGkGIM0ApBmANAOQZgDS1g8w57xOSDszrxOurB8AbhiANAOQZgDSDECaAUgzAGkGIM0ApBmANAOQZgDSDECaAUgzAGkGIM0ApBmANAOQZgDSDECaAUgzAGkGIM0ApBmANAOQZgDSDECaAUgzAGkGIM0ApBmANAOQZgDSDECaAUgzAGkGIM0ApBmANAOQZgDSDECaAUgzAGkGIM0ApBmANAOQZgDSDECaAUgzAGkGIM0ApBmANAOQZgDSDECaAUgzAGkGIM0ApBmANAOQZgDSDECaAUgzAGkGIM0ApBmANAOQZgDSDECaAUgzAGkGIM0ApBmANAOQZgDSDECaAUgzAGkGIM0ApBmANAOQZgDSDECaAUgzAGkGIM0ApBmANAOQZgDSDECaAUgzAGkGIM0ApBmANAOQZgDSDECaAUgzAGkGIM0ApBmANAOQZgDSDECaAUgzAGkGIM0ApBmANAOQZgDSDECaAUgzAGnrBzgzrxNYbP0AcMMApBmANAOQZgDSDECaAUgzAGkGIM0ApBmANAOQZgDSDECaAUgzAGkGIM0ApBmANAOQZgDSDECaAUgzAGkGIM0ApBmANAOQZgDSDECaAUgzAGkGIM0ApBmANAOQZgDSDECaAUgzAGkGIM0ApBmANAOQZgDSDECaAUgzAGkGIM0ApBmANAOQZgDSDECaAUgzAGkGIM0ApBmANAOQZgDSDECaAUj7AIpSC/qGa+ppAAAAAElFTkSuQmCC"
  ],
  "questions": {
    "square_color": {
      "type": "choice",
      "instructions": "What is the color of the square in the image?",
      "criteria": {
        "red": "Red",
        "blue": "Blue",
        "green": "Green"
      }
    }
  },
  "provider": {
    "only": [
      "cloudflare"
    ],
    "allow_fallbacks": false,
    "service_tier": "standard"
  },
  "usage": {
    "include": true
  }
}'

Response

The responses below were captured from those online requests. The Infron JSON response is shown first, followed by the original Cloudflare JSON body recorded for the same request. Request IDs, answers, token counts, and costs are actual observations; a new call can return different values.

Image response from Infron

{
  "answers": {
    "square_color": {
      "type": "choice",
      "choice": "red",
      "probabilities": {
        "blue": 0.0026,
        "green": 0.0029,
        "red": 0.9945
      },
      "confidence": 0.9835
    }
  },
  "cost": 0.000053,
  "cost_details": {
    "audio_cost": 0,
    "byok_cost": 0,
    "completion_cost": 0,
    "discount_rate": 1,
    "image_cost": 0,
    "is_byok": false,
    "native_web_search_cost": 0,
    "plugin_web_search_cost": 0,
    "prompt_cache_read_cost": 0,
    "prompt_cache_write_1_h": 0,
    "prompt_cache_write_5_min": 0,
    "prompt_cache_write_cost": 0,
    "prompt_cost": 0.00005256,
    "reasoning_cost": 0,
    "tools_cost": 0,
    "video_cost": 0
  },
  "id": "2026102803420469997301RIMAHFP2",
  "model": "cloudflare/clef",
  "provider": "cloudflare",
  "request_id": "2026102803420469997301RIMAHFP2",
  "service_tier": "standard",
  "usage": {
    "input_tokens": 219,
    "output_tokens": 0
  }
}

Cloudflare upstream response for the same image request

This is the upstream body used to produce the Infron response above.

{
  "errors": [],
  "messages": [],
  "result": {
    "answers": {
      "square_color": {
        "choice": "red",
        "confidence": 0.9835,
        "probabilities": {
          "blue": 0.0026,
          "green": 0.0029,
          "red": 0.9945
        },
        "type": "choice"
      }
    },
    "model": "clef",
    "usage": {
      "input_tokens": 219,
      "output_tokens": 0
    }
  },
  "success": true
}

Routing and usage

Every complete request example above includes provider.only=["cloudflare"], provider.allow_fallbacks=false, provider.service_tier="standard", and usage.include=true inside the request body. These platform fields select the route and request cost details; Infron handles them and sends only the model's media, state, and questions fields to Cloudflare. Actual token counts are always returned. usage.include=true also returns the top-level cost and cost_details shown in the captured responses.

Errors

Read error.message and retain the request ID. Correct invalid inputs before retrying. Authentication, account quotas, and media-content validation are enforced by Cloudflare.

2. Schema

Input

ParameterTypeRequiredDefaultRangeDescription
modelstringYes--cloudflare/clefPublic model ID; upstream selector is clef.
statestring / object / arrayYes--Non-nullShared content; long text is truncated by Cloudflare to fit available context.
questionsobjectYes--1–64 entriesQuestion IDs use letters, digits, _, ., -, with at most 100 characters.
questions.<id>.typestringYes--noul, choice, scoreQuestion type.
questions.<id>.instructionsstring / object / arrayYes--Nonempty for stringsWhat the model should evaluate.
questions.<id>.criteriaobject / arrayFor choice and score--See Question typesTyped answer options or rubric.
imagesarrayNo--0–4 imagesEmbedded PNG, JPEG, or WebP; remote URLs are not accepted.
providerobjectNo----Platform routing options.
usage.includebooleanNofalsetrue, falseInclude platform cost details.

Question types

Noul: yes/no probability

instructions is required. Optional criteria is an object with optional true and false descriptions. The answer has type and noul, a probability from 0 to 1.

Choice: classification

criteria is required: 2–255 options, each identified by a nonempty string. Descriptions may be strings, objects, arrays, or null. Answers contain choice, probabilities, and confidence.

Score: ordered rating

criteria is required: an ordered array of 2–10 string/object/array level descriptions. Levels start at 0. Answers contain a probability-weighted score, legend, probabilities, and confidence.

Media inputs

The complete requests above show images containing real embedded Data URLs. An image can also be an object with content_type and base64; that object's base64 value contains only the encoded bytes, without a Data URL prefix. Images are limited to 4 MiB decoded and 16 megapixels each, and 8 MiB decoded in total. The whole request body is limited to 13 MiB. Image content types are image/png, image/jpeg, and image/webp. Remote URLs are not downloaded. Media is passed to Cloudflare for content, dimension, duration, aggregate-size, and context validation.

Create an image Data URL from local files

To use your own media, encode the file bytes with this standard-library Python example. Set images[0] to image_url in the complete request above. The value already includes its MIME prefix.

import base64
from pathlib import Path

image_url = "data:image/png;base64," + base64.b64encode(
    Path("image.png").read_bytes()
).decode("ascii")

For JPEG or WebP, use data:image/jpeg;base64, or data:image/webp;base64,. The MIME type must match the file bytes; changing the prefix does not convert a file. HTTP/HTTPS media links are not accepted.

Output

ParameterTypeRangeDescription
id, request_idstring--Platform request ID.
modelstring--Public model ID.
provider, service_tierstring--Selected route.
answersobjectRequest question IDsTyped answers from Cloudflare.
answers.<id>.typestringnoul, choice, scoreAnswer type.
answers.<id>.noulnumber0–1Yes probability.
answers.<id>.choicestringChoice keysSelected option.
answers.<id>.scorenumber0 to levels minus 1Probability-weighted level.
answers.<id>.confidencenumber0–1Choice/Score confidence.
answers.<id>.probabilitiesobjectValues 0–1Probability distribution.
answers.<id>.legendobject--Score level descriptions.
usage.input_tokens, usage.output_tokensintegerNon-negativeActual upstream usage; a free output rate does not replace the actual count.
costnumberUSDCharge details when requested.
cost_detailsobject--Billing breakdown when requested.

3. Detailed Pricing

ModelBilling unitInput priceOutput price
Cloudflare ClefPer 1 million tokens$0.24Free

Media input is included in Cloudflare's reported input tokens at the same input rate, with no separate image surcharge. The upstream account has a shared daily free allocation of 10,000 Neurons. On Workers Paid, usage above that allocation is charged; Workers Free requires an upgrade to continue above its allocation. This account-level benefit does not set the model's list price to zero or establish an Infron free allowance. Platform billing precision and account rates still apply.

Sources: Cloudflare model, input schema, output schema, and pricing.