POST /v1/decisions
Question Type | Fill Method | Description |
Category selection | type=choice | Select a category from the given candidates and return information such as candidate probabilities. |
Ordered scoring | type=score | Evaluate the status based on the given ordered levels and return information such as scores. |
Proposition judgment | type=noul | Evaluate the validity of a proposition and typically return a value between 0 - 1. |
Scenario | Recommended Question Type | Access Mode |
Customer Service Ticket Routing | choice | Use the ticket as the state, use team identifiers as candidates, and assign the ticket to the processing team based on choice. |
User Intent Classification | choice | Provide clear intent candidates. When unhandled intents need to be covered, explicitly define other categories in criteria. |
Ticket Urgency Assessment | noul | Define the meaning of "requires priority handling", and set the noul threshold based on business evaluation. |
Emotion, Satisfaction, or Priority Assessment | score | Use ordered criteria levels, and process results by combining score, legend, and probability distribution. |
Conditional Judgment in Agent Workflow | choice / noul | Evaluate the task status, and determine the subsequent processing branch or whether manual intervention is required. |
Multidimensional Assessment of the Same Business Status | Mixed type | Submit multiple questions with independent identifiers at a time, for example, identify the team, dissatisfaction level, and urgency level simultaneously. |
cmr-decisions as an example logical model name. Replace it with the name actually configured in the console before making calls. Upstream access credentials are configured on the server side, and clients use a CMR API Key for calls.POST {CMR_BASE_URL}/v1/decisions
/v1/decisions, and all examples in this document use this path.Header | Required | Description |
Authorization | Yes | Bearer <CMR_API_KEY> |
Content-Type | Yes | Fixed as application/json |
curl --request POST "${CMR_BASE_URL}/v1/decisions" \\--header "Authorization: Bearer ${CMR_API_KEY}" \\--header "Content-Type: application/json" \\--data '{"model": "cmr-decisions","state": "My withdrawal has failed for three consecutive days. I must pay my supplier today. Please process it as soon as possible.","questions": {"is_urgent": {"type": "noul","instructions": "Does this ticket need to be handled with priority?"}}}'
import osimport requestsresponse = requests.post(f"{os.environ['CMR_BASE_URL'].rstrip('/')}/v1/decisions",headers={"Authorization": f"Bearer {os.environ['CMR_API_KEY']}","Content-Type": "application/json",},json={"model": "cmr-decisions","state": "My withdrawal has failed for three consecutive days. I must pay my supplier today. Please process it as soon as possible.","questions": {"is_urgent": {"type": "noul","instructions": "Does this ticket need to be handled with priority?",}},},timeout=30,)response.raise_for_status()result = response.json()print(result["answers"]["is_urgent"]["noul"])
Parameter | Type | Required | Description |
model | string | Yes | CMR logical model name or model alias. Available values are subject to the current instance configuration. |
state | string | object | array | Yes | Text, structured business data, or context list to be evaluated. null, numbers, or boolean values are not accepted as the top-level state. |
questions | object | Yes | A collection of questions. Keys are business-defined question identifiers, and values are question objects. |
questions, question types, the number of candidates, and state length are validated by the upstream model. The gateway accepting the top-level types does not mean that the upstream will accept the entire request. The gateway top-level validation itself does not reject an empty string state, an empty array/object state, or empty questions. Whether these inputs are usable is determined by the upstream. For normal calls, it is recommended to submit a state and questions with actual business meaning.Parameter | Type | Required | Description |
questions.<question_id> | object | Yes | A question. question_id is a custom identifier, such as department or is_urgent. |
questions.<question_id>.type | string | Yes | Question type. Common values are choice, score, or noul. |
questions.<question_id>.instructions | string; object / array supported by the upstream can also be used. | Yes | Question description, judgment objectives, and rules; plain text is the easiest to integrate. |
questions.<question_id>.criteria | Depends on the question type | Fill in by type. | For choice, it is typically an object mapping candidate identifiers to descriptions; for score, it is typically an array of grades arranged in order; for noul, it can be omitted. |
{"model": "cmr-decisions","state": "My withdrawal has failed for three consecutive days. Please help me check the payment account.","questions": {"department": {"type": "choice","instructions": "Which team should handle this ticket?","criteria": {"billing": "Payment, billing, refund, and withdrawal issues","technical": "Program defects, service failures, and system integration issues","sales": "Product inquiries, purchasing, and contract issues"}}}}
{"model": "cmr-decisions","state": "I have reported this three times, but the issue remains unresolved, which is very disappointing.","questions": {"frustration": {"type": "score","instructions": "Assess the customer's dissatisfaction level and rate it from low to high according to the criteria.","criteria": ["Calm", "Somewhat dissatisfied", "Very dissatisfied"]}}}
{"model": "cmr-decisions","state": "Please process it immediately. The payment must be completed today.","questions": {"is_urgent": {"type": "noul","instructions": "Does the text express an urgent request that needs to be handled immediately?"}}}
{"model": "cmr-decisions","state": {"ticket": {"subject": "Withdrawal failed","message": "It has been failing for three days, and I must make the payment today. I am very dissatisfied."},"history": [{"role": "customer", "text": "I also reported this yesterday, but it is still unresolved."}]},"questions": {"department": {"type": "choice","instructions": "Select the team responsible for handling this ticket.","criteria": {"billing": "Payment, billing, and withdrawal issues","technical": "Program defects and system failures","sales": "Purchasing and contract inquiries"}},"frustration": {"type": "score","instructions": "Assess the customer's dissatisfaction level from low to high.","criteria": ["Calm", "Somewhat dissatisfied", "Very dissatisfied"]},"is_urgent": {"type": "noul","instructions": "Does it need to be handled with priority?"}}}
{"model": "cmr-decisions","state": [{"role": "customer", "text": "The withdrawal failed."},{"role": "customer", "text": "It has been three days, and the payment must be made today."}],"questions": {"is_urgent": {"type": "noul", "instructions": "Based on the context, does it need to be handled with priority?"}}}
Parameter | Type | Returned or Not | Description |
id | string | Yes | Request tracing ID generated by the gateway, in the format of "dec-" plus a random identifier; the field with the same name from the upstream is not reused. |
model | string | Yes | Upstream model name retained after protocol translation, which may be a versioned name; when no valid name is returned, it falls back to the logical model name, which may differ from the model in the request. |
answers | object | Yes | Answer objects organized by question identifier; correspond to the questions in the request through answers.<question_id>. |
usage | object | No | Normalized Token usage. If not provided by the upstream or if usage is absent from the translation result, this field is not returned. |
Parameter | Type | Returned or Not | Description |
answers.<question_id>.type | string | Returned based on the upstream response. | Typically choice. |
answers.<question_id>.choice | string | Returned based on the upstream response. | Identifier of the selected option, typically corresponding to a key in the criteria of the request. |
answers.<question_id>.probabilities | object | Returned based on the upstream response. | Mapping of option identifiers to probabilities, typically between 0 - 1. |
answers.<question_id>.confidence | number | Returned based on the upstream response. | Confidence returned by the model. The specific meaning is subject to the model protocol. |
Parameter | Type | Returned or Not | Description |
answers.<question_id>.type | string | Returned based on the upstream response. | Usually score. |
answers.<question_id>.score | number | Returned based on the upstream response. | Scoring result, which may be a decimal. The value range and calculation method are subject to the selected model. |
answers.<question_id>.legend | object | No | Mapping from level numbers to level descriptions, typically using string values such as 0, 1, and 2 as keys. |
answers.<question_id>.probabilities | object | No | Mapping from level numbers to probabilities. |
answers.<question_id>.confidence | number | No | Confidence returned by the model. |
Parameter | Type | Returned or Not | Description |
answers.<question_id>.type | string | Returned based on the upstream response. | Usually noul. |
answers.<question_id>.noul | number | Returned based on the upstream response. | Usually a proposition validity degree between 0 - 1; a larger value indicates that the model is more inclined to consider the proposition true. |
Parameter | Type | Returned or Not | Description |
usage.prompt_tokens | integer | Returned when usage exists. | Number of input tokens. The TypeSafe built-in rule maps input_tokens to this field. |
usage.completion_tokens | integer | Returned when usage exists. | Number of output tokens. The TypeSafe built-in rule maps output_tokens to this field. |
usage.total_tokens | integer | Returned when usage exists. | Total number of tokens. If not provided in the translation result, this value is calculated by adding the input and output Token counts. |
{"id": "dec-7f3a2c1059814a62acb350be36a4d119","model": "typesafe/jev-1.13","answers": {"is_urgent": {"type": "noul", "noul": 0.96}},"usage": {"prompt_tokens": 120,"completion_tokens": 18,"total_tokens": 138}}
{"id": "dec-a1b2c3d456784abca9c81234567890de","model": "typesafe/jev-1.13","answers": {"department": {"type": "choice","choice": "billing","probabilities": {"billing": 0.89, "technical": 0.10, "sales": 0.01},"confidence": 0.83},"frustration": {"type": "score","score": 1.8,"legend": {"0": "Calm", "1": "Somewhat dissatisfied", "2": "Very dissatisfied"},"probabilities": {"0": 0.05, "1": 0.10, "2": 0.85},"confidence": 0.86},"is_urgent": {"type": "noul", "noul": 0.96}},"usage": {"prompt_tokens": 427,"completion_tokens": 73,"total_tokens": 500}}
{"id": "dec-9e8d7c6b54324d01aabbccddeeff0011","model": "typesafe/jev-1.13","answers": {"is_urgent": {"type": "noul", "noul": 0.78}}}
{"detail": {"code": "invalid_decisions_request","message": "Request does not match the CMR Decisions Standard","issues": [{"path": "/state", "reason": "missing"}]}}
Parameter | Description |
detail.code | Validation error identifier. For a standard request shape error, the value is invalid_decisions_request. |
detail.message | Error summary |
detail.issues[].path | JSON Pointer path of the issue field. For the request root object, use /. |
detail.issues[].reason | Reason, such as missing, object_required, or a type validation reason. |
{"error": {"message": "InternalServerError: {\\"error\\":\\"Upstream service is overloaded\\"}","type": null,"param": null,"code": "529"}}
Parameter | Description |
error.message | Error description, which may contain processed upstream diagnostic information. |
error.type | Error type, which can be a string or null and varies depending on the error source. Do not assume it is always a fixed string. |
error.param | Related parameter. It may be null or another placeholder value when no specific parameter is identified. |
error.code | Error code. It is currently common as an HTTP status code in string format. |
HTTP Status Code | Common Scenes | Recommendation |
400 | Invalid JSON format, request body is not an object, required field missing, standard field type error, invalid logical model name, or the upstream rejects the current parameter. | Correct the request instead of retrying blindly. |
401 | Gateway or upstream authentication failed, or the access credential is invalid or expired. | Check the CMR API Key and upstream credentials. |
403 | Missing required authentication information, invalid authentication header format, or no permission to access the target model or API. The specific status depends on the authentication configuration. | Check Authorization and model access permissions. |
404 | The upstream model, resource, or request path does not exist. | Check the upstream model and API path configuration. |
408 | Request or upstream call timeout. | Decide whether to retry based on the business time limit. |
422 | The upstream rejects the internal structure of questions, input length, or other model constraints. | Correct the parameters based on upstream diagnostics; the current implementation retains the 422 status code. |
429 | Gateway rate limiting, upstream quota exceeded, or no deployment currently available. | Use a backoff policy based on Retry-After (if present). |
500 | Internal error in the gateway or upstream, or failed to connect to the upstream. | Record the request ID and troubleshoot; retry with backoff based on the business policy. |
502 | The upstream response is not a valid expected protocol result, or the protocol translation result does not satisfy the response contract. | Check the upstream and translation configurations, and contact support personnel if the issue persists. |
503 | The protocol translation runtime environment/configuration is unavailable, or the upstream service is unavailable. | Check the service and configuration status, and retry after recovery. |
504 | Upstream gateway timeout. | Decide whether to retry based on the business time limit. |
529 | The TypeSafe upstream is overloaded. | The current implementation retains 529 and does not uniformly rewrite it to 500; retry with fault fallback for temporary failures. |
Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback