Jev API 调用

了解 Jev

Jev 由 TypeSafe 提供,是判断模型,不是聊天模型。给它一段文字和一个问题,它直接回答归哪一类、打几分、是还是否,结果程序可以直接使用。例如把“订单重复扣款”的反馈分给账单团队,或给一条评论打分。

它使用 TypeSafe 接口,与 OpenAI Chat Completions 接口不兼容,也不能作为 Codex、Claude Code 的对话模型。

获取 API Key

控制台 获取 TeamoRouter API Key,将它保存到 TEAMOROUTER_API_KEY 环境变量。已有 Key 可直接使用,无需注册 TypeSafe 账号。

用官方 SDK 接入

TypeSafe 官方 SDK 可以直接使用,只需把 base_url 指向 TeamoRouter,api_key 换成 TeamoRouter API Key。官方 SDK 默认请求 jev-latest,在 TeamoRouter 请把模型指定为 jev

Python(pip install typesafe-sdk):

python
import os
from typesafe_sdk import Choice, TypeSafeClient

client = TypeSafeClient(
    api_key=os.environ["TEAMOROUTER_API_KEY"],
    base_url="https://api.teamorouter.cn",  # 只改这一行
    model="jev",
)

response = client.system_one(
    state="I was charged twice for the same order.",
    questions={
        "department": Choice(
            instructions="Which team should handle this customer message?",
            criteria={
                "billing": "Charges, payments and refunds",
                "technical": "Bugs and integration issues",
                "other": "Other requests",
            },
        ),
    },
)
print(response.answers["department"])

TypeScript(npm install @typesafe-ai/sdk):

ts
import { choice, TypeSafeClient } from "@typesafe-ai/sdk";

const client = new TypeSafeClient({
  apiKey: process.env.TEAMOROUTER_API_KEY,
  baseURL: "https://api.teamorouter.cn", // 只改这一行
});

const response = await client.systemOne({
  model: "jev",
  state: "I was charged twice for the same order.",
  questions: {
    department: choice("Which team should handle this customer message?", {
      billing: "Charges, payments and refunds",
      technical: "Bugs and integration issues",
      other: "Other requests",
    }),
  },
});
console.log(response.answers.department);

直接调用接口

请求地址:POST https://api.teamorouter.cn/v1/systemone,请求头 Authorization: Bearer <TeamoRouter API Key>,请求体与 TypeSafe 官方一致。下面把一条“重复扣款”的反馈分到 billingtechnicalother。示例使用英文输入,便于先确认调用;中文场景需用实际数据验证效果。

bash
curl --fail-with-body 'https://api.teamorouter.cn/v1/systemone' \
  -H "Authorization: Bearer $TEAMOROUTER_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "jev",
  "state": "I was charged twice for the same order.",
  "questions": {
    "department": {
      "type": "choice",
      "instructions": "Which team should handle this customer message?",
      "criteria": {
        "billing": "Charges, payments and refunds",
        "technical": "Bugs and integration issues",
        "other": "Other requests"
      }
    }
  }
}'

读取结果

以下仅为返回格式示意,实际结果和概率以调用返回为准:

json
{
  "answers": {
    "department": {
      "type": "choice",
      "choice": "billing",
      "probabilities": { "billing": 0.96, "technical": 0.01, "other": 0.03 },
      "confidence": 0.92
    }
  }
}

answers.department.choice 是选中的分类。probabilities 包含各个分类的概率;confidence 表示模型对这次分类的置信度。

选择判断类型

类型 提交什么 读取什么
choice 分类 criteria 为“选项名 → 说明”的对象 choiceprobabilitiesconfidence
score 评分 criteria 为按分值从低到高排列的说明数组 scorelegendprobabilitiesconfidence;分数可能有小数
noul 是非判断 问题描述,可选 criteria.truecriteria.false noul 为 0–1 的数值,越接近 1 越倾向“是”

state 可以是文本、对象或数组。questions 中每个自定义问题名都会在 answers 中对应返回;多个问题分别判断,前一个问题的答案不会自动传给后一个问题。三种类型的完整写法见 TypeSafe primitives

查看价格与限制

  • Jev 在 TeamoRouter 为限时福利价:输入按官方价 0.01 折计费,输出免费,以 实时价格 为准。
  • state 加最长单个问题最多 32K tokens;state 加所有问题合计最多 64K tokens。
  • choice 最多 255 个选项;score 使用 2–10 档评分说明。
  • 请求不使用 messagesstreamtemperaturemax_tokens

排查调用问题

  • 401:检查 Key 是否完整、是否有效,以及 Authorization: Bearer 请求头。
  • 400:检查 statequestions、问题类型和 criteria 的格式,错误信息会指出具体字段。
  • 404:核对请求路径是否为 /v1/systemone
  • 429:请求超过限流,等待片刻后按指数退避重试;官方 SDK 默认会自动重试。

接口定义参考 TypeSafe API 文档

准备好了?三步即可开始登录控制台 · 购买额度 · 创建 API Key
DiscordGet community help instantly
Jev API 调用 · 帮助文档