获取 Jev

API 参考

你买的是通用 Decision API。给 `/v1/decide` 传一个 `state` 和带类型的 `questions`,拿回校准过的 `answers`——拿它做什么由你决定。下面的现成端点只是常见场景的可选 shortcut,你不用等我们替你加。

鉴权

所有端点用同一个 Bearer key。在定价页创建(登录、预付一小笔余额)。key 形如 jv_live_…。把它留在服务端、放进环境变量,别提交到代码库或暴露在前端。

Authorization: Bearer jv_live_your_key_here
Content-Type: application/json

核心 API —— /v1/decide

这才是产品本体。一次调用:一个 state 加带类型的 questions,拿回校准过的 answers。下面的一切(以及每个现成 API)都只是它加上一组固定的问题。

POST https://jevtypesafeai.com/api/v1/decide

请求体

  • model —— jev-latest,或钉住某版本如 jev-1.13.0。可选。
  • state —— 要评估的输入:字符串、对象或数组。必填。
  • questions —— 「名字 → 带类型问题」的映射(choicescorenoul),一次往返并行评估。必填。

三种问题类型

每个问题恰好是其中之一。一次调用可任意混用。

choice —— 选出一个选项

一个 criteria 映射,最多 255 个带标签选项。Jev 返回胜出的 choice、每个选项的 probability,以及 confidence

"route": {
  "type": "choice",
  "instructions": "Where should this ticket go?",
  "criteria": {
    "billing": "payments, refunds, invoices",
    "bug": "the product is broken",
    "account": "login or access"
  }
}
// → { "type":"choice", "choice":"billing", "confidence":0.99,
//     "probabilities": { "billing":0.99, "bug":0.0, "account":0.01 } }

score —— 在有序刻度上打分

一个有序的 criteria 数组,2–10 个由低到高的具体等级描述。Jev 返回(可能带小数的)score、每级 probabilitieslegendconfidence

"urgency": {
  "type": "score",
  "instructions": "How urgent is this message?",
  "criteria": ["routine, no rush", "today", "urgent", "critical, about to churn"]
}
// → { "type":"score", "score":2.97, "confidence":1.0,
//     "probabilities": { "0":0.0, "3":1.0 } }

noul —— 校准过的是/否

只要 instructions。Jev 返回 noul——答案为「是」的校准 0–1 概率。非常适合门控与护栏。

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

提示:state 可以是字符串、对象或数组——只发决策需要的上下文。state 加全部问题合计最多约 64k tokens。

示例请求

curl

curl https://jevtypesafeai.com/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?" }
    }
  }'

Python

import os, requests

r = requests.post(
    "https://jevtypesafeai.com/api/v1/decide",
    headers={"Authorization": f"Bearer {os.environ['JEV_API_KEY']}"},
    json={
        "state": "Customer: I was charged twice...",
        "questions": {
            "escalate": {"type": "noul", "instructions": "Escalate to a human now?"}
        },
    },
    timeout=30,
)
print(r.json()["answers"]["escalate"]["noul"])  # 0.0 - 1.0

JavaScript / TypeScript

const res = await fetch("https://jevtypesafeai.com/api/v1/decide", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.JEV_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    state: "Customer: I was charged twice...",
    questions: {
      escalate: { type: "noul", instructions: "Escalate to a human now?" },
    },
  }),
});
const data = await res.json();
if (data.answers.escalate.noul > 0.7) handoffToHuman();

响应

你会拿回解析后的 model、按你的问题名索引的 answers 映射,以及 usage 块。因为每个答案类型由请求固定,你用普通代码直接分支——无需解析、无需正则。

{
  "model": "jev-1.13.0",
  "answers": {
    "route":    { "type": "choice", "choice": "billing", "confidence": 0.99,
                  "probabilities": { "billing": 0.99, "bug": 0.0, "account": 0.01 } },
    "urgency":  { "type": "score", "score": 3.0, "probabilities": { "0": 0.0, "3": 1.0 } },
    "escalate": { "type": "noul", "noul": 0.94 }
  },
  "usage": { "input_tokens": 62, "cost_usd": 0.000026, "credits_remaining_usd": 4.999974 }
}

错误码

  • 400 —— 请求校验失败;error 字段说明原因。
  • 401 —— API key 缺失、无效或已吊销。
  • 402 —— 余额不足(code: "insufficient_credits")。
  • 403 —— 账户未激活。
  • 404 —— 未知的应用端点。
  • 502 —— 上游 Jev 错误;带退避重试。

最佳实践

  • 有合适的应用端点就用它;只有需要自定义决策时才用 /decide
  • state 精简到决策需要的内容——按 input token 付费。
  • 生产环境钉住模型版本,避免阈值漂移。
  • jv_live_ key 留在服务端。

现成 API

可选的 shortcut。有合适的就按示例传普通字段、省去自己写问题——拿回干净带类型的结果和 usage 块。没有合适的就用上面的 /v1/decide,你永远不受我们的 preset 限制。字段错误返回 400,并附 expects 示例。

邮件

POST /api/v1/email/triage邮件分诊

对收到的邮件分类:类别、优先级、是否垃圾、是否需要回复、路由到哪个团队。

# request
{"subject":"Charged twice","body":"I was charged twice and need this fixed today."}

# response
{"category":"billing","priority":"urgent","spam":false,"needs_reply":true,"route_to":"finance","confidence":0.96}

客服工单

POST /api/v1/support/triage工单分诊

路由支持工单:团队、问题类型、严重度、紧急度、是否立即升级。

# request
{"subject":"App is down","body":"Production dashboard returns 500 for all users since 10am."}

