文档目录

快速开始

5 分钟内上手 Jev。

非官方中文翻译 · 内容以 英文原文 ↗ 为准 · 同步于 2026-10-15

本指南介绍使用 Jev(TypeSafe 的 System One 模型)的四种方式:使用我们的 SDK、调用我们的 API、使用我们的 agent skill,或试用浏览器版 Playground。

前往 TypeSafe 控制台 获取 API key。

你需要了解的最少知识

每次调用 Jev 都会接收一个 state(上下文状态)(简单的字符串或结构化对象)和一组问题,并对每个问题返回一个答案:

mermaid
%%{init: {"fontFamily": "Inter, sans-serif", "flowchart": {"rankSpacing": 35, "wrappingWidth": 300, "subGraphTitleMargin": {"top": 12, "bottom": 12}}}}%%
flowchart LR
    doc["state<br/><i>input text or object<br/>to evaluate</i>"]
    quest["questions<br/><i>what you want to know<br/>about the state</i>"]

    subgraph call["one call to Jev"]
        direction LR
        doc --> api["TypeSafeClient<br/>.system_one()"]
        quest --> api
    end

    api --> ans["answers<br/><i>one result per question</i>"]

Jev 可以回答三种类型的问题,统称为题型(primitives):

问题类型 目标 返回值
Choice 从列表中选择一个选项 choice、probabilities、confidence
Score 按评分标准对 state 评分 score、probabilities、confidence
Noul 这个陈述是否为真? noul(0–1)

Vibe it: Agent Skill

最快的方式是为你的项目安装 TypeSafe skill,让编程智能体(coding agent)编写集成代码。

  1. 安装 TypeSafe skill ,可使用 Claude Code 插件或运行 npx skills add typesafe-ai/skills --skill typesafe-ai。你也可以在 GitHub 上阅读 SKILL.md。

Claude Code

在终端运行下面两条命令:

bash
claude plugin marketplace add typesafe-ai/skills
claude plugin install typesafe@typesafe-ai

其他智能体

bash
npx skills add typesafe-ai/skills --skill typesafe-ai

按提示选择你的智能体。默认安装到当前项目,加 -g 可全局安装。

复制给你的智能体

把这段提示粘贴到你的编程智能体中:

text
Install the TypeSafe skill. If you're in Claude Code, run `claude plugin marketplace add typesafe-ai/skills`, then `claude plugin install typesafe@typesafe-ai`. If you're in another agent, run `npx skills add typesafe-ai/skills --skill typesafe-ai` and select your agent. Use one installation method. You can read the skill directly at https://github.com/typesafe-ai/skills/blob/main/skills/typesafe-ai/SKILL.md (raw: https://raw.githubusercontent.com/typesafe-ai/skills/main/skills/typesafe-ai/SKILL.md). Then use the TypeSafe skill when working on this project.
  1. 告诉你的编程智能体,在开发过程中使用 TypeSafe skill。
plaintext
Let's build a simple CLI that uses Jev to evaluate a set of supplied texts on multiple dimensions. Use the TypeSafe skill to understand how to use the TypeSafe API and how to structure the system. Ask me questions about what kinds of texts I want to evaluate and on what dimensions.

Agent Skill 页面提供了更多示例提示以及常见问题(例如智能体没有使用 skill)的解决方法。

Code it: 你的第一个请求

下面演示如何在你喜欢的编程语言中调用 Jev。Python、JavaScript 和 TypeScript 示例使用我们的 SDK;Bash 示例直接调用 API。

创建一个工作目录并设置你的 API key。下面这些 setup 命令使用 Bash,可运行在 macOS、Linux 或装有 WSL 的 Windows 上:

bash
mkdir typesafe-quickstart
cd typesafe-quickstart
export TYPESAFE_API_KEY="your-api-key"

下面的示例发送一张客户支持工单,并在一次请求中向 Jev 提出三个问题:哪个团队应该处理它、客户的挫败感有多强,以及问题是否紧急。

Python

需要 Python 3.10 或更高版本。选择一个包管理器来安装 SDK:

pip

已安装 pip 后,创建虚拟环境并安装 SDK:

