Integrations / Cloudflare

Using Jev via Cloudflare Workers AI.

Cloudflare Workers AI supports TypeSafe Jev under model identifier typesafe/jev.

Developers can execute Jev directly inside Cloudflare Workers using the native env.AI.run() binding or from external services using Cloudflare's REST API.

Model Identifier & Execution Model

Cloudflare cataloged TypeSafe Jev for developers looking for non-generative, structured decision execution:

Model Identifier: typesafe/jev on Cloudflare Workers AI.
Execution Environment: Workers AI can be invoked through the native Worker binding without manually managing an external HTTP API call.
Authentication: When called via env.AI.run inside a Worker, authentication is handled implicitly by the Cloudflare Workers AI binding. External REST calls use a standard Cloudflare API token.

Workers AI Binding (env.AI.run)

To use Jev in a Cloudflare Worker, configure the AI binding in your wrangler.jsonc or wrangler.toml:

wrangler.jsonc snippet
{
  "ai": {
    "binding": "AI"
  }
}

Then invoke typesafe/jev directly in your Worker handler:

TypeScript (Cloudflare Worker env.AI.run)
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request: Request, env: Env): Promise<Response> {
    const inputState = "Support ticket: User cannot reset 2FA because SMS is not arriving on phone +14155552671. Carrier: Verizon.";

    // Invoke Jev using Cloudflare Workers AI binding
    const response = await env.AI.run("typesafe/jev", {
      state: inputState,
      questions: {
        is_urgent: {
          type: "noul",
          instructions: "Does this convey urgency?",
          criteria: {
            true: "Explicitly time-sensitive",
            false: "No urgency expressed"
          }
        },
        department: {
          type: "choice",
          instructions: "Which team should handle this?",
          criteria: {
            billing: "Payments, invoicing, refunds",
            technical: "Bugs, outages, integrations"
          }
        },
        frustration: {
          type: "score",
          instructions: "How frustrated is the customer?",
          criteria: [
            "Calm",
            "Frustrated",
            "Very angry"
          ]
        }
      }
    });

    return Response.json(response);
  }
};

Cloudflare REST API Usage

If calling Cloudflare from external services or microservices, use the Cloudflare Workers AI REST endpoint with an account token:

cURL (Cloudflare Workers AI REST Endpoint)
curl -X POST "https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run" \
  -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "typesafe/jev",
    "input": {
      "state": "Transaction: Amount $450. Card country: US. Shipping country: US. CVV matched: Yes.",
      "questions": {
        "fraud_level": {
          "type": "choice",
          "instructions": "Evaluate transaction risk tier",
          "criteria": {
            "low": "Standard domestic card transaction with matching verification data",
            "medium": "Unusual velocity or slight mismatch requiring inspection",
            "high": "Known stolen card attributes or confirmed suspicious pattern"
          }
        },
        "require_review": {
          "type": "noul",
          "instructions": "This transaction requires human underwriter review."
        }
      }
    }
  }'

Question Schemas & Response Structure

The payload format for typesafe/jev on Cloudflare follows the TypeSafe System One schema containing a shared state string and a keyed questions object (supporting Choice, Score, and Noul primitives):

Noul: Keyed question with type: "noul", instructions, and optional binary criteria (returns calibrated probability float noul).
Choice: Keyed question with type: "choice", instructions, and an explicit map of label-to-definition criteria (returns winning choice, confidence, and probabilities map).
Score: Keyed question with type: "score", instructions, and an ordered list of rubric level strings in criteria (returns continuous weighted score, confidence, legend, and level probabilities).

The execution response returns model metadata, answers keyed by question identifier, and token usage:

JSON (Cloudflare Workers AI Response Shape)
{
  "model": "typesafe/jev",
  "answers": {
    "is_urgent": {
      "type": "noul",
      "noul": 0.884
    },
    "department": {
      "type": "choice",
      "choice": "billing",
      "confidence": 0.931,
      "probabilities": {
        "billing": 0.931,
        "technical": 0.069
      }
    },
    "frustration": {
      "type": "score",
      "score": 2.15,
      "confidence": 0.88,
      "legend": {
        "0": "Calm",
        "1": "Frustrated",
        "2": "Very angry"
      },
      "probabilities": {
        "0": 0.05,
        "1": 0.75,
        "2": 0.20
      }
    }
  },
  "usage": {
    "input_tokens": 142,
    "output_tokens": 0
  }
}

Context Window Limits

Cloudflare Workers AI documents a 32,000-token context window for typesafe/jev.

Context envelope note: Make sure the total length of your shared state string plus all accompanying question prompts and rubric descriptions stays within the 32,000-token limit when submitting requests to Cloudflare Workers AI.

Pricing & Billing Exposure

Cloudflare Workers AI bills inference execution through your Cloudflare account under standard Workers AI usage metrics (Neural Compute Units / Neurons) or published model rates. Check your Cloudflare dashboard under Workers & Pages > AI > Usage for current account allocations and neuron consumption.

Not affiliated with, endorsed by, or operated by TypeSafe AI. Vendor claims are cited and attributed.