Decision Model API

Updated at:

Call POST /compatible-mode/v1/systemone to use the Bailian decision model (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 configuration, see Configure the API key in environment variables.

ImportantTry the preview model online: Before writing code, try the decision model in the Playground. Pick a demo scenario (customer service judgment, agent verification, ticket routing, content moderation, agent task routing, or medical triage), enter your business content, run the model, and review decisions, probability distributions, and token usage. Modify inputs to observe how results change.

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

China (Beijing)

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

Singapore

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

US (Virginia)
decision-model

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

Germany (Frankfurt)
decision-model

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

Japan (Tokyo)
decision-model

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

Hong Kong (China)
decision-model

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

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. Supported values:

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).

The following image input parameters apply to the stable decision-model.

image · Object · Body · Optional

A single image visible to all questions; questions do not need to reference it. Mutually exclusive with images and assets.

image object properties

image.url · String · Body · One of two

A publicly accessible HTTP/HTTPS image URL, or a Base64 Data URL such as data:image/png;base64,... (use the MIME type that matches the image file). The server downloads the image; every redirect is revalidated and must use HTTP/HTTPS (FTP and other schemes are rejected).

image.data_base64 · String · Body · One of two

Raw Base64 image bytes without the data:image/...;base64, prefix. A prefix causes IMAGE_BASE64_INVALID; use url for Data URLs.

image.type · String · Body · Optional

Must be image. Optional in image / images, required in assets.

images · Array<Object> · Body · Optional

Multiple images as a nonempty array; each element uses the same format as image. All images are visible to all questions; you cannot specify that a question sees only certain images. Mutually exclusive with image and assets.

assets · Object · Body · Optional

A map from asset IDs to image objects. The key is a caller-defined nonempty string, the asset ID of that image. Mutually exclusive with image / images (at most one of the three may be present, including explicit null).

The key difference from image / images: images in assets are not visible to all questions automatically. Their scope depends on where the ID is referenced—an ID in state is shared by all questions, while an ID in a question's instructions / criteria belongs only to that question. This makes "multiple images, each question sees a different one" possible and avoids putting unrelated images into every question's context.

assets object properties

assets.<asset_id>.type · String · Body · Required

Must be image. It cannot be omitted in assets; a missing value returns IMAGE_TYPE_INVALID.

assets.<asset_id>.url · String · Body · One of two

A publicly accessible HTTP/HTTPS image URL, or a Base64 Data URL. The server downloads the image; every redirect is revalidated and must use HTTP/HTTPS (FTP and other schemes are rejected).

assets.<asset_id>.data_base64 · String · Body · One of two

Raw Base64 image bytes without a Data URL prefix. Exactly one of url and data_base64 must be nonempty; otherwise the request returns IMAGE_SOURCE_INVALID. Image objects do not accept undefined fields; extra fields return INVALID_FIELD. The legacy format field is the exception: it is accepted but its value is ignored, and the actual bytes determine the format.

Use HTTP, or DashScope Python SDK 2.1.0 or later with extra_body to pass image / images / assets. These are not named parameters of client.decision.create yet. The DashScope Java SDK does not support image input; use HTTP.

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 / Object / Array · Optional

Question description or judgment criteria, as a string, object, or array. With assets, reference asset IDs in string values to bind images to this question.

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: decision-model: 268,288 tokens; decision-model-preview: 65,536 tokens; overlong state is rejected.

Request Examples

  • Python: DashScope SDK 2.0.1 or later (client.decision.create). The SDK builds the endpoint from your workspace and region; image input requires 2.1.0 or later (passed through extra_body). Install with pip install -U "dashscope>=2.0.1", see Install the SDK.
  • Java: DashScope SDK 2.23.3 or later (DecisionModel.call), Maven dependency com.alibaba:dashscope-sdk-java. See the DashScope Java SDK documentation for the full API reference.
  • On call failures, the Python SDK raises a DashScopeError exception and the Java SDK raises an ApiException.

Image input example

Image URL(curl)

curl -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",
    "state": "Identify the animal in the image.",
    "image": {"url": "https://dashscope.oss-cn-beijing.aliyuncs.com/images/dog_and_girl.jpeg"},
    "questions": {
      "animal": {
        "type": "choice",
        "instructions": "Which animal is in the image?",
        "criteria": {"dog": "Dog", "cat": "Cat", "none": "No animal"}
      }
    }
  }'

Base64 image(Python)

Replace /path/to/screenshot.png with your local PNG screenshot path. For multiple images, replace image with images: [{"url": ...}, ...].

import base64
import json
import os
import urllib.request

with open("/path/to/screenshot.png", "rb") as image_file:
    img_b64 = base64.b64encode(image_file.read()).decode()

