Try it
Copy the code ↓- Data source
- Decision schema
- Model inference
- Structured result
2 Decision schema 3 typed questions
next_actionchoicegenerateretrieve_morediscardreviewrelevancescorelowmediumhighevidence_enoughnoulprobability 0–1
3 Model inference typesafe/jev-1.13
Waiting for a run.
4 Structured result
Raw JSON
Run the demo to see the JSON answers, the highlighted pick and the final action.
FLATKEY_API_KEY and run.curl -sS https://router.flatkey.ai/api/alpha/decisions \
-H "Authorization: Bearer $FLATKEY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "typesafe/jev-1.13",
"state": "Question: What is our refund window for annual Business plans purchased in the EU?\n\nRetrieved chunk (#3, score 0.71):\n\"Our Help Center notes that monthly Starter plans can cancel anytime. Shipping SLAs for hardware accessories are 5–7 business days in North America. A 2023 blog post mentions a winter promo that extended trials to 30 days.\"\n\nAlready kept: none.\nTask: next_action (generate / retrieve_more / discard / review), relevance, evidence_enough.",
"questions": {
"next_action": {
"type": "choice",
"instructions": "Given the user question and this retrieved chunk (plus any already-kept evidence), what should the RAG pipeline do next? Prefer the cheapest safe path.",
"criteria": {
"generate": "The kept evidence is on-topic and sufficient to answer without guessing; proceed to the generator",
"retrieve_more": "The chunk is partly useful but evidence is still thin, incomplete, or missing a key fact—fetch more before answering",
"discard": "This chunk is off-topic, outdated, or contradictory noise; drop it and do not put it in context",
"review": "Relevance or conflict is ambiguous enough that a human or stronger judge should decide before generation"
}
},
"relevance": {
"type": "score",
"instructions": "How relevant is this retrieved chunk to answering the user question, ignoring how well-written it is.",
"criteria": [
"low",
"medium",
"high"
]
},
"evidence_enough": {
"type": "noul",
"instructions": "Together with already-kept evidence, there is enough specific support to answer the question without inventing missing facts."
}
}
}'// Node.js 18+ (built-in fetch). Run: FLATKEY_API_KEY=... node jev.mjs
const body = {
"model": "typesafe/jev-1.13",
"state": "Question: What is our refund window for annual Business plans purchased in the EU?\n\nRetrieved chunk (#3, score 0.71):\n\"Our Help Center notes that monthly Starter plans can cancel anytime. Shipping SLAs for hardware accessories are 5–7 business days in North America. A 2023 blog post mentions a winter promo that extended trials to 30 days.\"\n\nAlready kept: none.\nTask: next_action (generate / retrieve_more / discard / review), relevance, evidence_enough.",
"questions": {
"next_action": {
"type": "choice",
"instructions": "Given the user question and this retrieved chunk (plus any already-kept evidence), what should the RAG pipeline do next? Prefer the cheapest safe path.",
"criteria": {
"generate": "The kept evidence is on-topic and sufficient to answer without guessing; proceed to the generator",
"retrieve_more": "The chunk is partly useful but evidence is still thin, incomplete, or missing a key fact—fetch more before answering",
"discard": "This chunk is off-topic, outdated, or contradictory noise; drop it and do not put it in context",
"review": "Relevance or conflict is ambiguous enough that a human or stronger judge should decide before generation"
}
},
"relevance": {
"type": "score",
"instructions": "How relevant is this retrieved chunk to answering the user question, ignoring how well-written it is.",
"criteria": [
"low",
"medium",
"high"
]
},
"evidence_enough": {
"type": "noul",
"instructions": "Together with already-kept evidence, there is enough specific support to answer the question without inventing missing facts."
}
}
};
const res = await fetch("https://router.flatkey.ai/api/alpha/decisions", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.FLATKEY_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify(body),
});
if (!res.ok) throw new Error(`Jev request failed: ${res.status} ${await res.text()}`);
const { answers, usage } = await res.json();
console.log(JSON.stringify(answers, null, 2), usage);# Python 3.8+ (pip install requests). Run: FLATKEY_API_KEY=... python jev.py
import json, os, requests
body = json.loads(r"""{
"model": "typesafe/jev-1.13",
"state": "Question: What is our refund window for annual Business plans purchased in the EU?\n\nRetrieved chunk (#3, score 0.71):\n\"Our Help Center notes that monthly Starter plans can cancel anytime. Shipping SLAs for hardware accessories are 5–7 business days in North America. A 2023 blog post mentions a winter promo that extended trials to 30 days.\"\n\nAlready kept: none.\nTask: next_action (generate / retrieve_more / discard / review), relevance, evidence_enough.",
"questions": {
"next_action": {
"type": "choice",
"instructions": "Given the user question and this retrieved chunk (plus any already-kept evidence), what should the RAG pipeline do next? Prefer the cheapest safe path.",
"criteria": {
"generate": "The kept evidence is on-topic and sufficient to answer without guessing; proceed to the generator",
"retrieve_more": "The chunk is partly useful but evidence is still thin, incomplete, or missing a key fact—fetch more before answering",
"discard": "This chunk is off-topic, outdated, or contradictory noise; drop it and do not put it in context",
"review": "Relevance or conflict is ambiguous enough that a human or stronger judge should decide before generation"
}
},
"relevance": {
"type": "score",
"instructions": "How relevant is this retrieved chunk to answering the user question, ignoring how well-written it is.",
"criteria": [
"low",
"medium",
"high"
]
},
"evidence_enough": {
"type": "noul",
"instructions": "Together with already-kept evidence, there is enough specific support to answer the question without inventing missing facts."
}
}
}""")
res = requests.post(
"https://router.flatkey.ai/api/alpha/decisions",
headers={"Authorization": f"Bearer {os.environ['FLATKEY_API_KEY']}"},
json=body,
timeout=60,
)
res.raise_for_status()
data = res.json()
print(json.dumps(data["answers"], indent=2), data.get("usage"))
No Flatkey key yet? Get one for Jev 1.13 →
About this use case

