Project: Jeveto — 置信度门控的 Agent 决策层 生态三仓:jeveto(编排层)· jevkit(决策客户端 · 本仓)· jev-calib(决策监控)
⚠️ Disclaimer: This is a third-party, unofficial wrapper around OpenRouter's Decisions API — not affiliated with, endorsed by, or maintained by OpenRouter or TypeSafe. The API is in alpha and may change without notice.
The first open-source third-party client for OpenRouter's Decisions API (Jev, by TypeSafe) — a calibrated-probability decision model, not a chat model.
Jev answers typed questions with calibrated probabilities — zero text generation. Three primitives: noul (yes/no calibrated probability), choice (pick one), score (scale rating). 70-500ms latency, output tokens free.
三种问题类型都必须带 criteria,且形状各不相同 —— 这是最容易踩的坑:
| type | criteria 形状 |
返回 |
|---|---|---|
noul |
record {"true": 描述, "false": 描述} |
{"noul": 0.0~1.0} 校准概率 |
score |
array ["锚点0", "锚点1", ...] |
{"score": 期望锚点序号 0..N-1, "legend": {序号: 锚点}, "probabilities": {...}, "confidence": ...} |
choice |
record {选项: 描述}(键即选项,不需要 options) |
{"choice": 选中键, "probabilities": {...}, "confidence": ...} |
⚠️ 两大坑(本仓实测,官方 client 未覆盖):
score返回的score不是 0–1 归一值,是「期望锚点序号」(5 个锚点 → 0..4);用前必须/(N-1)归一化- 少传
criteria直接 HTTP 400,报错 path 指向criteria—— 可据此反推字段
Chat models guess; Jev calibrates. If you need routing, classification, or gating decisions ("is this worth doing?"), a chat model wrapped in JSON is slower, uncalibrated, and costs more. Jev is the ultimate classifier:
- Calibrated probabilities — real confidence, not vibes
- 70-500ms — System-1 speed for gating decisions
- $0.042/M input, output free — 14 questions ≈ $0.00004
- Typed questions — noul / choice / score, with explicit criteria
pip install jevkit # (after publish — for now: copy the jevkit/ directory)
export OPENROUTER_API_KEY=<your key> # from openrouter.aifrom jevkit import Client, gate
client = Client() # reads OPENROUTER_API_KEY
# 一次 decide() 同时问三件事:真伪 + 期望值 + 下一步
r = client.decide({
"is_real": {
"type": "noul",
"instructions": "Is this opportunity a genuine paid opportunity?",
"criteria": {"true": "real payer with verifiable payment record",
"false": "no payment record / roleplay only / asks for secrets"},
},
"ev": {
"type": "score",
"instructions": "Score the expected value.",
"criteria": ["1 - not worth it", "2 - weak", "3 - fair", "4 - strong", "5 - excellent"],
},
"next_step": {
"type": "choice",
"instructions": "What should we do next?",
"criteria": {"submit_now": "we can deliver immediately",
"ask_sponsor": "need clarification first",
"skip": "not worth it"},
},
}, state="<把机会的真实情况写在这里>")
a = r["answers"]
p = a["is_real"]["noul"] # 校准概率
ev = a["ev"]["score"] / 4 # 归一化(锚点 5 个 → /4)
step = a["next_step"]["choice"] # 选中键
print(p, ev, step, gate(p)) # act / confirm / escalate跑现成示例:
export OPENROUTER_API_KEY=sk-or-...
python3 examples/three_questions.pyjevkit noul "worth outreach?" --state "lead: ..." # → 0.61
jevkit gate 0.63 # → confirm
jevkit decide questions.json --state "..." # → full answersquestionsexpects a record ({name: {...}}), not an array- 三种类型都要
criteria:noul=record / score=array / choice=record(见上表) score返回的是锚点序号,不是 0–1(必须归一化)- The response is
answers.{name}.noul— not a top-level probability - Borderline probabilities flip — never auto-act on 0.5-0.7, gate them
- noul(false) + noul(true) don't have to sum to 1
from jevkit import gate
p = client.noul(...) # System 1: calibrated fast decision
action = gate(p) # act(>=0.7) / confirm(0.5-0.7) / escalate(<0.5)
if action == "act": # only auto-act on high confidence
do_the_thing()
elif action == "confirm":
queue_for_review() # borderline → human or System 2 (LLM review)Default thresholds: act >= 0.7, confirm >= 0.5 — tuned for the "borderline
flips" property (never auto-act in 0.5-0.7). Override per use case:
gate(p, act=0.8, confirm=0.6) # stricter gateSystem 1 (Jev) decides who/what to act on; System 2 (a chat model) handles the acting itself (writing, reasoning). This division keeps costs low and decisions calibrated.
决策质量要盯 —— 姊妹仓 jev-calib 跑同一 state N 次,测可重复性、检漂移、留漂移账本:
git clone https://github.com/HCTDIP/jev-calib && cd jev-calib
PYTHONPATH=../jevkit python3 jev_calib.py --config cases.json --runs 5 # 真跑
python3 track.py --report-only # 看跨轮漂移趋势- ✅ Client + CLI + gate pattern (validated with real API calls, R3 read-back)
- ✅ Score / Choice 调用形状实测校正(criteria 形状 + 锚点序号陷阱)
- ✅ Error handling: RuntimeError on HTTP errors (fallback-friendly)
- 🚧 Tests + CI
MIT
Jev 的卖点是确定性:同一状态、同一问题 → 同一结论。缓存把这句话变成可断言的行为,顺便省钱。
from jevkit import Client
c = Client(cache_dir="~/.cache/jevkit") # 或 export JEVKIT_CACHE_DIR=~/.cache/jevkit
r1 = c.decide(questions, state="…") # -> {"_cache": "miss"} 真调用
r2 = c.decide(questions, state="…") # -> {"_cache": "hit"} 零外呼、零费用
c.decide(questions, state="…", no_cache=True) # 显式绕过
c.cache_stats() # {"hits":1,"misses":1,"hit_rate":0.5,...}- key =
sha256(model + state + questions)(字典序无关;换模型不串味) - 默认关闭(不偷偷写磁盘);
cache_dir=或JEVKIT_CACHE_DIR开启;JEVKIT_CACHE_TTL秒可设过期 - 实测:第二次同状态调用
_cache=hit,0 外呼(重复尽调 0 成本)
choice()旧版发的是options→ HTTP 400(API 要求criteriarecord)。现已修正,并向后兼容旧的options=[...]写法(自动转{opt: opt})- 新增
score()+normalize_score(value, anchors):score返回的是锚点刻度上的期望值(不是 0-1) decide()增加no_cache参数,HTTP 层抽成_post()(可替换,便于测试)