Request Parameters Content-Type · String · Header · Required Request type: application/json. Authorization · String · Header · Required API key, in the format: Bearer $DASHSCOPE_API_KEY. model · String · Body · Required Model name: decision-model-preview. state · String / Object / Array · Body · Required The business state to make decisions on: ticket text, a conversation, or a structured object (objects are serialized before being sent to the model). questions · Object · Body · Required A map of questions. The key is a caller-defined question id; the value is a question object with the following fields. Question object properties type · String · Required Question type:
choice: single choice
noul: yes/no
score: ordinal scale
instructions · String · Optional Question description or judgment criteria. criteria · Object / Array · Depends on type
choice: a map of option name → option description (1–255 items; providing all options and an other fallback is recommended).
noul: optional {"true":…, "false":…} descriptions.
score: an array of level descriptions from low to high (2–255 levels; 3–7 clearly distinguishable levels recommended).
Limits and recommendations
- Maximum 16 questions (latency grows near-linearly with the number of questions).
choice options: ≤ 255.
score levels: 2–255 (3–7 recommended).
- Context: maximum 65536 tokens; overlong
state is rejected.
| Request Examples The DashScope SDKs already support the decision model (compatible with the TypeSafe System One protocol):
- Python: DashScope SDK 2.0.1 or later. The decision model is new in 2.0.1 — older versions do not have the
client.decision interface and raise an AttributeError. Install: pip install -U "dashscope>=2.0.1". See Install the SDK. The SDK derives the /compatible-mode/v1/systemone endpoint from your workspace and region automatically.
- Java: DashScope SDK 2.23.3 or later. The decision model is new in 2.23.3 — older versions do not have the
com.alibaba.dashscope.decision package. Maven coordinates: com.alibaba:dashscope-sdk-java:2.23.3 (Gradle: implementation group: 'com.alibaba', name: 'dashscope-sdk-java', version: '2.23.3'). The API key is read from the DASHSCOPE_API_KEY environment variable by default.
- On failure, the Python SDK raises a
DashScopeError exception and the Java SDK raises an ApiException.
You can also use the generic TypeSafe SDK (typesafe-sdk) with base_url pointing to the Bailian gateway. The SDK automatically appends /v1/systemone and parses the response. Install: pip install typesafe-sdk. Ticket routingA single request handles three decisions at once: team assignment (choice), escalation (noul), and severity (score). The example below uses the China (Beijing) region. DashScope Pythonimport os
import dashscope
# The following is the configuration for the China (Beijing) region. Replace "{WorkspaceId}" with your actual workspace ID. The configuration differs by region.
# The decision model endpoint always sits under the compatible-mode path of the workspace gateway; the SDK derives it from workspace and region.
client = dashscope.Client(
# If you have not configured an environment variable, replace the following line with your Model Studio API key: api_key="sk-xxx"
api_key=os.getenv("DASHSCOPE_API_KEY"),
workspace="{WorkspaceId}",
region="cn-beijing",
)
result = client.decision.create(
model="decision-model-preview",
state={"ticket_id": "T-1001", "content": "More than 24 hours after payment, the order has not been credited."},
questions={
"department": {"type": "choice", "instructions": "Which team should handle this?",
"criteria": {"billing": "Payment, refund, and billing issues", "technical": "Product failure and integration issues"}},
"escalate": {"type": "noul", "instructions": "Should on-call staff be notified immediately?"},
"severity": {"type": "score", "instructions": "How severe is this issue?",
"criteria": ["Minor issue, no impact on functionality", "Some functionality affected, but a workaround exists",
"Core functionality unavailable, no workaround", "Severe business or security impact"]},
},
)
print(result.answers["department"].choice) # selected option
print(result.answers["escalate"].noul) # P(yes)
print(result.answers["severity"].score) # probability-weighted level index
print(result.usage.input_tokens, result.latency_ms)
DashScope Javaimport com.alibaba.dashscope.decision.DecisionModel;
import com.alibaba.dashscope.decision.DecisionModelParam;
import com.alibaba.dashscope.decision.DecisionModelResult;
import com.alibaba.dashscope.decision.DecisionQuestion;
import com.alibaba.dashscope.utils.JsonUtils;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public class DecisionDemo {
public static void main(String[] args) throws Exception {
// The API key is read from the DASHSCOPE_API_KEY environment variable by default.
// The constructor takes the workspace ID and region; the SDK derives
// https://{WorkspaceId}.{region}.maas.aliyuncs.com/compatible-mode/v1/systemone
Map<String, Object> state = new HashMap<>();
state.put("ticket_id", "T-1001");
state.put("content", "More than 24 hours after payment, the order has not been credited. The user cannot continue using core services and demands immediate handling.");
Map<String, String> options = new LinkedHashMap<>();
options.put("billing", "Payment, refund, and billing issues");
options.put("technical", "Product failure and integration issues");
List<String> levels = Arrays.asList(
"Minor issue, no impact on functionality",
"Some functionality affected, but a workaround exists",
"Core functionality unavailable, no workaround",
"Severe business or security impact");
Map<String, DecisionQuestion> questions = new LinkedHashMap<>();
questions.put("department", DecisionQuestion.choice("Which team should handle this?", options));
questions.put("escalate", DecisionQuestion.noul("Should on-call staff be notified immediately?"));
questions.put("severity", DecisionQuestion.score("How severe is this issue?", levels));
DecisionModelParam param = DecisionModelParam.builder()
.model(DecisionModelParam.Models.DECISION_MODEL_PREVIEW)
.state(state)
.questions(questions)
.build();
DecisionModel decisionModel = new DecisionModel("{WorkspaceId}", "cn-beijing");
DecisionModelResult result = decisionModel.call(param);
System.out.println(JsonUtils.toJson(result));
}
}
TypeSafe Pythonimport os
from typesafe_sdk import TypeSafeClient
client = TypeSafeClient(
api_key=os.environ["DASHSCOPE_API_KEY"],
base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode",
)
result = client.system_one(
model="decision-model-preview",
state={"ticket_id": "T-1001", "content": "More than 24 hours after payment, the order has not been credited."},
questions={
"department": {"type": "choice", "instructions": "Which team should handle this?",
"criteria": {"billing": "Payment, refund, and billing issues", "technical": "Product failure and integration issues"}},
"escalate": {"type": "noul", "instructions": "Should on-call staff be notified immediately?"},
"severity": {"type": "score", "instructions": "How severe is this issue?",
"criteria": ["Minor issue, no impact on functionality", "Some functionality affected, but a workaround exists",
"Core functionality unavailable, no workaround", "Severe business or security impact"]},
},
)
print(result.answers["department"]) # choice, confidence, probabilities
print(result.answers["escalate"]) # noul P(yes)
print(result.answers["severity"]) # score, legend, probabilities
curlcurl -sS -X POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/systemone \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "decision-model-preview",
"state": {"ticket_id": "T-1001", "content": "More than 24 hours after payment, the order has not been credited. The user cannot continue using core services and demands immediate handling."},
"questions": {
"department": {"type": "choice", "instructions": "Which team should handle this?",
"criteria": {"billing": "Payment, refund, and billing issues", "technical": "Product failure and integration issues"}},
"escalate": {"type": "noul", "instructions": "Should on-call staff be notified immediately?"},
"severity": {"type": "score", "instructions": "How severe is this issue?",
"criteria": ["Minor issue, no impact on functionality", "Some functionality affected, but a workaround exists",
"Core functionality unavailable, no workaround", "Severe business or security impact"]}
}
}'
Yes/no decisionA noul question returns P(yes), where 0 = no and 1 = yes. The example below uses the China (Beijing) region. DashScope Pythonimport os
import dashscope
client = dashscope.Client(
# If you have not configured an environment variable, replace the following line with your Model Studio API key: api_key="sk-xxx"
api_key=os.getenv("DASHSCOPE_API_KEY"),
workspace="{WorkspaceId}",
region="cn-beijing",
)
result = client.decision.create(
model="decision-model-preview",
state="Is this comment asking for a refund?",
questions={"refund": {"type": "noul", "instructions": "Is the user asking for a refund?"}},
)
print(result.answers["refund"].noul) # P(yes)
DashScope Javaimport com.alibaba.dashscope.decision.DecisionModel;
import com.alibaba.dashscope.decision.DecisionModelParam;
import com.alibaba.dashscope.decision.DecisionModelResult;
import com.alibaba.dashscope.decision.DecisionQuestion;
import java.util.LinkedHashMap;
import java.util.Map;
public class DecisionDemo {
public static void main(String[] args) throws Exception {
Map<String, DecisionQuestion> questions = new LinkedHashMap<>();
questions.put("refund", DecisionQuestion.noul("Is the user asking for a refund?"));
DecisionModelParam param = DecisionModelParam.builder()
.model(DecisionModelParam.Models.DECISION_MODEL_PREVIEW)
.state("Is this comment asking for a refund?")
.questions(questions)
.build();
DecisionModel decisionModel = new DecisionModel("{WorkspaceId}", "cn-beijing");
DecisionModelResult result = decisionModel.call(param);
System.out.println(result.getAnswers().get("refund").getNoul()); // P(yes)
}
}
TypeSafe Pythonimport os
from typesafe_sdk import TypeSafeClient
client = TypeSafeClient(
api_key=os.environ["DASHSCOPE_API_KEY"],
base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode",
)
result = client.system_one(
model="decision-model-preview",
state="Is this comment asking for a refund?",
questions={"refund": {"type": "noul", "instructions": "Is the user asking for a refund?"}},
)
print(result.answers["refund"]) # noul P(yes)
curlcurl -sS -X POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/systemone \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "decision-model-preview",
"state": "Is this comment asking for a refund?",
"questions": {
"refund": {"type": "noul", "instructions": "Is the user asking for a refund?"}
}
}'
|