结构化评估(System One)
错误排查
调用过程中遇到错误?请参阅 API 错误码参考 获取完整的错误类型说明与排查方案。
POST /api/v1/systemoneSystem One 接口针对一段 state(待评估内容),按你定义的一组类型化 questions(问题)进行评估,并为每个问题返回一个结构化 answer(答案)。答案与问题通过你自定义的 key 一一对应。
state、questions 和 assets 的语义遵循 TypeSafe System One API。通过 ZenMux 调用时,使用上方地址、ZenMux API Key 和 ZenMux 模型 ID。
每个问题可以是以下四种类型之一,同一请求可以混合使用:
- noul:是/否判定,返回答案为“是”的概率。
- choice:从你定义的选项集合中选择其一,返回选中项及完整概率分布。
- score:按你定义的分级标准打分,返回跨各分级的概率加权分值。
- box:定位图片中的一个目标,返回边界框坐标。
文本和结构化数据使用 application/json;上传图片使用 multipart/form-data,将 JSON 参数放在 request 分段中,图片作为独立文件分段上传。
请求头
Authorization string *
Bearer Token 鉴权,格式为 Bearer $ZENMUX_API_KEY。
Content-Type string *
文本请求为 application/json;图片上传为 multipart/form-data; boundary=...。
请求参数
将以下参数直接放入 JSON 请求体,适用于文本和结构化数据评估。上传图片请切换到 multipart/form-data。
model string *
要使用的模型 ID,格式为 <provider>/<model-name>,例如 typesafe/jev-latest。
state string、object 或 array *
待评估的内容。可以是纯文本 string,也可以是结构化数据(object / array),例如对话记录、业务记录或应用当前状态。
questions object *
一个非空的类型化问题映射(map)。key 由你自行指定,返回的答案会以相同的 key 归位。key 不会传递给底层模型,也不参与推理。
questions.<question-id> object *
一个类型化问题对象,使用 type 指定类型、instructions 描述任务。criteria 的要求取决于类型。
type string *
问题类型,取值为 noul、choice、score 或 box。
instructions string、object 或 array *
该问题需要模型判断的内容。
criteria object 或 array 视类型而定
评判标准,其形态取决于 type:
noul(可选):object,用true/false分别描述“是”和“否”的含义。choice(必填):object,将每个选项映射到对应的评判说明;无需额外说明时可置为null。score(必填):有序array,按顺序描述各分级;至少包含两个分级。box:不使用criteria。
响应
返回包含结构化答案的 JSON 对象。
model string
执行本次评估所使用的模型名称。
answers object
答案映射,key 与请求中 questions 使用的 key 相同,每个问题对应一个答案。
answers.<question-id> object
与该问题 type 匹配的答案对象。choice 与 score 的 confidence(0 到 1)由答案的概率分布推导得出;Box 的 confidence 说明模型对定位结果的确信程度。
- noul 答案
typestring— 固定为noul。noulnumber— 是/否答案,取值范围 0(否)到 1(是)。
- choice 答案
typestring— 固定为choice。choicestring— 概率最高的选项。probabilitiesobject— 每个选项到其概率的映射(各项之和为 1)。confidencenumber— 模型的确信度,由概率分布推导得出。
- score 答案
typestring— 固定为score。scorenumber— 跨各分级的概率加权分值,可能落在分级之间。legendobject— 各分级序号到其描述的映射。probabilitiesobject— 各分级(字符串 key)到其概率的映射(各项之和为 1)。confidencenumber— 模型的确信度,由概率分布推导得出。
- box 答案
typestring— 固定为box。boxobject— 包含top、bottom、left、right四条边,均为 0–1 的归一化坐标。confidencenumber | null— 0–1 的定位确信度;模型未提供时为null。
坐标以图片左上角为原点:top、bottom 是占图片高度的比例,left、right 是占图片宽度的比例。转换为像素时,横向坐标乘图片宽度,纵向坐标乘图片高度。
每道 Box 问题只返回一个框。即使目标不存在,Box 仍会返回坐标,没有“未找到”的专用结果。 建议同时询问一道 Noul 判断目标是否存在;存在概率较低时忽略 Box,不要仅凭返回框判断目标存在。置信度阈值应根据自己的图片样本确定。
usage object
本次请求的 Token 用量信息。
input_tokensinteger— 输入消耗的 Token 数。output_tokensinteger— 输出消耗的 Token 数。
图片用量包含在 input_tokens 中。价格以 ZenMux 模型目录 中的模型价格为准。
调用示例
示例提供 JSON 文本请求和图片上传两种用法。图片示例沿用 TypeSafe 的 request + 文件分段结构,同时询问 Noul 和 Box。准备符合上方尺寸限制、包含红色矩形的 photo.png,并设置环境变量 ZENMUX_API_KEY。TypeScript 图片示例使用 Node.js 20+ 的 fetch、FormData 和 Blob;Python 使用 requests。响应数值仅作示例,实际结果会变化。
curl /api/v1/systemone \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ZENMUX_API_KEY" \
-d '{
"model": "typesafe/jev-latest",
"state": "救命!我的账户回款已经连续 3 天失败了。",
"questions": {
"is_urgent": {
"type": "noul",
"instructions": "这段内容是否传达出紧迫感?"
},
"department": {
"type": "choice",
"instructions": "应由哪个团队来处理?",
"criteria": {
"billing": "支付、开票、退款",
"technical": "缺陷、故障、集成",
"sales": "定价、升级、新开户"
}
},
"frustration": {
"type": "score",
"instructions": "客户的不满程度如何?",
"criteria": ["平静", "不满", "非常愤怒"]
}
}
}'import requests
resp = requests.post(
"/api/v1/systemone",
headers={
"Authorization": "Bearer <your_ZENMUX_API_KEY>",
"Content-Type": "application/json",
},
json={
"model": "typesafe/jev-latest",
"state": "救命!我的账户回款已经连续 3 天失败了。",
"questions": {
"is_urgent": {
"type": "noul",
"instructions": "这段内容是否传达出紧迫感?",
},
"department": {
"type": "choice",
"instructions": "应由哪个团队来处理?",
"criteria": {
"billing": "支付、开票、退款",
"technical": "缺陷、故障、集成",
"sales": "定价、升级、新开户",
},
},
"frustration": {
"type": "score",
"instructions": "客户的不满程度如何?",
"criteria": ["平静", "不满", "非常愤怒"],
},
},
},
)
print(resp.json())const resp = await fetch("/api/v1/systemone", {
method: "POST",
headers: {
Authorization: "Bearer <ZENMUX_API_KEY>",
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "typesafe/jev-latest",
state: "救命!我的账户回款已经连续 3 天失败了。",
questions: {
is_urgent: {
type: "noul",
instructions: "这段内容是否传达出紧迫感?",
},
department: {
type: "choice",
instructions: "应由哪个团队来处理?",
criteria: {
billing: "支付、开票、退款",
technical: "缺陷、故障、集成",
sales: "定价、升级、新开户",
},
},
frustration: {
type: "score",
instructions: "客户的不满程度如何?",
criteria: ["平静", "不满", "非常愤怒"],
},
},
}),
});
console.log(await resp.json());{
"model": "typesafe/jev-latest",
"answers": {
"is_urgent": {
"type": "noul",
"noul": 0.92
},
"department": {
"type": "choice",
"choice": "technical",
"probabilities": { "billing": 0.08, "technical": 0.85, "sales": 0.07 },
"confidence": 0.82
},
"frustration": {
"type": "score",
"score": 1.6,
"legend": { "0": "平静", "1": "不满", "2": "非常愤怒" },
"probabilities": { "0": 0.05, "1": 0.3, "2": 0.65 },
"confidence": 0.78
}
},
"usage": { "input_tokens": 312, "output_tokens": 48 }
}curl /api/v1/systemone \
-H "Authorization: Bearer $ZENMUX_API_KEY" \
-F 'request={
"model": "typesafe/jev-1.14",
"state": {
"photo": "0b719304-319a-4f83-a84e-55a9fb3e16b8"
},
"assets": {
"0b719304-319a-4f83-a84e-55a9fb3e16b8": {
"type": "image",
"part": "photo-file"
}
},
"questions": {
"has_red_rectangle": {
"type": "noul",
"instructions": "Does the image in `photo` contain a red rectangle?"
},
"red_rectangle_location": {
"type": "box",
"instructions": "the red rectangle in `photo`"
}
}
};type=application/json' \
-F '[email protected];type=image/png'import json
import os
import requests
body = {
"model": "typesafe/jev-1.14",
"state": {
"photo": "0b719304-319a-4f83-a84e-55a9fb3e16b8"
},
"assets": {
"0b719304-319a-4f83-a84e-55a9fb3e16b8": {
"type": "image",
"part": "photo-file"
}
},
"questions": {
"has_red_rectangle": {
"type": "noul",
"instructions": "Does the image in `photo` contain a red rectangle?"
},
"red_rectangle_location": {
"type": "box",
"instructions": "the red rectangle in `photo`"
}
}
}
with open("photo.png", "rb") as image:
resp = requests.post(
"/api/v1/systemone",
headers={"Authorization": f"Bearer {os.environ['ZENMUX_API_KEY']}"},
files=[
("request", (None, json.dumps(body), "application/json")),
("photo-file", ("photo.png", image, "image/png")),
],
timeout=60,
)
resp.raise_for_status()
print(resp.json())import { readFile } from "node:fs/promises";
const body = {
"model": "typesafe/jev-1.14",
"state": {
"photo": "0b719304-319a-4f83-a84e-55a9fb3e16b8"
},
"assets": {
"0b719304-319a-4f83-a84e-55a9fb3e16b8": {
"type": "image",
"part": "photo-file"
}
},
"questions": {
"has_red_rectangle": {
"type": "noul",
"instructions": "Does the image in `photo` contain a red rectangle?"
},
"red_rectangle_location": {
"type": "box",
"instructions": "the red rectangle in `photo`"
}
}
};
const form = new FormData();
form.append(
"request",
new Blob([JSON.stringify(body)], { type: "application/json" }),
"request.json",
);
form.append(
"photo-file",
new Blob([await readFile("photo.png")], { type: "image/png" }),
"photo.png",
);
const resp = await fetch("/api/v1/systemone", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.ZENMUX_API_KEY}` },
body: form,
});
if (!resp.ok) {
throw new Error(`HTTP ${resp.status}: ${await resp.text()}`);
}
console.log(await resp.json());{
"model": "typesafe/jev-1.14",
"answers": {
"has_red_rectangle": {
"type": "noul",
"noul": 0.98
},
"red_rectangle_location": {
"type": "box",
"box": {
"top": 0.26,
"bottom": 0.74,
"left": 0.22,
"right": 0.78
},
"confidence": 0.94
}
},
"usage": {
"input_tokens": 1162,
"output_tokens": 40
}
}