body = {
    "model": "decision-model",
    "state": "Identify the problem in this ticket screenshot.",
    "image": {"url": f"data:image/png;base64,{img_b64}"},
    "questions": {
        "error_code": {
            "type": "choice",
            "instructions": "Which error code appears in the screenshot?",
            "criteria": {"E-7788": "Disk full", "500": "HTTP 500", "other": "Other or absent"},
        },
        "escalate": {"type": "noul", "instructions": "Should the on-call team be notified immediately?"},
        "severity": {
            "type": "score",
            "instructions": "How severe is the issue?",
            "criteria": ["Minor", "Some functions affected", "Core functions unavailable", "Severe business/security impact"],
        },
    },
}
request = urllib.request.Request(
    "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/systemone",
    data=json.dumps(body).encode(),
    headers={
        "Authorization": f"Bearer {os.environ['DASHSCOPE_API_KEY']}",
        "Content-Type": "application/json",
    },
)
with urllib.request.urlopen(request) as response:
    print(json.dumps(json.load(response), ensure_ascii=False, indent=2))

DashScope Python

Requires DashScope Python SDK 2.1.0 or later.

import os

import dashscope

# Configuration for China (Beijing) region. Replace "{WorkspaceId}" with your real workspace ID; other regions differ.
# image/images are not named parameters of create yet; extra_body forwards them alongside state and questions.
client = dashscope.Client(
    # If the API key is not in an environment variable, replace the line below: api_key="sk-xxx"
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    workspace="{WorkspaceId}",
    region="cn-beijing",
)

result = client.decision.create(
    model="decision-model",
    state="Identify the animal in the image.",
    questions={
        "animal": {"type": "choice", "instructions": "Which animal is in the image?",
                   "criteria": {"dog": "Dog", "cat": "Cat", "none": "No animal"}},
    },
    # A local image can be Base64-encoded into a data URL first (see the Base64 example above); multiple images use images: [{"url": ...}, ...]
    extra_body={"image": {"url": "https://dashscope.oss-cn-beijing.aliyuncs.com/images/dog_and_girl.jpeg"}},
)

print(result.answers["animal"].choice)   # selected option
print(result.usage.input_tokens, result.latency_ms)

Two screenshots (assets)

A customer claims delivery is complete and requests payment release. The order screenshot says pending delivery; the tracking screenshot shows out for delivery with no delivery confirmation. order_status references only the order image, signed only the tracking image, and payout_risk both. state contains no asset IDs, so the images are not shared automatically.

import json
import os
import urllib.request

ORDER_IMAGE_URL = "https://g-adoc.alcasset.com/media/maas_docs/sfm-cn/zh/images/6a4b3c2d1e0f96b6.png"
TRACKING_IMAGE_URL = "https://g-adoc.alcasset.com/media/maas_docs/sfm-cn/zh/images/6a4b3c2d1e0f96b5.png"

body = {
    "model": "decision-model",
    "state": {
        "ticket_id": "AS-20261203-0417",
        "customer_claim": "用户称商品已签收但订单仍显示待收货,要求核实并放款。",
        "evidence": "两张截图由用户在工单中上传,各题已绑定对应截图。",
    },
    "assets": {
        "order_page": {"type": "image", "url": ORDER_IMAGE_URL},
        "tracking_page": {"type": "image", "url": TRACKING_IMAGE_URL},
    },
    "questions": {
        "order_status": {
            "type": "choice",
            "instructions": {
                "question": "这张订单截图中的订单状态是什么?",
                "screenshot": "order_page",
            },
            "criteria": {
                "pending_payment": "待付款",
                "pending_delivery": "待收货",
                "completed": "已完成",
                "refunded": "已退款",
                "other": "其他或无法判断",
            },
        },
        "signed": {
            "type": "noul",
            "instructions": {
                "question": "这张物流截图是否显示包裹已签收?",
                "screenshot": "tracking_page",
            },
            "criteria": {"true": "已签收", "false": "未签收或无签收记录"},
        },
        "payout_risk": {
            "type": "score",
            "instructions": {
                "question": "结合这两张截图,用户诉求与证据是否一致?",
                "order": "order_page",
                "tracking": "tracking_page",
            },
            "criteria": [
                "证据一致,可自动放款",
                "证据基本一致,建议抽查",
                "证据不足,需人工复核",
                "证据与诉求矛盾,应拒绝放款",
            ],
        },
    },
}

request = urllib.request.Request(
    "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/systemone",
    data=json.dumps(body).encode(),
    headers={
        "Authorization": f"Bearer {os.environ['DASHSCOPE_API_KEY']}",
        "Content-Type": "application/json",
    },
)
with urllib.request.urlopen(request) as response:
    result = json.load(response)

print(result["answers"]["order_status"]["choice"])
print(result["answers"]["signed"]["noul"])
print(result["answers"]["payout_risk"]["score"])
print(result["usage"]["input_tokens"], result["latency_ms"])

Ticket routing

A single request handles three decisions at once: team assignment (choice), escalation (noul), and severity (score). The example below uses the China (Beijing) region.

DashScope Python

import 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",
    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 Java

import 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("decision-model")
        .state(state)
        .questions(questions)
        .build();

    DecisionModel decisionModel = new DecisionModel("{WorkspaceId}", "cn-beijing");
    DecisionModelResult result = decisionModel.call(param);

    System.out.println(JsonUtils.toJson(result));
  }
}

TypeSafe Python

import 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",
    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

curl

curl -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",
    "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 decision

A noul question returns P(yes), where 0 = no and 1 = yes. The example below uses the China (Beijing) region.

DashScope Python

import 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",
    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 Java

import 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("decision-model")
        .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 Python

import 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",
    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)

curl

curl -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",
    "state": "Is this comment asking for a refund?",
    "questions": {
      "refund": {"type": "noul", "instructions": "Is the user asking for a refund?"}
    }
  }'

Response Parameters

model · String

Model name echoed back.

request_id · String

Request ID, for troubleshooting.

answers · Object

A map of answers. The key corresponds to the question id in the request; the value is an answer object with the following fields.

Answer object properties

type · String

Matches the question type (choice / noul / score).

choice · String

For choice: the selected option name.

noul · Float

For noul: P(yes), where 0 = no and 1 = yes.

score · Float

For score: the probability-weighted expectation of the level index, which can fall between two levels (e.g. 1.43).

probabilities · Object

The probability of each option / level (sums to 1).

confidence · Float

The confidence of the answer (returned for choice / score).

legend · Object

For score: a map of level index → level description.

usage · Object

Metering information:

  • input_tokens (Integer): number of input tokens.

latency_ms · Float

Server-side latency (milliseconds).

Response Example

Ticket routing

The following is the response for the ticket routing example (abbreviated). Probabilities and confidence depend on the actual result.

{
  "model": "decision-model",
  "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
}

Two screenshots for an after-sales ticket

With assets, each question is bound to its own screenshot. The response is as follows (excerpt). The order status is pending_delivery, signed is close to 0, and the highest risk level has a probability of about 0.87. Probabilities, confidence, token usage, and latency vary with the model version and input; rely on the actual call.

{
  "model": "decision-model",
  "request_id": "15a284ab-4d04-91e2-9f09-76491dae8008",
  "answers": {
    "order_status": {
      "type": "choice",
      "choice": "pending_delivery",
      "confidence": 0.9999901652336121,
      "probabilities": {
        "pending_payment": 3.6634898492593493e-7,
        "pending_delivery": 0.9999921321868896,
        "completed": 0.0000033668684409349225,
        "refunded": 4.810578957403777e-8,
        "other": 0.000004223978066875134
      }
    },
    "signed": {
      "type": "noul",
      "noul": 0.00005330973363015801
    },
    "payout_risk": {
      "type": "score",
      "score": 2.8109508976340294,
      "confidence": 0.810950911603868,
      "legend": {
        "0": "Evidence is consistent; payment can be released automatically",
        "1": "Evidence is mostly consistent; spot-check recommended",
        "2": "Insufficient evidence; manual review required",
        "3": "Evidence contradicts the claim; payment should be rejected"
      },
      "probabilities": {
        "0": 0.011254648678004742,
        "1": 0.037222571671009064,
        "2": 0.08083999902009964,
        "3": 0.8706827759742737
      }
    }
  },
  "usage": {
    "input_tokens": 3011
  },
  "latency_ms": 574.7
}

Image references and scope

  • A string value must exactly equal an asset ID. Substrings, Markdown image syntax, and object keys do not count. For example, {"screenshot":"order_page"} references an image, but {"screenshot":"See order_page screenshot"} does not.
  • Images referenced in state are shared by all questions. Images referenced in a question's instructions or criteria descriptions enter only that question. One question can reference multiple IDs.
  • Every asset must be referenced at least once; otherwise the entire request fails with ASSET_UNREFERENCED. Images are never silently dropped.
  • Images are appended in template-block order: state, the question's instructions, then candidate descriptions. Objects are traversed by lexicographic key order and arrays by element order. Each image follows its referring text with an Asset "<ID>" label. Each ID is appended only once per question.
  • Use semantic IDs such as order_page and tracking_page. IDs enter the model's text input. Avoid collisions with existing business string values, which would become image references.

assets versus image/images

image / images are shortcuts for shared images. The server creates internal IDs such as __image_1 and __image_2, avoiding collisions with business text, and wraps the original state in an object with content and images. assets preserves the original state.

