跳到主要内容

TypeSafe Jev(三种调用方式)使用文档

本文档基于对本中转实例的 真实调用验证 写成,所有请求与响应均为实测结果。 Jev 是 TypeSafe 的「System One」判断型模型:不做自由文本对话,只对给定 state 上的 questions 返回结构化判断(choice / score / noul)。

基本信息

项目
中转 Base URLhttps://llmapi.cttai.art
鉴权方式Authorization: Bearer <API Key>
API KeyAPI 控制台「令牌」页面生成(注意保密,勿公开)
可用模型jev-1.13.0jev-latestjev-preview(当前均解析到 jev-1.13.0
计费仅按 input_tokens 计费($0.042 / 百万输入 token),输出免费

说明:jev-latest 指向最新稳定版(默认可直接用);jev-preview 指向最新构建,存在预览版时会领先于稳定版;jev-1.13.0 是固定版本号。


方式一:列出可用模型(连通性检查)

GET https://llmapi.cttai.art/v1/models
Authorization: Bearer <API Key>

实测返回:

{
"data": [
{ "id": "jev-1.13.0", "object": "model", "owned_by": "task plugin", "supported_endpoint_types": ["openai"] },
{ "id": "jev-latest", "object": "model", "owned_by": "task plugin", "supported_endpoint_types": ["openai"] },
{ "id": "jev-preview", "object": "model", "owned_by": "task plugin", "supported_endpoint_types": ["openai"] }
],
"object": "list",
"success": true
}

提示:supported_endpoint_types: ["openai"] 只是 new-api 的通用标记,不代表 chat/completions 可用,请见文末「不支持的用法」。


方式二:原生路由(推荐,同步返回答案)

POST https://llmapi.cttai.art/typesafe/v1/systemone
Authorization: Bearer <API Key>
Content-Type: application/json

请求体

{
"model": "jev-latest",
"state": "Customer: My payouts have been failing for 3 days, I am losing sales, please help ASAP",
"questions": {
"department": {
"type": "choice",
"instructions": "Which team should handle this?",
"criteria": {
"billing": "Payments, invoicing, refunds",
"technical": "Bugs, outages, integrations",
"sales": "Pricing, upgrades, new accounts"
}
},
"urgent": {
"type": "noul",
"instructions": "Does this express urgency?"
},
"frustration": {
"type": "score",
"instructions": "How frustrated is the customer?",
"criteria": ["Calm", "Frustrated", "Very angry"]
}
}
}

字段规则:

  • model:必填,取三个模型名之一。
  • state:共享上下文,可为文本 / 对象 / 数组 / null(64k 上下文预算内)。
  • questions:必填,非空对象;每个问题 type 只能是以下三种:
    • choicecriteria对象,选项数 1~255。
    • scorecriteria数组,档位数 2~10。
    • noulcriteria 可选,若填则键只能是 "true"/"false"
  • stream:不支持(必须为 false 或不传)。

实测响应

{
"model": "jev-1.13.0",
"answers": {
"department": {
"type": "choice",
"choice": "billing",
"confidence": 0.91,
"probabilities": { "billing": 0.94, "sales": 0, "technical": 0.06 }
},
"urgent": {
"type": "noul",
"noul": 0.98
},
"frustration": {
"type": "score",
"score": 1.07,
"confidence": 0.9,
"legend": { "0": "Calm", "1": "Frustrated", "2": "Very angry" },
"probabilities": { "0": 0, "1": 0.93, "2": 0.07 }
}
},
"usage": { "input_tokens": 425, "output_tokens": 70 }
}

回答字段对应关系:

题型返回字段
choicechoice(命中的选项键)+ confidence + probabilities(各选项概率)
scorescore(档位数值,0 起)+ confidence + legend(档位原文)+ probabilities
noulnoul(0~1 的置信度)
  • 该接口同步完成,即发即回;usage.input_tokens 即计费量。
  • 结果不会保留到任务查询接口,务必保存本次响应。

curl 示例

curl 'https://llmapi.cttai.art/typesafe/v1/systemone' \
-H 'Authorization: Bearer <API Key>' \
-H 'Content-Type: application/json' \
-d '{
"model": "jev-latest",
"state": "Customer: My payouts have been failing for 3 days.",
"questions": {
"urgent": { "type": "noul", "instructions": "Does this express urgency?" }
}
}'

方式三:通用任务接口(提交 + 查询)

POST https://llmapi.cttai.art/v1/tasks/typesafe # 提交任务
GET https://llmapi.cttai.art/v1/tasks/{task_id} # 查询任务状态

请求体与方式二的请求体结构相同(model 必填)。

提交(实测)

curl 'https://llmapi.cttai.art/v1/tasks/typesafe' \
-H 'Authorization: Bearer <API Key>' \
-H 'Content-Type: application/json' \
-d '{
"model": "jev-latest",
"state": "Customer: My payouts have been failing for 3 days.",
"questions": { "urgent": { "type": "noul", "instructions": "Does this express urgency?" } }
}'

提交响应(返回网关公开任务 ID,task_idid):

{
"created_at": 1789967908,
"id": "task_HA2KPl4UIKSwr7ZOCcGQStelcz357SpI",
"model": "jev-latest",
"status": "queued",
"task_id": "task_HA2KPl4UIKSwr7ZOCcGQStelcz357SpI"
}

查询状态(实测)

GET https://llmapi.cttai.art/v1/tasks/task_HA2KPl4UIKSwr7ZOCcGQStelcz357SpI
{
"created_at": 1789967908,
"fail_reason": "",
"finished_at": 1789967908,
"platform": "typesafe",
"progress": "100%",
"status": "SUCCESS",
"task_id": "task_HA2KPl4UIKSwr7ZOCcGQStelcz357SpI"
}

注意:通用接口的查询响应只返回标准状态字段,不会重新返回答案正文(该插件为同步完成路由)。要用判断结果请使用「方式二」并保存同步响应;任务记录仅用于状态与计费核对。


不支持的用法

以下用法实测不可用,请勿使用:

用法结果
POST /v1/chat/completions503 model_not_found(Jev 不做对话)
stream: true报错(TypeSafe System One 不支持流式)
任务轮询拿答案查询只返回状态,不返回答案

附:Python 调用示例(已验证可运行)

import json, urllib.request, ssl

BASE = "https://llmapi.cttai.art"
KEY = "<API Key>"
CTX = ssl.create_default_context()

def call(path, method="GET", body=None):
data = json.dumps(body, ensure_ascii=False).encode() if body is not None else None
req = urllib.request.Request(BASE + path, data=data, method=method,
headers={"Authorization": "Bearer " + KEY,
"Content-Type": "application/json"})
with urllib.request.urlopen(req, context=CTX, timeout=30) as resp:
return resp.status, json.loads(resp.read().decode("utf-8"))

# 方式二:原生路由
status, resp = call("/typesafe/v1/systemone", "POST", {
"model": "jev-latest",
"state": "Customer: My payouts have been failing for 3 days.",
"questions": {"urgent": {"type": "noul", "instructions": "Does this express urgency?"}},
})
print(status, json.dumps(resp, ensure_ascii=False, indent=2))

提示:本文档内容均来自对该中转实例的真实调用实测,可直接使用 curl 或任意 OpenAI 兼容客户端验证。