Skip to main content

Decision Model API

Call POST /compatible-mode/v1/systemone to use the Bailian decision model (decision-model-preview), which returns classification, scoring, and yes/no decisions with full probability distributions and confidence in a single forward pass, without generating text. Suitable for high-frequency structured decisions such as ticket routing, content moderation, agent routing, and result verification.

Prerequisites

You have created an API Key and set it as the environment variable DASHSCOPE_API_KEY. For more information, see Configure an API key in environment variables.

Request

Protocol: TypeSafe System One (POST /compatible-mode/v1/systemone) A single request carries the business state and several typed questions (choice / noul / score). The model returns the decision result and probability distribution for each question in one forward pass, with choice and score additionally returning confidence, and does not generate text, so latency and cost are independent of output length. Endpoint Replace {WorkspaceId} with your workspace ID. See Regions and endpoints.

Region

Endpoint

Singapore

https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/systemone

China (Beijing)

https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/systemone

Request Parameters

Content-Type · String · Header · RequiredRequest type: application/json.Authorization · String · Header · RequiredAPI key, in the format: Bearer $DASHSCOPE_API_KEY.model · String · Body · RequiredModel name: decision-model-preview.state · String / Object / Array · Body · RequiredThe 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 · RequiredA map of questions. The key is a caller-defined question id; the value is a question object with the following fields.
type · String · RequiredQuestion type:
  • choice: single choice
  • noul: yes/no
  • score: ordinal scale
instructions · String · OptionalQuestion 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 routing
  • Yes/no decision
A single request handles three decisions at once: team assignment (choice), escalation (noul), and severity (score). The example below uses the Singapore region.
  • DashScope Python
  • DashScope Java
  • TypeSafe Python
  • curl
import os

import dashscope

# The following is the configuration for the Singapore 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="ap-southeast-1",
)

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)

Response Parameters

model · StringModel name echoed back.request_id · StringRequest ID, for troubleshooting.answers · ObjectA map of answers. The key corresponds to the question id in the request; the value is an answer object with the following fields.
type · StringMatches the question type (choice / noul / score).choice · StringFor choice: the selected option name.noul · FloatFor noul: P(yes), where 0 = no and 1 = yes.score · FloatFor score: the probability-weighted expectation of the level index, which can fall between two levels (e.g. 1.43).probabilities · ObjectThe probability of each option / level (sums to 1).confidence · FloatThe confidence of the answer (returned for choice / score).legend · ObjectFor score: a map of level index → level description.
usage · ObjectMetering information:
  • input_tokens (Integer): number of input tokens.
latency_ms · FloatServer-side latency (milliseconds).

Response Example

The following is the response for the ticket routing example (abbreviated). Probabilities and confidence depend on the actual result.
{
  "model": "decision-model-preview",
  "request_id": "7b986c65-b223-9341-b5f0-b988e27ecaac",
  "answers": {
    "department": {
      "type": "choice",
      "choice": "billing",
      "confidence": 0.88,
      "probabilities": {"billing": 0.94, "technical": 0.06}
    },
    "escalate": {
      "type": "noul",
      "noul": 0.99
    },
    "severity": {
      "type": "score",
      "score": 2.25,
      "confidence": 0.91,
      "legend": {
        "0": "Minor issue, no impact on functionality",
        "1": "Some functionality affected, but a workaround exists",
        "2": "Core functionality unavailable, no workaround",
        "3": "Severe business or security impact"
      },
      "probabilities": {"0": 0.0, "1": 0.01, "2": 0.73, "3": 0.26}
    }
  },
  "usage": {"input_tokens": 125},
  "latency_ms": 52.9
}

Error Codes

If the call fails, an error message is returned. For more error codes and solutions, see Error messages.