对 `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`)。**不会下发给上游**。 |
images | array | 待评估的图片,最多 8 张。图片会被放在 `state` 之前、按你发送的顺序排列,因此 `state` 可以写「第一张是维修前,第二张是维修后」这类指代。
每张约 280 input tokens(与尺寸无关)。建议先缩到长边约 1024 像素并转 JPEG,这样请求更小更快。
不支持与 `think` / `sequential` 同时使用(会返回 422)。展开结构待评估的图片,最多 8 张。图片会被放在 `state` 之前、按你发送的顺序排列,因此 `state` 可以写「第一张是维修前,第二张是维修后」这类指代。
每张约 280 input tokens(与尺寸无关)。建议先缩到长边约 1024 像素并转 JPEG,这样请求更小更快。
不支持与 `think` / `sequential` 同时使用(会返回 422)。 array
数组元素一张待评估的图片。两种形态二选一:data URL 字符串,或 `{content_type, base64}` 对象。
支持 JPEG / PNG / WebP / GIF(GIF 只取第一帧),单张最大 5 MB(base64 解码后)。 union
oneOf · 1oneOf · 2对象形态:显式给出 MIME 类型与 base64 字节。 | 字段 | 类型 | 说明 |
|---|
content_type必填 | string | 图片 MIME 类型,如 `image/png`。 | base64必填 | string | 图片的 base64 编码字节(不含 data URL 前缀)。 |
|
steps | integer | 去噪步数(每次读取的 denoise steps),1~8,默认 1。可与 `images` 同用。 |
samples | integer | 重复读取次数:读 1~32 次(每次用不同噪声)并对结果取平均,用于降低方差。
**每次读取都会计费**,因此该值会成倍放大实际用量。可与 `images` 同用。 |
think | integer | 思考预算(token),0~4096,是**硬上限**。
设置后上游会返回非 0 的 `usage.output_tokens`(thought 的长度),并计入计费。
需要纯文本 `state`,不能与 `images` 同用(会返回 422)。 |
sequential | boolean | 按问题分块顺序读取:每块能看到先前块的答案。
需要纯文本 `state`,不能与 `images` 同用(会返回 422)。 |
{
"model": "codiv/openjev-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": "codiv/openjev-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": "codiv/openjev-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~10;`choice` 的选项数超过 128;`images` 超过 8 张或形态非法(非 data URL / 非 `{content_type, base64}` 对象);`steps` 不在 1~8;`samples` 不在 1~32;`think` 不在 0~4096;传了 `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 上游请求体校验失败(状态码原样透传)。常见于扩展字段的组合约束:`think` 或 `sequential` 与 `images` 同时使用、图片格式不被支持、单图超过 5 MB 等。上游的错误体形如 `{"detail": {"error_type", "message"}}`。
application/json
| 字段 | 类型 | 说明 |
|---|
error | object | 展开结构| 字段 | 类型 | 说明 |
|---|
message | string | 人类可读的错误说明。 | type | string | 错误大类,如 `invalid_request_error`。 | code | string | 机器可读错误码,如 `missing_required_field` / `validation_failed` / `invalid_json`。 |
|
{
"detail": {
"error_type": "conflicting_parameters",
"message": "think cannot be used together with images."
}
}
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"
}
}