Use image when all questions need one image, or images when all questions need the same set. Use assets when each question needs specific images or images must correspond to business fields, so unrelated images do not enter each question's context. Input token overhead differs between the paths; use actual responses to assess usage and decisions.

Capacity and format limits

  • At most 4 images per question and 16 image assets per request, counting URL and Base64 sources together. An asset referenced by multiple questions counts once in each question. Different IDs count separately even when bytes or URLs match; content is not deduplicated. Excess images cause rejection, without dropping or truncating images.
  • Only fully decodable, single-frame JPEG, PNG, and WebP images are supported. Actual bytes determine the format, not URL suffixes or Content-Type. EXIF rotation is applied before conversion to RGB.
  • The default per-image download budget and whole-request deadline are both 30 seconds. Any image failure fails the entire request, without partial answers. Image bytes, pixels, and request-body size depend on deployment configuration, with no fixed public limits; configured capacities are checked in advance.

Error responses include error_code, the JSON Pointer details.field, and the failure stage details.stage. Invalid protocol or values use InvalidParameter; capacity violations use ValidationError. The parameter errors below return HTTP 400, except upstream unavailability and request timeout.

Error codes and conditions

  • MEDIA_FIELDS_CONFLICT · HTTP 400 · InvalidParameter · schema:More than one media field is present, including null。
  • MEDIA_FIELD_INVALID · HTTP 400 · InvalidParameter · schema:image is not an object or images is not a nonempty array。
  • ASSET_ID_INVALID · HTTP 400 · InvalidParameter · schema:Empty or whitespace-only ID。
  • IMAGE_TYPE_INVALID · HTTP 400 · InvalidParameter · schema:Missing type or value other than image。
  • IMAGE_SOURCE_INVALID · HTTP 400 · InvalidParameter · schema:Exactly one nonempty source was not supplied。
  • IMAGE_URL_INVALID · HTTP 400 · InvalidParameter · schema:Invalid URL protocol or Data URL。
  • INVALID_FIELD · HTTP 400 · InvalidParameter · schema:Undefined image field, except format。
  • ASSET_UNREFERENCED · HTTP 400 · InvalidParameter · references:No exact full-string reference to the asset。
  • IMAGE_NOT_SUPPORTED · HTTP 400 · InvalidParameter · limits:Deployment has not enabled images。
  • IMAGE_COUNT_EXCEEDED · HTTP 400 · ValidationError · limits:More than 4 images in one question。
  • IMAGE_REQUEST_COUNT_EXCEEDED · HTTP 400 · ValidationError · limits:More than 16 image assets; rejected before download or decoding。
  • IMAGE_BASE64_INVALID · HTTP 400 · InvalidParameter · decode:Not strict raw Base64。
  • IMAGE_EMPTY_DATA · HTTP 400 · InvalidParameter · decode:Empty image data。
  • IMAGE_FORMAT_UNSUPPORTED · HTTP 400 · InvalidParameter · decode:Actual format is not JPEG, PNG, or WebP。
  • IMAGE_MULTIFRAME_UNSUPPORTED · HTTP 400 · InvalidParameter · decode:Animated or multiframe image。
  • IMAGE_DECODE_FAILED · HTTP 400 · InvalidParameter · decode:Image cannot be fully decoded。
  • IMAGE_PIXELS_EXCEEDED · HTTP 400 · ValidationError · decode:Pixel count exceeds deployment limit。
  • IMAGE_URL_UNAVAILABLE · HTTP 400 · InvalidParameter · download:Image URL returns non-2xx。
  • IMAGE_HOST_NOT_FOUND · HTTP 400 · InvalidParameter · download:Image host cannot be resolved。
  • IMAGE_BYTES_EXCEEDED · HTTP 400 · ValidationError · download:Image bytes exceed deployment limit。
  • IMAGE_DOWNLOAD_TIMEOUT · HTTP 400 · InvalidParameter · download:Per-image download budget exceeded (default 30 seconds); retryable。
  • IMAGE_UPSTREAM_UNAVAILABLE · HTTP 503 · ServiceUnavailable · download:Image origin unavailable; HTTP 503 / ServiceUnavailable; retryable。
  • REQUEST_TIMEOUT · HTTP 500 · ResponseTimeout · request:Whole-request deadline exceeded (default 30 seconds); HTTP 500 / ResponseTimeout; retryable。
{
  "code": "InvalidParameter",
  "error_code": "ASSET_UNREFERENCED",
  "message": "<400> InternalError.Algo.InvalidParameter: [ASSET_UNREFERENCED] Asset tracking_page has no matching full-string reference.",
  "details": {"stage": "references", "asset_id": "tracking_page", "field": "/assets/tracking_page"},
  "request_id": "0cd8d01b-a8c2-4ceb-9f11-f8dbc6a31d6b"
}

Error Codes

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