跳到正文
Jev

开发者

如何使用托管 Jev API

单一接口:发送 state 与类型化 questions,返回结构化答案。用本站 jv_live_ 密钥鉴权——预付输入 token,输出免费。上游 TypeSafe 密钥留在服务器。

1. 接口

每次调用均为 POST 到 https://jevtypesafe.org/api/v1/decide,使用 Bearer 鉴权。把密钥放在环境变量 JEV_API_KEY(切勿提交进仓库)。

curl
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?"
      }
    }
  }'

测试你的密钥 — 对线上接口发起一次与上方相同的请求:

将上方请求发到 https://jevtypesafe.org/api/v1/decide,使用你的密钥并扣一次小决策费用(均值约 ≈ $0.0004)。密钥仅留在浏览器;生产环境请放在服务端。

2. 请求体

两个必填字段:

3. 三种问题类型

choice — 单选

传入带标签的 criteria 映射。响应含获胜键、各选项概率与置信度。

choice
"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 档)。响应含数值分数与各档分布。

score
"severity": {
  "type": "score",
  "instructions": "How urgent is this?",
  "criteria": [
    "routine",
    "handle today",
    "urgent",
    "critical, about to churn"
  ]
}

noul — 校准的是/否

无需 criteria,仅 instructions。响应为 [0, 1] 概率。

noul
"escalate": {
  "type": "noul",
  "instructions": "Escalate to a human immediately?"
}

4. 响应

类型化答案可直接写分支逻辑,无需解析字符串里的 JSON。示例结构:

response
{
  "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. 限额与实践

立刻开通

登录 → 在定价页买小包 → 在账户创建 jv_live_ 密钥 → 调用本接口。Core decide 与所有托管工具共用余额。

如何使用托管 Jev API | 接口与示例