对 `state` 按 `questions` 逐项评估,返回每个问题的结构化答案与 token 用量。
**注意**:响应的 `model` 字段是平台模型名,与请求中的 `model` 一致。
请求体 · 必填
application/json
| 字段 | 类型 | 说明 |
|---|
model必填 | string | 平台模型名。 |
state必填 | union | 待评估内容。纯文本传字符串;结构化数据(工单状态、聊天记录等)传对象或数组。展开结构待评估内容。纯文本传字符串;结构化数据(工单状态、聊天记录等)传对象或数组。 union
oneOf · 1oneOf · 2oneOf · 3 |
questions必填 | object | 问题映射。key 由调用方自取,答案按同名 key 返回;key 不下发给模型、不参与推理。 |
auto_route | boolean | 平台侧路由开关(默认 true)。设为 false 时须同时给 `supplier`。**不会下发给上游**。 |
supplier | string | 指定供应商(匹配渠道的 provider_name,如 `TypeSafe` / `OpenRouter`)。**不会下发给上游**。 |
{
"model": "typesafe/jev-latest",
"state": "Help! My payouts have been failing for 3 days.",
"questions": {
"is_urgent": {
"type": "noul",
"instructions": "Does this message convey urgency?",
"criteria": {
"true": "Explicitly time-sensitive",
"false": "No urgency expressed"
}
},
"department": {
"type": "choice",
"instructions": "Which team should handle this?",
"criteria": {
"billing": "Payments, invoicing, refunds",
"technical": "Bugs, outages, integrations",
"sales": "Pricing, upgrades, new accounts"
}
},
"frustration": {
"type": "score",
"instructions": "How frustrated is the customer?",
"criteria": [
"Calm",
"Frustrated",
"Very angry"
]
}
}
}
请求示例
参考地址:https://router.shengsuanyun.com。路径参数与凭据需替换;非 JSON 请求体需按对应格式准备。
curl -X POST 'https://router.shengsuanyun.com/api/v1/decisions' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
--data '{
"model": "typesafe/jev-latest",
"state": "Help! My payouts have been failing for 3 days.",
"questions": {
"is_urgent": {
"type": "noul",
"instructions": "Does this message convey urgency?",
"criteria": {
"true": "Explicitly time-sensitive",
"false": "No urgency expressed"
}
},
"department": {
"type": "choice",
"instructions": "Which team should handle this?",
"criteria": {
"billing": "Payments, invoicing, refunds",
"technical": "Bugs, outages, integrations",
"sales": "Pricing, upgrades, new accounts"
}
},
"frustration": {
"type": "score",
"instructions": "How frustrated is the customer?",
"criteria": [
"Calm",
"Frustrated",
"Very angry"
]
}
}
}'
响应
200 评估成功
application/json
| 字段 | 类型 | 说明 |
|---|
model必填 | string | 平台模型名(与请求中的 `model` 一致)。 |
answers必填 | object | 每个问题一个答案,key 与请求的 `questions` 一致。 |
usage必填 | object | 本次请求的 token 用量(计费依据)。展开结构本次请求的 token 用量(计费依据)。 | 字段 | 类型 | 说明 |
|---|
input_tokens必填 | integer | | output_tokens必填 | integer | |
|
{
"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": "Calm",
"1": "Frustrated",
"2": "Very angry"
},
"probabilities": {
"0": 0.05,
"1": 0.3,
"2": 0.65
},
"confidence": 0.78
}
},
"usage": {
"input_tokens": 312,
"output_tokens": 48
}
}
400 请求不合法。可能原因:缺少 `model` / `state` / `questions`;`questions` 为空或不是对象;某问题的 `type` 不是 `noul`/`choice`/`score`;`score` 的 `criteria` 少于 2 档;传了 `stream: true`。
application/json
| 字段 | 类型 | 说明 |
|---|
error | object | 展开结构| 字段 | 类型 | 说明 |
|---|
message | string | 人类可读的错误说明。 | type | string | 错误大类,如 `invalid_request_error`。 | code | string | 机器可读错误码,如 `missing_required_field` / `validation_failed` / `invalid_json`。 |
|
{
"error": {
"message": "field state is required",
"type": "invalid_request_error",
"code": "missing_required_field"
}
}
401 未认证:平台 API Key 缺失或无效。
application/json
| 字段 | 类型 | 说明 |
|---|
error | object | 展开结构| 字段 | 类型 | 说明 |
|---|
message | string | 人类可读的错误说明。 | type | string | 错误大类,如 `invalid_request_error`。 | code | string | 机器可读错误码,如 `missing_required_field` / `validation_failed` / `invalid_json`。 |
|
{
"error": {
"message": "API Key 缺失或无效。请检查 Authorization 请求头(Bearer sk-...)。",
"type": "authentication_error",
"code": "invalid_api_key"
}
}
402 余额不足(预扣费阶段被拒)。
application/json
| 字段 | 类型 | 说明 |
|---|
error | object | 展开结构| 字段 | 类型 | 说明 |
|---|
message | string | 人类可读的错误说明。 | type | string | 错误大类,如 `invalid_request_error`。 | code | string | 机器可读错误码,如 `missing_required_field` / `validation_failed` / `invalid_json`。 |
|
{
"error": {
"message": "余额不足:预扣费阶段被拒绝,请充值后重试。",
"type": "insufficient_balance_error",
"code": "insufficient_balance"
}
}
404 模型不可用:模型未上架、渠道未绑定(`channel_models` 缺行)或该渠道的 `supported_apis` 未包含本接口。
application/json
| 字段 | 类型 | 说明 |
|---|
error | object | 展开结构| 字段 | 类型 | 说明 |
|---|
message | string | 人类可读的错误说明。 | type | string | 错误大类,如 `invalid_request_error`。 | code | string | 机器可读错误码,如 `missing_required_field` / `validation_failed` / `invalid_json`。 |
|
{
"error": {
"message": "模型不可用:模型未上架、渠道未绑定(channel_models 缺行)或该渠道的 supported_apis 未包含本接口。",
"type": "invalid_request_error",
"code": "model_not_found"
}
}
422 上游请求体校验失败(状态码原样透传)。
application/json
| 字段 | 类型 | 说明 |
|---|
error | object | 展开结构| 字段 | 类型 | 说明 |
|---|
message | string | 人类可读的错误说明。 | type | string | 错误大类,如 `invalid_request_error`。 | code | string | 机器可读错误码,如 `missing_required_field` / `validation_failed` / `invalid_json`。 |
|
{
"detail": {
"error_type": "validation_error",
"message": "Upstream request validation failed."
}
}
429 触发限流(平台或上游)。上游 429 会被识别为可重试,可能自动切换渠道。
application/json
| 字段 | 类型 | 说明 |
|---|
error | object | 展开结构| 字段 | 类型 | 说明 |
|---|
message | string | 人类可读的错误说明。 | type | string | 错误大类,如 `invalid_request_error`。 | code | string | 机器可读错误码,如 `missing_required_field` / `validation_failed` / `invalid_json`。 |
|
{
"error": {
"message": "触发限流(平台或上游)。上游 429 会被识别为可重试,可能自动切换渠道,请稍后重试。",
"type": "rate_limit_error",
"code": "rate_limit_exceeded"
}
}
502 上游不可用。
application/json
| 字段 | 类型 | 说明 |
|---|
error | object | 展开结构| 字段 | 类型 | 说明 |
|---|
message | string | 人类可读的错误说明。 | type | string | 错误大类,如 `invalid_request_error`。 | code | string | 机器可读错误码,如 `missing_required_field` / `validation_failed` / `invalid_json`。 |
|
{
"error": {
"message": "上游不可用,请稍后重试。",
"type": "upstream_error",
"code": "upstream_unavailable"
}
}
529 上游(TypeSafe)临时过载,可稍后重试。
application/json
| 字段 | 类型 | 说明 |
|---|
error | object | 展开结构| 字段 | 类型 | 说明 |
|---|
message | string | 人类可读的错误说明。 | type | string | 错误大类,如 `invalid_request_error`。 | code | string | 机器可读错误码,如 `missing_required_field` / `validation_failed` / `invalid_json`。 |
|
{
"error": {
"message": "上游临时过载,可稍后重试。",
"type": "overloaded_error",
"code": "upstream_overloaded"
}
}