Most applications that adopt an AI model do not need another chatbot. They need a decision: which queue this ticket belongs to, whether the command an agent wants to run is dangerous, which model this request should be routed to. Today those decisions are made by prompting a chat model and parsing its prose — and you pay text-generation latency and cost for every one of them.
TypeSafe's Jev takes a different route. It does not generate text. It answers questions and returns probabilities. We have wired it into CodeGateway behind POST /v1/systemone.
Why a separate endpoint
Jev takes { state, questions } and returns { model, answers, usage } — no choices[], no streamable prose. That is not the shape of a chat completion, and forcing it through /v1/chat/completions fails at the upstream: when we sent messages, Cloudflare answered Unsupported fields passed: messages, stream. Valid fields: state.
Rather than build a compatibility layer that fakes a chat interface, CodeGateway adds a dedicated branch: POST /v1/systemone, passing Jev's native request and response shapes through unchanged. In GET /v1/models the row carries an api: "systemone" marker, so clients route on that field instead of guessing from capability flags.
What a call looks like
curl https://api.codegateway.dev/v1/systemone \
-H "Authorization: Bearer $CODEGATEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"state": "Our API integration started returning 500s 20 minutes ago and order processing is fully blocked.",
"questions": {
"urgent": {
"type": "noul",
"instructions": "Does this convey urgency or time-sensitivity?"
},
"department": {
"type": "choice",
"instructions": "Which queue should handle this request?",
"criteria": {
"billing": "Charges, invoices, refunds",
"technical": "Bugs, outages, integrations",
"sales": "Pricing, upgrades, new accounts"
}
},
"complexity": {
"type": "score",
"instructions": "How much reasoning does this request demand?",
"criteria": ["Trivial: a single fact", "Moderate: a few steps, one domain", "Hard: many interacting constraints"]
}
}
}'The response is typed answers with probabilities, not prose that needs to be parsed back (the codegateway block is the gateway's own accounting; every other field passes through untouched):
{
"model": "jev-1.13.0",
"answers": {
"urgent": { "type": "noul", "noul": 0.99 },
"department": {
"type": "choice",
"choice": "technical",
"confidence": 0.92,
"probabilities": { "billing": 0.03, "technical": 0.92, "sales": 0.05 }
},
"complexity": { "type": "score", "score": 1.07, "confidence": 0.88 }
},
"usage": { "input_tokens": 527, "output_tokens": 74 }
}Three question types cover most "smart if-statements": noul answers yes/no with the probability that the answer is yes, choice picks one option from a fixed set and returns the whole distribution, and score places the input on an ordered scale. You can ask several questions in one request, and the questions are evaluated in parallel — adding more barely moves latency, it only costs a few more input tokens.
What we measured
Four calls made straight from our development machine to Cloudflare — routing an urgent outage, routing a calm lookup, judging whether rm -rf is destructive, and judging whether git status is safe:
End-to-end latency of 420–1125 ms. TypeSafe currently serves from the US West Coast, and the network round trip from Asia eats most of its advertised 70–500 ms, so treat this as the cross-region reality rather than the datacenter number.
Roughly $0.00002 per call: input is billed at $0.042 per million tokens ($42 per billion), output is free.
The behaviour held up: the outage scored
urgent0.99 and routed tofrontier; the lookup scored 0.05 and routed tocheap;rm -rfscored 0.87 destructive with aconfirm/blockrecommendation;git statusscored 0.01 and was allowed.
What it cannot do
Two traps are worth stating plainly.
First, type safety is not factual correctness. Jev will never emit a value outside the schema you defined, but it can still emit a well-formed, wrong answer. What rescues you is the probability: an answer below your threshold should go to human review or to a stronger model instead of being executed. Our own run shows the signal — for rm -rf the action distribution came back block 0.5 / confirm 0.5 with a confidence of 0.25, meaning the model was torn between refusing outright and asking first. That is the kind of answer a harness should turn into a confirmation step rather than act on.
Second, it is not a replacement for a language model. Jev accepts text only (state may be a string, a JSON object, or an array), the state plus your longest question has to fit a 32k-token budget (64k for the whole request), there is no image, audio or video input, and it generates no prose at all. Accuracy is best in English; other languages work but should be validated on your own data before you depend on them.
How CodeGateway serves it
Channel:
typesafe/jevfrom the Cloudflare model catalog, called through the REST/accounts/{id}/ai/runendpoint under Unified Billing. CodeGateway holds no TypeSafe provider key — this channel is provider-keyless like every other upstream in the gateway.Billing: input tokens only, output free. The rate is seeded in D1
model_costs(migration 0159) and mirrored in the hardcoded fallback table, with a parity gate keeping the two in lockstep.Metering: pre-deduct, call, settle — the same pipeline the image and video routes use, so each call lands in
request_logswith its tokens, cost and latency.Response: Jev's native
model/answers/usagefields come back untouched, wrapped in acodegatewayblock (cost_usd_micro/markup/latency_ms) so callers never have to do the accounting themselves.
When to reach for it
If your system already has a pile of "ask a model for JSON, then parse it" decision points — classification, routing, scoring, guardrails — a model like Jev is worth testing in isolation. It turns those decisions from prose generation plus parsing into a single typed inference, at an order of magnitude less latency and cost. If your task needs generation, multi-step reasoning, or images, it will not help; keep that on a chat model.