开发者
如何使用托管 Jev API
单一接口:发送 state 与类型化 questions,返回结构化答案。用本站 jv_live_ 密钥鉴权——预付输入 token,输出免费。上游 TypeSafe 密钥留在服务器。
来源参考:
1. 接口
每次调用均为 POST 到 https://jevtypesafe.org/api/v1/decide,使用 Bearer 鉴权。把密钥放在环境变量 JEV_API_KEY(切勿提交进仓库)。
请求头:Authorization: Bearer jv_live_…请求头:Content-Type: application/json- 购买预付包(或使用每月赠送 token)后,在「账户」创建密钥。
curl https://jevtypesafe.org/api/v1/decide \
-H "Authorization: Bearer $JEV_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"state": "Customer: I was charged twice and nobody has replied for 3 days.",
"questions": {
"route": {
"type": "choice",
"instructions": "Where should this go?",
"criteria": { "billing": "money", "bug": "broken", "account": "login" }
},
"urgency": {
"type": "score",
"instructions": "How urgent is this?",
"criteria": ["routine", "today", "urgent", "critical"]
},
"escalate": {
"type": "noul",
"instructions": "Escalate to a human now?"
}
}
}'import os
import requests
resp = requests.post(
"https://jevtypesafe.org/api/v1/decide",
headers={
"Authorization": f"Bearer {os.environ['JEV_API_KEY']}",
"Content-Type": "application/json",
},
json={
"state": "Customer: I was charged twice and nobody has replied for 3 days.",
"questions": {
"route": {
"type": "choice",
"instructions": "Where should this go?",
"criteria": {"billing": "money", "bug": "broken", "account": "login"},
},
"urgency": {
"type": "score",
"instructions": "How urgent is this?",
"criteria": ["routine", "today", "urgent", "critical"],
},
"escalate": {
"type": "noul",
"instructions": "Escalate to a human now?",
},
},
},
timeout=30,
)
resp.raise_for_status()
print(resp.json())const res = await fetch("https://jevtypesafe.org/api/v1/decide", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.JEV_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
state: "Customer: I was charged twice and nobody has replied for 3 days.",
questions: {
route: {
type: "choice",
instructions: "Where should this go?",
criteria: { billing: "money", bug: "broken", account: "login" },
},
urgency: {
type: "score",
instructions: "How urgent is this?",
criteria: ["routine", "today", "urgent", "critical"],
},
escalate: {
type: "noul",
instructions: "Escalate to a human now?",
},
},
}),
});
if (!res.ok) throw new Error(await res.text());
console.log(await res.json());测试你的密钥 — 对线上接口发起一次与上方相同的请求:
将上方请求发到 https://jevtypesafe.org/api/v1/decide,使用你的密钥并扣一次小决策费用(均值约 ≈ $0.0004)。密钥仅留在浏览器;生产环境请放在服务端。
2. 请求体
两个必填字段:
- state — 上下文文本(工单、邮件、评论等)。最长 4,000 字符。
- questions — 名称 → 问题对象的映射。同一次请求里的多个问题共享 state,一轮返回。
3. 三种问题类型
choice — 单选
传入带标签的 criteria 映射。响应含获胜键、各选项概率与置信度。
"topic": {
"type": "choice",
"instructions": "What is the primary issue?",
"criteria": {
"billing": "billing or payment problem",
"bug": "the product is broken",
"account": "login or access"
}
}score — 量表打分
传入有序 criteria 数组(2–10 档)。响应含数值分数与各档分布。
"severity": {
"type": "score",
"instructions": "How urgent is this?",
"criteria": [
"routine",
"handle today",
"urgent",
"critical, about to churn"
]
}noul — 校准的是/否
无需 criteria,仅 instructions。响应为 [0, 1] 概率。
"escalate": {
"type": "noul",
"instructions": "Escalate to a human immediately?"
}4. 响应
类型化答案可直接写分支逻辑,无需解析字符串里的 JSON。示例结构:
{
"model": "jev-latest",
"answers": {
"route": {
"type": "choice",
"choice": "billing",
"confidence": 1.0,
"probabilities": { "billing": 1.0, "bug": 0.0, "account": 0.0 }
},
"urgency": {
"type": "score",
"score": 2.0,
"confidence": 0.9,
"probabilities": { "0": 0.05, "1": 0.1, "2": 0.7, "3": 0.15 }
},
"escalate": { "type": "noul", "noul": 0.72 }
},
"usage": { "input_tokens": 180, "output_tokens": 40 }
}usage.input_tokens 从预付余额扣除;输出 token 免费。
5. 限额与实践
- 速率约每密钥 60 次/分钟(另有 IP / 账户 / 全局上限)。
- 软燃烧上限约每账户每小时 2,000,000 token、每天 20,000,000 token。
- 精简 state——按输入 token 计费。
- 一次调用批量多个问题,共享 state 成本。
- 用置信度 / noul 阈值自动处理简单案例,其余再升级。
立刻开通
登录 → 在定价页买小包 → 在账户创建 jv_live_ 密钥 → 调用本接口。Core decide 与所有托管工具共用余额。