Clef Demo

API Doc

Clef Omni API

POST /v1/clef-omni/run/

Hosted multimodal decision API for clef-omni. Send a state + typed questions; get probabilities for every option. Upstream Cloudflare tokens never leave our servers — you use a sk_live_ key.

Usage

ts
const res = await fetch("https://clefdemo.com/v1/clef-omni/run/", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.CLEF_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "clef-omni",
    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, invoices, and refunds",
          technical: "Outages, errors, and configuration",
          sales: "Plans and upgrades",
        },
      },
      severity: {
        type: "score",
        instructions: "How severe is the customer impact?",
        criteria: ["No impact", "Minor", "Major", "Critical"],
      },
    },
  }),
});

const data = await res.json();
// data.answers.urgent / team / severity
console.log(data);

Parameters

  • modelstringrequireddefault: "clef-omni"

    Model selector: "clef-omni" (default), also accepts "clef" and "clef-flash". Maps to Workers AI @cf/cloudflare/* on our servers.

  • statestring | object | arrayrequired

    Content to evaluate: plain text or structured JSON (records, chat logs, app state). Long text may be truncated to fit context.

  • questions {}objectrequiredminProperties: 1, maxProperties: 64

    Map of question id → typed question (noul | choice | score). Ids: letters, digits, _, ., - (max 100). Answers are returned under the same ids.

  • images []arraymaxItems: 4

    Optional embedded PNG/JPEG/WebP data URLs (max 4; ≤4 MiB each). Remote URLs are not accepted. Images bill as input tokens.

  • audio []arraymaxItems: 4

    Clef-Omni: optional embedded audio data URLs (max 4; ≤8 MiB / 300s each). Combined audio+video decoded ≤16 MiB. Remote URLs not accepted.

  • videos []arraymaxItems: 2

    Clef-Omni: optional embedded video data URLs (max 2; ≤16 MiB / 60s each). Remote URLs not accepted.

Authentication

Header: Authorization: Bearer sk_live_…
Create keys in Account. Keys are stored hashed; the plaintext is shown once. Revoked / disabled accounts get 401.

Errors

  • 401 unauthorized
  • 402 paywall — buy credits on Pricing
  • 415 bad Content-Type (must be application/json)
  • 429 rate_limit / daily_cap
  • 400 validation
  • 413 payload too large
  • 502 / 504 upstream / timeout — not charged

Security & anti-abuse

  • No anonymous access to /v1 — Bearer key required on every call.
  • Per-IP and per-key rate limits (≈40 req/min) plus a daily call cap per key.
  • API keys hashed at rest; Cloudflare tokens are never exposed to browsers.
  • Body size cap (~12 MiB); media must be embedded data URLs (no remote URL fetch).
  • Failed upstream inference does not deduct credits.
  • Cache hits are free and do not re-run the model.

Billing

  • 1 credit ≈ 1 input token (media is tokenized as input). Output probabilities are not billed.
  • Retail packs: $5 Developer ≈ 2.08M credits · $20 Production ≈ 8.33M credits · $100 Scale ≈ 41.67M credits. Pack sizes are prepaid credit estimates (≈ input tokens), not a guaranteed number of API requests. See Pricing.
  • Identical cached playground/API hits are free (cost_credits = 0). Failed upstream inference (502 / 504) is not charged.
Clef Omni API – Authentication, Parameters & Errors · Clef Demo