Decision APIs: Batch Judgment Patterns for AI Applications

    Decision APIs constrain model output to probabilities, categories, and scores so applications can route, block, grade, and review at scale. This article explains shared-context batch decisions, a governable service architecture, conceptual request and response shapes, typical use cases, and practices for calibration, observability, and rollout.

    From generated text to structured decisions

    A common generative AI call takes context in and returns free text. That fits open tasks such as summarization, question answering, and writing. In many business systems, though, what is actually required is a structured judgment: whether a condition is met, which preset category an input belongs to, which score band quality falls into, or whether a risk level crosses a threshold. If the model still emits natural language that must then be parsed, teams often pay for extra latency, unstable formats, complex post-processing, and harder audits.

    The core idea of a decision API is to constrain the model to a limited output space: judgment, selection, and scoring. The system does not wait for a token-by-token answer. It receives option probabilities, the probability that a condition holds, or a score, and then routes, blocks, grades, or sends the case to human review. Decision APIs do not replace generative models. They fill the decision layer of an AI application: generative interfaces produce content; decision interfaces gate, route, classify, and evaluate.

    Compared with ordinary generative calls, the engineering value shows up in four ways:

    • Parseable output. Results come back as probabilities, categories, or scores, which reduces natural-language parsers and format-repair logic.
    • Efficient batching. Several judgments can share one context, avoiding repeated transfer and repeated understanding of long documents, images, or audio and video.
    • More predictable latency. There is no wait for a long generated text, which matters for online risk control, routing, and moderation.
    • Easier human–machine collaboration. Confidence can split automatic action from human review through configurable thresholds.

    A decision API does not remove model uncertainty. It makes uncertainty explicit as a probability or score so the system can govern it with engineering controls instead of hiding it inside generated text.

    Core capabilities

    Batch judgment with shared context

    In real workflows, one request often needs several related answers. A support ticket might need “does this involve a refund,” “is this a high-severity complaint,” “which queue should own it,” and “how urgent is it.” Calling the model once per question reprocesses the same context and raises both cost and latency. Batch judgment puts shared context and multiple decision items in one request. Each item carries only its own question, options, and criteria.

    Shared context and decision items should be designed separately. Context covers documents, conversations, and references to images or audio and video. Decision items cover the question, output type, candidate options, scoring rubric, and a business identifier. That split supports caching and reuse, and it lets each item be tracked on its own.

    Non-generative output: probability, category, and score

    Decision interfaces usually return three kinds of results:

    • Boolean judgment. A probability of true or false for condition checks, compliance checks, and safety blocks.
    • Multi-class choice. A probability for each option in a preset set, for ticket classification, intent routing, and risk banding.
    • Scoring. A score or band against a rubric, for quality assessment, relevance, and risk scoring.

    These outputs can enter a rules engine directly. For example, a “high risk” probability above a threshold can escalate automatically, while low confidence goes to a human queue. Developers should not treat probability as ground truth. Offline evaluation and threshold calibration should map model confidence to business actions.

    Multimodal and long context

    Many decisions are not text-only. Image moderation, audio and video grading, and document-layout checks need multimodal input. If a decision API accepts images, audio, video, and long documents, understanding the material and making the judgment can live in one service. Long context also raises cost, latency, and noise. In practice, use referenced context, chunk summaries, key-frame extraction, and structured text preprocessing instead of stuffing every raw asset into the request.

    Latency and billing

    Decision interfaces are typically billed on input context and decision items, not on generated output length. For multi-question requests that share context, careful design reduces repeated input. Watch end-to-end latency percentiles, not only the average, and keep the online service stable with concurrency limits, timeouts and retries, caching, and fallbacks.

    Confidence-driven human review

    The most useful pattern is to treat confidence as a routing signal: high confidence runs automatically, low confidence goes to human review, and the middle band is sampled or judged a second time. That raises automation while limiting the cost of mistakes. Thresholds should not be guessed. They should follow a cost matrix: the cost of a false pass is not the same as the cost of a false block, so the thresholds should differ.

    A reference architecture for a governable decision path

    A production decision service usually has six layers:

    1. Ingress. Authentication, rate limits, tenant isolation, request audit, and idempotency. Online decisions are called by many systems and need clear quotas and trace identifiers.
    2. Context assembly. Redaction, cropping, references, and versioning for text, images, audio, and video. Context should have a unique identifier so the same material is not transferred twice.
    3. Decision orchestration. Split business questions into atomic decision items, bind options, rubrics, and output types, and control batching, timeouts, and retries.
    4. Model invocation. Call the decision capability, return probabilities, categories, or scores, and record the model version, context version, and request parameters.
    5. Post-processing and routing. Thresholds, confidence calibration, conflict merging, and rule fallbacks. High-risk actions must pass a second check in business rules.
    6. Human review and feedback. Low-confidence results enter a review queue. Review outcomes flow back as evaluation data and close the loop.

    At deployment time, general-purpose function compute, message queues, and logging and monitoring—such as those provided by Baidu AI Cloud—can split the service into a stateless inference entry and an asynchronous review queue, which makes elastic scaling and audit trails easier.

    Conceptual interface and code

    The following request is conceptual. It shows shared context plus multiple decision items. It is not a vendor-specific API definition.

    1. {
    2. "context_id": "ctx-2024-001",
    3. "context": {
    4. "text": "The body of the ticket submitted by the user...",
    5. "media": [
    6. {"type": "image", "uri": "object://bucket/case-001.jpg"},
    7. {"type": "audio", "uri": "object://bucket/call-001.wav"}
    8. ]
    9. },
    10. "decisions": [
    11. {
    12. "id": "policy_check",
    13. "type": "boolean",
    14. "question": "Does this content violate current policy clause A?",
    15. "criteria": "Judge against the scope and exceptions of clause A"
    16. },
    17. {
    18. "id": "risk_band",
    19. "type": "choice",
    20. "options": ["low", "medium", "high"],
    21. "question": "Which risk band should this ticket be assigned to?",
    22. "rubric": "low: no sensitive elements; medium: disputed but containable; high: major rights or external spread risk"
    23. },
    24. {
    25. "id": "quality_score",
    26. "type": "score",
    27. "min": 0,
    28. "max": 5,
    29. "question": "How completely does the reply cover the user's question?",
    30. "rubric": "0-1 not covered; 2-3 partially covered; 4-5 fully covered with actionable steps"
    31. }
    32. ],
    33. "constraints": {
    34. "return_confidence": true
    35. }
    36. }

    A conceptual response might look like this:

    1. {
    2. "results": [
    3. {"id": "policy_check", "probabilities": {"true": 0.93, "false": 0.07}},
    4. {"id": "risk_band", "probabilities": {"low": 0.08, "medium": 0.22, "high": 0.70}},
    5. {"id": "quality_score", "score": 3.8, "confidence": 0.81}
    6. ]
    7. }

    Routing by confidence:

    1. AUTO_THRESHOLD = 0.85
    2. REVIEW_THRESHOLD = 0.60
    3. def route_decision(result):
    4. confidence = max(result.get("probabilities", {}).values(), default=result.get("confidence", 0))
    5. action = result.get("action", "review")
    6. if confidence >= AUTO_THRESHOLD:
    7. return {"mode": "auto", "action": action}
    8. if confidence >= REVIEW_THRESHOLD:
    9. return {"mode": "sample_review", "action": action}
    10. return {"mode": "human_review", "action": action}

    The principle is simple: high confidence runs automatically, mid confidence is sampled for review, and low confidence requires a human. Real thresholds should come from offline evaluation and gradual rollout experiments.

    Typical applications

    1. Model routing and complexity split. Request complexity varies widely. A decision interface can first judge request type, required capability, and risk level, then route to models or pipelines of different size. Simple requests take a light path; complex ones take a stronger path, which lowers average latency and cost.

    2. Content safety and adversarial behavior. Before and after external tool or plugin calls, and around content generation, a decision interface can flag privilege-escalation intent, signs of prompt injection, or abnormal tool use. These cases should keep an audit log, and high-risk results should require human confirmation.

    3. Compliance and policy checks. Policy clauses often have scope and exceptions. Breaking a clause into decidable questions, each with a rubric, improves consistency. Policy judgment is high risk and needs human review plus versioned clause management.

    4. Ticket classification and priority. One request can judge business category, urgency, owning queue, and whether to escalate, instead of making several calls. Probabilities can order queues; low-confidence tickets go to human triage.

    5. Quality assessment and content scoring. Generated content, support replies, and document summaries can be scored against a rubric for automated quality checks and sampled review. Rubrics should be specific and observable, not vague.

    6. Risk assessment and credit-score assistance. A decision interface can pull signals from unstructured material and emit a risk band, but it must not replace compliance review. High-risk finance or credit use cases need explainability, an appeal path, and human review.

    Engineering practices

    Keep decision questions atomic. One question should ask one thing. Options should be mutually exclusive and complete, and scoring criteria should be observable. Mixing several judgments into one question makes confidence hard to interpret.

    Version the context. Shared context needs a unique identifier and a version so results can be reproduced and audited. Store multimodal assets by object reference instead of putting large files in the request body.

    Calibrate confidence. Probability is not accuracy. Draw calibration curves on an offline labeled set, set thresholds from the business cost matrix, and re-evaluate regularly. For imbalanced classes, watch recall on the minority class.

    Shard batch requests. Split large sets of decision items, and set both per-request and overall timeouts. Use concurrency limits for items that can run in parallel, and deduplication keys for idempotent requests.

    Double-check high-risk actions. Automatic blocking, charging, or credit decisions must not depend on model probability alone. Combine a rules engine, authorization checks, and human review.

    Observe the whole decision path. Record the request identifier, context version, model version, each decision result, confidence, routing action, and human review outcome. Metrics should include latency percentiles, automatic-execution rate, human-review rate, error rate, and fallback rate.

    Define fallbacks. On timeout, insufficient confidence, or abnormal output, degrade to a rules engine, a default safe policy, or a human queue. Do not fail silently.

    Evaluation, governance, and rollout

    Do not evaluate a decision API only by whether the answer “sounds human.” Measure business metrics: classification accuracy, recall, calibration error, automatic-execution rate, human-review rate, end-to-end latency, and cost per decision. Offline evaluation should cover edge cases, adversarial cases, and multimodal cases. Online evaluation should compare old and new policies through gradual release.

    For governance, keep an inventory of decision items: owner, output type, thresholds, review policy, version, and audit requirements for each one. Decisions that affect user rights should retain an explainable basis and an appeal channel. Model output is an advisory signal. It must not bypass existing authorization and compliance processes.

    A practical rollout has three steps. First, prove the concept on a high-value, low-risk flow that humans can still catch, such as ticket classification or content quality checks. Second, build an offline evaluation set and a confidence-calibration process, release gradually, and watch automatic-execution and error rates. Third, extend to routing, safety checks, and batch evaluation, and settle on a layered architecture of decision, generation, and human review.

    Overall, decision APIs mark an important interface split: open generation stays separate from structured judgment, so AI applications can make routine decisions with lower latency, more parseable results, and stronger governance. The work that matters is question modeling, confidence calibration, threshold policy, and human–machine collaboration—not packing everything into one oversized call. Only then does batch judgment become stable, auditable, and reversible productivity.