bash
python3 -m venv .venv
.venv/bin/pip install typesafe-sdk

uv

已安装 uv 后,初始化项目并安装 SDK:

bash
uv init --bare
uv add typesafe-sdk

保存为 route_ticket.py:

python
from typesafe_sdk import Choice, Noul, Score, TypeSafeClient

ticket = "Our API integration started returning 500 errors on every request about 20 minutes ago, and we can't process any customer orders until this is fixed."

with TypeSafeClient(model="jev-latest") as client:  # Reads TYPESAFE_API_KEY.
    response = client.system_one(
        state=ticket,
        questions={
            "department": Choice(
                instructions="Which team should handle this",
                criteria={
                    "billing": "Payment or subscription issues",
                    "technical": "Bugs or integration problems",
                    "sales": "Pricing or account questions",
                },
            ),
            "frustration": Score(
                instructions="How frustrated the customer appears",
                criteria=[
                    "Calm, just stating facts",
                    "Frustrated but civil",
                    "Very angry, strong language",
                ],
            ),
            "is_urgent": Noul(
                instructions="The message conveys urgency or time-sensitivity",
            ),
        },
    )

print(response.choices["department"].choice)
print(response.scores["frustration"].score)
print(response.nouls["is_urgent"].noul)

用任意一种安装方式运行:

bash
.venv/bin/python route_ticket.py

JavaScript

需要 Node.js 20 或更高版本。安装 SDK 并把项目标记为 ES 模块:

bash
npm install @typesafe-ai/sdk
npm pkg set type=module

保存为 route_ticket.js:

javascript
import { choice, noul, score, TypeSafeClient } from "@typesafe-ai/sdk";

const ticket = "Our API integration started returning 500 errors on every request about 20 minutes ago, and we can't process any customer orders until this is fixed.";

const client = new TypeSafeClient({ defaultModel: "jev-latest" }); // Reads TYPESAFE_API_KEY.
const response = await client.systemOne({
  state: ticket,
  questions: {
    department: choice("Which team should handle this", {
      billing: "Payment or subscription issues",
      technical: "Bugs or integration problems",
      sales: "Pricing or account questions",
    }),
    frustration: score("How frustrated the customer appears", [
      "Calm, just stating facts",
      "Frustrated but civil",
      "Very angry, strong language",
    ]),
    is_urgent: noul("The message conveys urgency or time-sensitivity"),
  },
});

console.log(response.answers.department.choice);
console.log(response.answers.frustration.score);
console.log(response.answers.is_urgent.noul);

运行:

bash
node route_ticket.js

TypeScript

需要 Node.js 22.18 或更高版本才能直接运行 TypeScript。安装 SDK 并把项目标记为 ES 模块:

bash
npm install @typesafe-ai/sdk
npm pkg set type=module

保存为 route_ticket.ts:

typescript
import { choice, noul, score, TypeSafeClient } from "@typesafe-ai/sdk";

const ticket = "Our API integration started returning 500 errors on every request about 20 minutes ago, and we can't process any customer orders until this is fixed.";

const client = new TypeSafeClient({ defaultModel: "jev-latest" }); // Reads TYPESAFE_API_KEY.
const response = await client.systemOne({
  state: ticket,
  questions: {
    department: choice("Which team should handle this", {
      billing: "Payment or subscription issues",
      technical: "Bugs or integration problems",
      sales: "Pricing or account questions",
    }),
    frustration: score("How frustrated the customer appears", [
      "Calm, just stating facts",
      "Frustrated but civil",
      "Very angry, strong language",
    ]),
    is_urgent: noul("The message conveys urgency or time-sensitivity"),
  },
});

console.log(response.answers.department.choice);
console.log(response.answers.frustration.score);
console.log(response.answers.is_urgent.noul);

运行:

bash
node route_ticket.ts

SDK 会根据你的问题推导答案类型,因此 response.answers.department.choice 的类型为 "billing" | "technical" | "sales"。

Bash

需要 curl 7.76 或更高版本。保存为 route_ticket.sh:

bash
#!/usr/bin/env bash
set -euo pipefail
: "${TYPESAFE_API_KEY:?Set TYPESAFE_API_KEY first.}"

