jev 是远程决策服务,非本地安装模型;需四步接入:1. 在 console.typesafe.ai 申请 api key 并设为环境变量;2. 构造含 state、questions、model 的标准请求体;3. 用 fetch 向 https://api.typesafe.ai/v1/chat/completions 发起带 bearer 鉴权的 post 请求;4. 封装为 jevdecide 函数复用,返回结构化 decisions。
☞☞☞AI 智能聊天, 问答助手, AI 智能搜索, 多模态理解力帮你轻松跨越从0到1的创作门槛☜☜☜

Jev 不是传统意义上“安装”的模型,它不通过 npm install 下载到本地,而是一个远程决策服务。Node.js 项目接入 Jev 的核心动作是:发起符合 OpenAI 兼容规范的 HTTP 请求,不需要安装模型文件或运行推理引擎。
下面分四步说清楚怎么在 Node.js 里用起来:
申请并配置 API Key
打开 console.typesafe.ai 注册登录,在 Keys 页面创建新密钥。复制生成的 sk-xxx 字符串,存为环境变量:
export TYPESAFE_API_KEY="sk-abc123..."
Node.js 中读取:
const apiKey = process.env.TYPESAFE_API_KEY;
if (!apiKey) throw new Error("Missing TYPESAFE_API_KEY");
构造标准请求体(关键三字段)
Jev 只认三个顶层字段:
-
state: 当前上下文文本(比如工单内容、用户消息、游戏地图状态) -
questions: 数组,每个元素是带type的问题对象(choice/score/noul) -
model: 固定填"jev-latest"(当前指向jev-1.13.0)
示例:
const payload = {
model: "jev-latest",
state: "用户说‘我的订单还没发货,急!’",
questions: [
{ type: "noul", question: "Does this message express urgency?" },
{ type: "choice", question: "Which team should handle this?", options: ["technical", "billing", "sales"] }
]
};
发起 POST 请求(推荐 fetch,无需额外 SDK)
Jev 接口地址是 https://api.typesafe.ai/v1/chat/completions,鉴权用 Bearer Token:
const res = await fetch("https://api.typesafe.ai/v1/chat/completions", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${apiKey}`
},
body: JSON.stringify(payload)
});
const data = await res.json();
// 返回结构稳定,含 decisions 数组,每个有 choice/score/confidence 等字段
封装成可复用的裁判函数
把上面逻辑收进一个函数,屏蔽细节:
async function jevDecide(state, questions) {
const res = await fetch("https://api.typesafe.ai/v1/chat/completions", {
method: "POST",
headers: { "Content-Type": "application/json", "Authorization": `Bearer ${apiKey}` },
body: JSON.stringify({ model: "jev-latest", state, questions })
});
if (!res.ok) throw new Error(`Jev error: ${res.status}`);
return (await res.json()).decisions;
}
// 调用示例
const result = await jevDecide(
"付款失败,错误码 PAY_402",
[{ type: "choice", question: "Root cause category?", options: ["network", "auth", "payment"] }]
);
// → { choice: "payment", confidence: 0.92, probabilities: { ... } }
整个过程不依赖任何第三方 SDK,纯原生 fetch 即可跑通。如果你已有 OpenAI SDK 代码,只需改 baseURL 和 model 名,其余逻辑几乎零改动。











