决策模型使用 System One 原生协议,根据结构化状态一次回答一个或多个分类、评分或开放式问题。
端点与鉴权
| 项 | 值 |
|---|---|
| 请求端点 | POST https://routerbrain.ai/decision/v1/systemone |
| 鉴权 | Authorization: Bearer <API-Key> |
| Content-Type | application/json |
| 响应模式 | 同步 JSON,不支持流式 |
模型代号可在 决策模型目录 中查看。
快速示例
curl -X POST https://routerbrain.ai/decision/v1/systemone \
-H 'Authorization: Bearer sk-xxxxxxxx' \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: order-review-20260930-001' \
-d '{
"model": "jev",
"state": {
"order": { "amount": 1280, "currency": "CNY" },
"customer": { "risk_level": "medium" }
},
"questions": {
"review": {
"type": "choice",
"instructions": "Decide whether this order can be approved.",
"criteria": {
"approve": "Approve when the risk is acceptable.",
"reject": "Reject when the risk is unacceptable."
}
}
}
}'
请求体
| 字段 | 类型 | 必需 | 说明 |
|---|---|---|---|
model | string | ✅ | 决策模型代号,最长 128 个字符。 |
state | null | string | object | array | ✅ | 供模型判断的业务状态。 |
questions | object | ✅ | 1~32 个问题;键为问题 ID,非空且最长 128 个字符。 |
session_id | string | ❌ | 缓存亲和会话标识,最长 256 个字符;只用于平台选路,不透传上游。 |
除上述平台字段外,请求中的 System One 扩展字段会按原协议透传。请求体上限为 64 KB。
问题类型
每个问题都必须包含 type,可选包含 instructions。支持以下类型:
type | criteria | 用途 |
|---|---|---|
choice | 对象,包含 1~255 个选项 | 从命名选项中选择结果;选项名非空且最长 128 个字符。 |
score | 数组,包含 2~10 个等级 | 在有序等级中评分。 |
noul | 可省略、为 null 或对象 | 返回开放式、非受限答案。类型名必须写为 noul。 |
成功响应
网关保留上游 System One 响应。成功响应至少包含:
{
"model": "<resolved-upstream-model>",
"answers": {
"review": { "...": "System One answer fields" }
},
"usage": {
"input_tokens": 123,
"output_tokens": 18
}
}
answers 中每个答案的内部字段由实际 System One 模型返回;调用方应按所用模型的协议处理,不要假定为固定结构。usage 用于计费,输入和输出 Token 单价可在决策模型目录查看。
可选请求头
| 请求头 | 说明 |
|---|---|
Idempotency-Key | 最长 255 个字符。重试同一业务请求时使用稳定值;网关会派生上游幂等键,但不会缓存或重放响应。 |
x-session-id | 缓存亲和会话标识;仅在请求体未提供 session_id 时使用。 |
x-trace-id | 业务追踪 ID,写入调用与用量记录。 |
x-user-id | 你们产品中的终端用户 ID。 |
x-agent-name | 调用方 Agent 或服务名。 |
错误响应
错误使用 OpenAI 风格的统一结构:
{
"error": {
"message": "model is required and must not exceed 128 characters",
"type": "invalid_request_error",
"param": null,
"code": null
}
}
| HTTP 状态 | 含义 |
|---|---|
400 | JSON 格式或请求体解析失败。 |
401 | 缺少、格式错误或无效的 API Key。 |
422 | state、model、questions、问题类型、幂等键或会话标识校验失败。 |
502 | 所有可用上游线路失败,或上游响应格式无效。 |