列出和获取决策
GET /v1/decisions 和 GET /v1/decisions/{slug}——API 密钥所属工作区的决策及每个当前生效版本的契约——以及决策的 GPT-Live 委托及其回答端点。
GET https://api.dcision.io/v1/decisions
GET https://api.dcision.io/v1/decisions/{slug}这两个读取端点让集成——或通过 MCP 服务器的智能体——无需打开应用,就能知道有哪些决策、每个决策接受什么以及回答什么。它们只显示当前生效版本所公开的内容:从未部署过的草稿会被列出,但在你部署之前,它的 schema 保持私有。
二者使用与决策相同的 API 密钥,与 GET /v1/me 和 GET /v1/executions 共享读取速率限制窗口,且不计费。
另外两个端点将已部署的决策连接到 OpenAI 实时语音会话——参见 GPT-Live 委托。
列出决策
curl https://api.dcision.io/v1/decisions \
-H "Authorization: Bearer $DCISION_API_KEY"{
"data": [
{
"slug": "lead-qualification",
"name": "Lead Qualification",
"description": "Qualify inbound leads and route them to the right team.",
"status": "deployed",
"version": 3,
"updated_at": "2026-10-05T13:41:09.204Z"
},
{
"slug": "chat-triage",
"name": "Chat triage",
"description": null,
"status": "draft",
"version": null,
"updated_at": "2026-10-04T18:02:55.731Z"
}
]
}| 字段 | 类型 | 说明 |
|---|---|---|
data | array | 工作区的决策,最近更新的排在最前。 |
data[].slug | string | 决策的 slug——即其端点 POST /v1/decisions/{slug}。 |
data[].name | string | 决策的名称。 |
data[].description | string 或 null | 决策的描述。 |
data[].status | string | draft(从未部署)、deployed 或 disabled(端点已关闭)。 |
data[].version | integer 或 null | 当前生效的版本;草稿为 null。 |
data[].updated_at | string | 决策最后一次更改的时间,ISO 8601 格式。 |
只有 deployed 的决策可以运行:其他决策会返回 409 DECISION_NOT_DEPLOYED 或 409 DECISION_DISABLED。
获取决策
curl https://api.dcision.io/v1/decisions/lead-qualification \
-H "Authorization: Bearer $DCISION_API_KEY"{
"slug": "lead-qualification",
"name": "Lead Qualification",
"description": "Qualify inbound leads and route them to the right team.",
"status": "deployed",
"version": 3,
"state_schema": {
"type": "object",
"required": ["message"],
"properties": {
"message": { "type": "string", "description": "Inbound lead message" },
"company_size": { "type": "number", "description": "Employee count" },
"source": { "type": "string", "description": "website, referral, ads" }
}
},
"questions": [
{
"id": "purchase_intent",
"type": "probability",
"prompt": "Does this lead have real intent to buy in the next 30 days?",
"options": ["yes", "no"]
},
{
"id": "priority",
"type": "score",
"prompt": "How urgent is it to answer this lead?",
"options": ["low", "medium", "high", "critical"]
},
{
"id": "route",
"type": "choice",
"prompt": "Which team should receive this lead?",
"options": ["sales", "sdr", "nurture", "spam", "other"]
}
],
"composites": [
{ "id": "lead_score", "description": "0–1 ranking: intent counts double, priority adds, spam-like routes don't count" }
],
"actions": ["continue", "block", "escalate", "fallback"],
"fallback_action": "escalate",
"example_state": { "message": "<message>", "company_size": 1.5, "source": "<source>" }
}| 字段 | 类型 | 说明 |
|---|---|---|
slug | string | 决策的 slug。 |
name | string | 决策的名称。 |
description | string 或 null | 决策的描述。 |
status | string | draft、deployed 或 disabled。 |
version | integer 或 null | 当前生效的版本;草稿为 null。 |
state_schema | object 或 null | 当前生效版本接受的 state,以 JSON Schema 表示——即编辑器中的 API 契约:{ "type": "object", "required", "properties" };文本 state 为 { "type": "string" },列表 state 为 { "type": "array", "items" }。草稿为 null。 |
questions | array | 按顺序排列的问题。草稿为空。 |
questions[].id | string | 问题的键——即其回答在 result 和 confidence 中的键。 |
questions[].type | string | choice、score 或 probability。 |
questions[].prompt | string、object 或 array | 问题的指令,与 schema 中所写的一致。 |
questions[].options | array | 回答可能的取值:choice 问题的选项(包括 other);score 问题的等级标签,从低到高;probability 问题为 ["yes", "no"],其 result 是yes 的概率。 |
questions[].min_confidence | number | 仅当问题设置了 minConfidence 时出现:低于该值时适用 fallback 行动。 |
composites | array | 仅针对带有复合指标的决策:每个复合指标的 id 和 description。 |
actions | array | 响应可能携带的行动:continue、block、escalate 和 fallback。草稿为空。 |
fallback_action | string | 回答为 other 或置信度过低时的行动——参见策略与行动。草稿中不存在。 |
example_state | any | 一个结构正确的占位 state——字符串为 <field>、数字为 1.5、整数为 1——可以从它开始。运行前请替换这些值。草稿为 null。 |
草稿会返回 200,其中 version、state_schema 和 example_state 为 null,questions 和 actions 为空。策略、目的地、设置和决策的 context 永远不会返回。
错误
| 状态 | 代码 | 何时 |
|---|---|---|
| 401 | INVALID_API_KEY | 密钥缺失、格式错误、未知或已撤销。 |
| 404 | DECISION_NOT_FOUND | 密钥所属工作区中没有使用此 slug 的决策,或 slug 格式错误。 |
| 429 | RATE_LIMITED | 当前分钟内的读取请求过多。 |
密钥只能看到其所属工作区的决策。
GPT-Live 委托
GET https://api.dcision.io/v1/decisions/{slug}/openai-live
POST https://api.dcision.io/v1/decisions/{slug}/openai-live/answersGPT-Live 会话(OpenAI 实时语音)可以在用户说话时向 OpenAI Decisions 提出带类型的问题。这两个端点让它提出你已部署决策的问题,并在这些回答上运行决策的策略、目的地和执行日志。GPT-Live 指南展示了完整流程。
导出委托
GET /v1/decisions/{slug}/openai-live 以 OpenAI Decisions 格式返回当前生效版本的问题,可直接作为 delegation 放入会话请求。它使用读取速率限制窗口,且不计费。
curl https://api.dcision.io/v1/decisions/lead-qualification/openai-live \
-H "Authorization: Bearer $DCISION_API_KEY"{
"decision": "lead-qualification",
"version": 3,
"delegation": {
"type": "decisions",
"model": "gpt-6-luna",
"questions": [
{
"type": "predicate",
"name": "purchase_intent",
"instructions": "Does this lead have real intent to buy in the next 30 days?\n\nTrue when: asks for pricing, a demo, a quote or a start date\nFalse when: just browsing, student, vendor or spam"
},
{
"type": "score",
"name": "priority",
"instructions": "How urgent is it to answer this lead?",
"levels": [{ "label": "low" }, { "label": "medium" }, { "label": "high" }, { "label": "critical" }]
},
{
"type": "choice",
"name": "route",
"instructions": "Which team should receive this lead?",
"choices": [
{ "value": "sales", "description": "high intent, ready to talk to sales" },
{ "value": "sdr", "description": "some intent, needs qualification" },
{ "value": "nurture", "description": "early stage, send content" },
{ "value": "spam", "description": "spam, vendor pitch or irrelevant" },
{ "value": "other", "description": "none of the options above" }
]
}
]
},
"answers_url": "/v1/decisions/lead-qualification/openai-live/answers"
}| 字段 | 类型 | 说明 |
|---|---|---|
decision | string | 决策的 slug。 |
version | integer | 问题所来自的当前生效版本。 |
delegation.type | string | 始终为 decisions。 |
delegation.model | string | OpenAI Decisions 模型,gpt-6-luna。 |
delegation.questions | array | 按顺序排列的问题,转换方式与 OpenAI Decisions 引擎相同:predicate(probability)、带 choices(value、description)的 choice,以及带 levels(label、description)的 score。每个问题都有 name——即问题的键——和 instructions。 |
answers_url | string | 回答的发送地址:POST /v1/decisions/{slug}/openai-live/answers 的路径。 |
只导出问题:决策的 context、策略和目的地都留在 Dcision 中。每次部署后请重新导出委托,让会话提出新版本的问题。
发送回答
POST /v1/decisions/{slug}/openai-live/answers 接收会话 decision.completed 事件中的 answers,并返回与 POST /v1/decisions/{slug} 相同的响应。不会调用任何引擎。
curl -X POST https://api.dcision.io/v1/decisions/lead-qualification/openai-live/answers \
-H "Authorization: Bearer $DCISION_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "model": "gpt-6-luna", "answers": [
{ "type": "predicate", "name": "purchase_intent", "probability": 0.92 },
{ "type": "score", "name": "priority", "score": 2.03, "probabilities": [
{ "value": 0, "label": "low", "probability": 0.02 }, { "value": 1, "label": "medium", "probability": 0.1 },
{ "value": 2, "label": "high", "probability": 0.71 }, { "value": 3, "label": "critical", "probability": 0.17 } ] },
{ "type": "choice", "name": "route", "choice": "sales", "probabilities": [
{ "value": "sales", "probability": 0.9 }, { "value": "sdr", "probability": 0.07 }, { "value": "other", "probability": 0.03 } ] }
] }'| 字段 | 类型 | 说明 |
|---|---|---|
answers | array | 必填,1 到 200 项:decision.completed 事件中的 answers,保持 OpenAI 发送时的原样——predicate、choice、score 或 refusal,每项都带有问题的 name。 |
model | string | 可选。作答的模型;缺省时为 gpt-6-luna。记录为 metrics.model。 |
usage | object | 可选。会话中该决策的 input_tokens 和 output_tokens,随执行一起记录。 |
state | any | 可选。供目的地和执行日志使用的上下文——例如通话期间应用的状态。发送时会根据决策的 state schema 进行校验。 |
?include=probabilities 会加入完整的分布,与运行决策相同。
{
"decision_id": "dec_3fKq9ZtW1mXcV7bN2pLa",
"execution_id": "exec_Lv7Qm2Xc9Tn4Rb8Wk1Pz",
"schema": "lead-qualification",
"version": 3,
"result": { "purchase_intent": 0.92, "priority": "high", "route": "sales" },
"confidence": { "purchase_intent": 0.84, "priority": 0.69, "route": 0.875 },
"scores": { "priority": 3.03 },
"composites": { "lead_score": 0.8542 },
"action": "continue",
"action_reason": { "type": "default" },
"metrics": {
"latency_ms": 38,
"engine": "openai",
"model": "gpt-6-luna",
"estimated_cost_usd": 0,
"input_tokens": 0,
"output_tokens": 0
}
}- 与运行相同的规则。策略、拒绝回答、
other和minConfidence检查、复合指标以及目的地都会在这些回答上运行;action和action_reason的含义与其他地方相同。 - 按运行计费。每次调用都计入套餐包含的决策数,超出后使用额度。
metrics.estimated_cost_usd为0:OpenAI 已经为 Live 会话计费。 - 记录为一次执行,来源为 API,引擎为
openai,凭据为 live——它会显示在执行记录、决策的概览和GET /v1/executions中。 - 它使用决策的速率限制窗口。不支持
Idempotency-Key:重试的调用会再次运行——并再次计费。
GPT-Live 端点的错误
| 状态 | 代码 | 何时 |
|---|---|---|
| 400 | INVALID_REQUEST | 没有 answers、超过 200 项,或回答与已部署的问题不匹配——缺少某个问题、choice 不是可选项之一、回答类型错误。 |
| 401 | INVALID_API_KEY | 密钥缺失、格式错误、未知或已撤销。 |
| 402 | CREDITS_EXHAUSTED、SPEND_CAP_REACHED、QUOTA_EXCEEDED | 仅限回答端点,与运行决策相同。 |
| 404 | DECISION_NOT_FOUND | 密钥所属工作区中没有使用此 slug 的决策。 |
| 409 | DECISION_NOT_DEPLOYED | 该决策从未部署过。对于已禁用的端点,回答端点还会返回 DECISION_DISABLED。 |
| 422 | INVALID_STATE | 仅限回答端点:可选的 state 与 state schema 不匹配。 |
| 429 | RATE_LIMITED | 当前分钟内的请求过多。 |