TokenRa
English登录注册

决策模型 · TypeSafe AI

Jev API

Jev 是 TypeSafe AI 的决策模型,不生成文本:你提交一段待判断的内容(state)和若干命名问题,每个答案都以类型化结果返回,并附带概率和置信度。

模型 ID
jev-latest
输入
文本或 JSON
输出
类型化答案
延迟
1 秒以内

Capabilities

能力与接口

只有一个同步接口。Jev 不使用对话格式,OpenAI 和 Anthropic 的 SDK 都不适用,请直接发送 HTTPS 请求;在 /v1/chat/completions 上调用 jev-latest 会报错。

POSThttps://tokenra.io/v1/decisions已实测
提交 state 和命名的 questions,每个问题返回一个类型化答案。鉴权:Authorization: Bearer。

Questions

问题类型

每个问题由你自定义名称,包含 type、instructions,并按类型提供 criteria。三种类型均已于 2026-10-23 实测。

typecriteria答案字段
noul可选。只能包含 "true" 和 "false" 两个键,分别说明何种情况成立。noul:答案为 true 的概率(0–1)。
choice必填。选项键到选项说明的对象,至少一个选项。choice(最可能的选项键)、各选项的 probabilities、confidence。
score必填。至少两个等级说明组成的数组,从低到高排列。score(0 到等级数−1,可以是小数)、legend、各等级的 probabilities、confidence。

Request

请求参数

参数类型必填说明
modelstring是jev-latest。响应中的 model 是实际回答的版本,例如 typesafe/jev-1.14-20261014 或 jev-1.14.0。
statestring / object / array是待判断的内容,所有问题共用:可以是文本,也可以是工单、记录等 JSON。已实测中文文本。
questionsobject是问题名称到问题对象的映射,至少一个;答案以相同的名称返回。
questions.*.typestring是noul、choice 或 score。
questions.*.instructionsstring / object / array是问题本身。
questions.*.criteriaobject / array否取决于问题类型,见上表;choice 和 score 必填。
streamboolean否不支持,请不要传;传 true 会报错。

Response

响应格式

示例请求的实际响应(2026-10-24)
{
  "model": "typesafe/jev-1.14-20261014",
  "answers": {
    "department": {
      "type": "choice",
      "choice": "billing",
      "probabilities": {
        "billing": 0.92,
        "technical": 0.08,
        "sales": 0
      },
      "confidence": 0.88
    },
    "frustration": {
      "type": "score",
      "score": 1.66,
      "legend": {
        "0": "平静",
        "1": "不满",
        "2": "非常愤怒"
      },
      "probabilities": {
        "0": 0,
        "1": 0.34,
        "2": 0.66
      },
      "confidence": 0.49
    },
    "is_urgent": {"type": "noul", "noul": 0.87}
  },
  "usage": {"input_tokens": 461, "output_tokens": 73},
  "id": "gen-dec-1792772719-p9IzUxjzfk4qHGN0DyAd",
  "provider": "TypeSafe"
}
字段类型说明
modelstring实际回答的 Jev 版本。
answers.<name>.typestring问题类型。
answers.<name>.noulnumber仅 noul:答案为 true 的概率。
answers.<name>.choicestring仅 choice:最可能的选项键。
answers.<name>.scorenumber仅 score:期望等级,0 到等级数−1。
answers.<name>.probabilitiesobjectchoice 和 score:各选项或等级的概率,合计为 1。
answers.<name>.legendobject仅 score:等级序号到等级说明的对照。
answers.<name>.confidencenumberchoice 和 score:0–1 的置信度,可据此把不确定的情况转人工。
usageobject计费用的 input_tokens 和 output_tokens。
id / providerstring请求 ID 和实际提供方,上游返回时才有。

答案以问题名称为键,不要依赖其顺序;实测返回顺序按名称排序,而不是请求中的顺序。

测试期间上游返回过两种格式:一种的 model 形如 typesafe/jev-1.14-20261014,并附带 id 和 provider;另一种的 model 形如 jev-1.14.0,没有这两个字段。两者的 answers 和 usage 完全相同,读取时只取你需要的字段即可。

Errors

错误与限制

请求校验错误

请求不合法时返回 HTTP 400,error.code 为 invalid_request,message 为下表之一。这类错误重试无效,请修正请求。

message原因
questions must not be empty缺少 questions 或为空。
state must be a string, object or array缺少 state,例如误发了对话格式的 messages。
unsupported question type; expected noul, choice or scoretype 不是三种之一。
choice criteria must be a nonempty object of choiceschoice 问题没有选项。
score criteria must contain at least two string levelsscore 问题少于两个等级。
noul criteria must contain only true and false string descriptionsnoul 的 criteria 中含有其他键。
decisions do not support streaming传了 stream: true。

常见错误

HTTPerror.code含义处理建议
401—API Key 缺失、错误或已删除,message 为 Invalid token。检查 Authorization: Bearer 请求头,并在控制台核对 Key。
400—请求体不是合法 JSON。修正 JSON,并带上 Content-Type: application/json。
403insufficient_user_quota账户余额或套餐额度不足。在控制台充值后重试。
503model_not_found模型 ID 不存在,或你的分组下没有可用渠道。在模型列表或 GET /v1/models 中核对模型 ID。
429—请求过于频繁。指数退避后重试。
5xx—上游服务商出错或超时。稍后重试几次;持续出错时保留 request id 联系支持。

使用限制与说明

  • 实测单次请求耗时 0.35–1 秒。
  • 计费:输入和输出 token 同价,均为每 100 万 token $0.042(2026-10-24 核对)。实测一次 358 个输入 token、60 个输出 token 的请求扣了 9 个额度,即 $0.000018。问题定义计入输入 token。价格会调整,实时价格见模型广场。
  • 一句话的 state 加示例中的三个问题,实测消耗 461 个输入 token 和 73 个输出 token,问题定义也计入输入。