Who / when
Audience
- RAG builders who want a cheap relevance and sufficiency gate between retrieval and generation
- search and support teams tired of answers that cite off-topic chunks
- evals engineers calibrating retrieve-more loops without another full chat model call
Triggers
- the generator invents answers from weakly related or conflicting chunks
- you need a typed keep / drop / retrieve-more decision per chunk at high QPS
- keyword or embedding scores alone still pass noisy neighbors into context
- you want calibrated thresholds before paying for a long generation call
The workflow
- 01Query + chunkUser question and one retrieved passageInput
- 02Next actiongenerate / retrieve_more / discard / reviewJev
- 03Relevance + enough?Score relevance, Noul sufficiencyJev
- 04Code gateKeep, fetch more, or block generateYour code
Question shape
{
"next_action": {
"type": "choice",
"instructions": "Given the user question and this retrieved chunk (plus any already-kept evidence), what should the RAG pipeline do next? Prefer the cheapest safe path.",
"criteria": {
"generate": "The kept evidence is on-topic and sufficient to answer without guessing; proceed to the generator",
"retrieve_more": "The chunk is partly useful but evidence is still thin, incomplete, or missing a key fact—fetch more before answering",
"discard": "This chunk is off-topic, outdated, or contradictory noise; drop it and do not put it in context",
"review": "Relevance or conflict is ambiguous enough that a human or stronger judge should decide before generation"
}
},
"relevance": {
"type": "score",
"instructions": "How relevant is this retrieved chunk to answering the user question, ignoring how well-written it is.",
"criteria": [
"low",
"medium",
"high"
]
},
"evidence_enough": {
"type": "noul",
"instructions": "Together with already-kept evidence, there is enough specific support to answer the question without inventing missing facts."
}
}Gate policy
≥ 0.90
Honor next_action: generate only when relevance is high and evidence_enough is true; otherwise retrieve_more or discard as chosen.
0.65–0.90
Prefer retrieve_more over generate; keep the chunk only if relevance is at least medium and log probabilities.
< 0.65
Discard or route to review; do not call the generator on low-confidence evidence.
Failure modes
Pre-launch checks before you trust auto-routing:
- Passing every top-k chunk to the generator because the embedding score looked high;
- Generating an answer when evidence_enough is false and inventing the missing policy detail;
- Discarding a partially useful chunk without retrieving a better one, then answering from nothing;
- Treating a conflicting or outdated passage as high relevance because it shares keywords;
- Skipping the gate on "simple" questions and only discovering bad citations in production;
FAQ
How is this different from a grounding / hallucination judge?
RAG gates run after retrieval and before generation: they decide whether to keep a chunk, fetch more, or block the generate call. A grounding judge runs on a claim (or draft answer) against sources after the fact. Many stacks want both. See Grounding / hallucination judge.
Why not rely on embedding similarity alone?
Similarity ranks neighbors; it does not know whether the passage actually answers the question or whether the set is sufficient. Jev asks those atomic questions in plain English and returns calibrated probabilities you can threshold.
What does the Flatkey call look like?
POST https://router.flatkey.ai/api/alpha/decisions with Authorization: Bearer …, Content-Type: application/json, and a body of state, model (typesafe/jev-1.13), and questions (choice / score / noul). This is not an OpenAI-compatible /v1 chat endpoint.
Can I bring my own API key?
Yes. Try the free demo above without signing in. To run it live on your own text, sign in with Google and connect a Flatkey or OpenRouter key (a quick test call runs when you save it). Manage or delete it anytime under Dashboard → BYOK. Keys are stored encrypted on the server, used only for runs you trigger, and never sent back to the browser. Need a Flatkey key? Get one for Jev 1.13 on Flatkey.
Is this the official TypeSafe Jev product page?
No. jev-llm.com is an independent research and practice site. Verify pricing, models and terms at the original TypeSafe sources.
Sources
JEV HAS 6 PRODUCTION PATTERNS… 01 SEMANTIC SQL… 02 TOOL ROUTING… 03 RAG GATES… 04 ENTITY RESOLUTION… 05 TEXT TO FEATURES… 06 CASCADE SAFETY… retrieve narrowly → ask atomic questions → batch… calibrate thresholds… escalate uncertainty… Jev should not count, compare dates, perform arithmetic or authorize irreversible actions by itself.
— @fluixoo View the post on X →
Wire this gate with your own key
Bring your own key through Flatkey / OpenRouter. Keep exact checks in code.