# response
{"team":"technical","issue_type":"outage","severity":"critical","urgency":"now","escalate":true,"confidence":0.99}

Agent

POST /api/v1/agent/riskAgent 风险门控

对 Agent 将要执行的工具调用做门控:allow / confirm / block、0–1 风险分、风险类别。

# request
{"goal":"Clean up the build directory","tool":"bash","arguments":"rm -rf ./dist && aws s3 sync ./build s3://prod --delete","context":"CI deploy step"}

# response
{"action":"block","risk":0.84,
 "categories":["destructive","irreversible","external_side_effect","data_exposure"],"confidence":0.6}

编程 Agent

POST /api/v1/context/filter上下文过滤

对 Agent 历史里的一条旧上下文决定 keep / truncate / drop,对抗上下文膨胀。

# request
{"task":"Fix the failing payment webhook test","item":"Tool call: read_file('README.md') -> 4000 tokens of project overview from 30 steps ago"}

# response
{"action":"drop","relevance":"minor","redundant":true,"confidence":0.53}

LLM 路由

POST /api/v1/model/route模型路由

按提示词复杂度选择模型档位;传入 models[] 可直接返回具体模型名。

# request
{"prompt":"Summarize this 2-sentence email in one line.","models":["fast-mini","balanced","frontier"]}

# response
{"recommended_tier":"fast","complexity":"simple","recommended_model":"fast-mini","confidence":0.78}

RAG 检索

POST /api/v1/rag/relevanceRAG 相关性

判断一段召回的文本是否真的回答了查询——用于重排与过滤。

# request
{"query":"How do I rotate my API key?","passage":"To rotate a key, open Settings > API keys, click Revoke on the old key, then Create new key. Update your environment variable."}

# response
{"relevant":true,"relevance":"direct answer","supports_claim":true,"confidence":1.0}

销售

POST /api/v1/leads/qualify线索评级

对进来的销售线索评级:是否合格、ICP 匹配、分层、是否在购买期、路由。

# request
{"lead":"Jane Doe, VP Eng at Acme (500 employees). 'We're evaluating decision APIs to replace a brittle rules engine — hoping to pick something this quarter.'"}

# response
{"qualified":true,"icp_match":"ideal","segment":"mid_market","buying_now":true,"route":"sales","confidence":0.83}

内容审核

POST /api/v1/content/moderate内容审核

审核用户文本:allow / review / block、各类别标记、命中的违规项。

# request
{"text":"You're an idiot and I'll find where you live."}

# response
{"action":"block",
 "flags":{"toxicity":true,"harassment":true,"violence":true,"sexual":false,
   "self_harm":false,"spam":false,"fraud":false,"pii":false},
 "violation_types":["toxicity","harassment","violence"],"confidence":0.69}

内容

POST /api/v1/content/classify内容分类

给任意帖子打标签:主题、格式、开头钩子、语气、互动潜力。

# request
{"text":"I quit my $200k job to sell candles. Here's what nobody tells you about starting a business 🧵"}

# response
{"topic":"business","format":"listicle","hook_style":"bold_claim","tone":"inspirational","engagement_potential":"very high","confidence":0.82}

社媒

POST /api/v1/social/post-analyze社媒帖子分析

评估帖子的钩子、是否制造悬念、是否有实据,以及传播潜力。

# request
{"post":"Most people fail at cold email because they lead with themselves. I sent 1,000 and the ones that worked all did the opposite. Here's the exact template."}

# response
{"hook":"scroll-stopping","opens_loop":true,"has_evidence":true,"format":"how_to","viral_potential":"high","confidence":0.66}

广告

POST /api/v1/ads/analyze广告分析

给广告打标签:钩子类型、认知阶段、是否有明确 offer、CTA、阻力。

# request
{"headline":"Stop losing leads to slow follow-up","primary_text":"Our AI replies to every inbound lead in 60 seconds so you never lose a deal to a competitor again.","cta":"Start free trial"}

# response
{"hook_type":"problem","awareness_stage":"problem_aware","has_clear_offer":true,"has_cta":true,"friction":"low","confidence":0.72}

SEO

POST /api/v1/seo/page-relevanceSEO 页面相关性

判断一个页面是否该内链到另一个页面,以及两者的关系。

# request
{"source":"Blog: 'How calibrated confidence scores work in decision models'","target":"Docs: 'noul — a calibrated yes/no question type'"}

# response
{"should_link":true,"relevance":"related","relationship":"narrower","confidence":0.62}

计费

  • 预付额度,在 Core 决策 API 和所有现成工作流 API 之间通用。
  • 标准额度 $0.42 / 1M input tokens,更大的额度包费率更低。output token 免费。
  • 每个响应都含 cost_usdcredits_remaining_usd
  • 额度永不过期。

API key 已包含

  • 即开即用、无 waitlist。
  • Core /v1/decide 决策 API。
  • 邮件、客服、Agent、RAG、销售、SEO、广告等现成 API。
  • 一个 API key、一个余额,通用于所有工作流。
  • 批量工作流 + 可复制的 curl / Python / JS 示例。
  • 新的 Jev 场景会持续做成现成端点。

能直接用 TypeSafe AI 的 Jev 吗?

可以——如果你只需要原始 Jev 模型访问,TypeSafe 官方平台直接提供。本服务面向想要「统一决策 API + 现成工作流端点 + 示例 + 工具 + 单一 key 与账单」的开发者。

独立服务. JevTypeSafeAI.com 是独立的开发者平台,与 TypeSafe AI 无从属或背书关系。Jev 由 TypeSafe AI 提供。

获取 API key →▶ 免费试用 Jev
Jev API 中文文档 — 应用层端点 + 决策原语 · Jev by TypeSafe AI