curl --fail-with-body --silent --show-error \
  https://api.typesafe.ai/v1/systemone \
  -H "Authorization: Bearer $TYPESAFE_API_KEY" \
  -H "Content-Type: application/json" \
  --data-binary @- <<'JSON'
{
  "state": "Our API integration started returning 500 errors on every request about 20 minutes ago, and we can't process any customer orders until this is fixed.",
  "model": "jev-latest",
  "questions": {
    "department": {
      "type": "choice",
      "instructions": "Which team should handle this",
      "criteria": {
        "billing": "Payment or subscription issues",
        "technical": "Bugs or integration problems",
        "sales": "Pricing or account questions"
      }
    },
    "frustration": {
      "type": "score",
      "instructions": "How frustrated the customer appears",
      "criteria": [
        "Calm, just stating facts",
        "Frustrated but civil",
        "Very angry, strong language"
      ]
    },
    "is_urgent": {
      "type": "noul",
      "instructions": "The message conveys urgency or time-sensitivity"
    }
  }
}
JSON

运行:

bash
bash route_ticket.sh

Jev 会针对同一份 state 评估每个问题,并在你提供的 ID 下返回答案。choice 是团队标签,score 是三档挫败感评分标准上的位置(0–2),noul 是紧急程度的概率(0–1)。

Python、JavaScript 和 TypeScript 示例会输出这三个值:

text
technical
0.67
0.99

Bash 示例会单行输出原始 JSON 响应。下一节中的 Raw Response 显示了其格式化后的样子,包含每个答案的 confidence 和 probabilities。以上为示例结果,Jev 不同版本之间的值可能会有所变化。

客户端 SDK 页面介绍了 Python 和 JavaScript SDK 的安装、强类型答案以及它们的重试策略。

调用:API

上一节中所有四个代码示例都使用了这个接口。上方的 Bash 标签展示了不使用 SDK 的完整 HTTP 请求。

http
POST https://api.typesafe.ai/v1/systemone
Authorization: Bearer <API_KEY>
Content-Type: application/json

原始响应

json
{
  "model": "jev-1.13.0",
  "answers": {
    "department": {
      "type": "choice",
      "choice": "technical",
      "confidence": 1.0,
      "probabilities": {
        "technical": 1.0,
        "billing": 0.0,
        "sales": 0.0
      }
    },
    "frustration": {
      "type": "score",
      "score": 0.67,
      "confidence": 0.5,
      "legend": {
        "0": "Calm, just stating facts",
        "1": "Frustrated but civil",
        "2": "Very angry, strong language"
      },
      "probabilities": {
        "0": 0.33,
        "1": 0.67,
        "2": 0.0
      }
    },
    "is_urgent": {
      "type": "noul",
      "noul": 0.99
    }
  },
  "usage": {
    "input_tokens": 428,
    "output_tokens": 73
  }
}

API 参考文档 列出了每个请求字段、问题类型和答案类型。

在 Playground 中试一试

Playground 可以在浏览器中直接运行 Jev:粘贴一段 state,添加问题并查看答案,无需编写代码。

  1. 打开 Playground 并登录。
  2. 粘贴任意文本 作为 state。
plaintext
Our API integration started returning 500 errors on every request about 20 minutes ago, and we can't process any customer orders until this is fixed.
  1. 添加一个问题。 试一个 Noul 问题:"Does this message express urgency?"
json
{
  "urgency": {
    "type": "noul",
    "instructions": "Does this message express urgency?"
  }
}
  1. 添加更多问题。 在一次调用中混合使用 Noul、Choice 和 Score 问题,一次性查看所有结果。

后续步骤

把 primitives 组合成更大的系统需要一些练习,即使你已经熟悉 LLM。机器学习入门 解释了为什么 Jev 返回的是校准过的概率,而不是生成的文本,以及这会如何改变你基于它进行构建的方式。

我们还建议你看看 Primitives 和 用例地图。

  1. 错误处理与重试
  2. 并行问题

本文档由 Mintlify 构建和托管,Mintlify 是一个面向开发者的文档平台。