{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/antfly/json-schema/antfly-inference-decide-response-schema.json",
  "title": "InferenceDecideResponse",
  "description": "Single-input responses have answers. Batch responses have data in input order, with one named answer array per input and aggregate usage including reported usage from failed items. Named gateway batches identify the configured model at the top level and resolved models per successful item.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/antfly-inference-api-openapi.yml#/components/schemas/InferenceDecideResponse",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "model",
    "usage"
  ],
  "properties": {
    "model": {
      "type": "string"
    },
    "model_identity": {
      "type": "string"
    },
    "renderer_version": {
      "type": "string"
    },
    "answers": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/InferenceDecideAnswer"
      }
    },
    "data": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/DecisionBatchItem"
      }
    },
    "usage": {
      "$ref": "#/$defs/DecisionUsage"
    }
  },
  "$defs": {
    "DecisionBatchItem": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "input_index",
        "answers"
      ],
      "properties": {
        "input_index": {
          "type": "integer",
          "minimum": 0
        },
        "id": {
          "type": "string",
          "minLength": 1
        },
        "error": {
          "type": "string",
          "description": "Named gateway and generated batches preserve valid siblings; a failed item has an empty answers array and this error code. Invalid input or request budgets fail validation before dispatch."
        },
        "model": {
          "type": "string",
          "description": "Resolved model reported for a successful named gateway batch item."
        },
        "answers": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/InferenceDecideAnswer"
          }
        }
      }
    },
    "DecisionChoiceProbability": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "value",
        "probability"
      ],
      "properties": {
        "value": {
          "type": "string",
          "minLength": 1
        },
        "probability": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        }
      }
    },
    "DecisionLevelProbability": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "label",
        "value",
        "probability"
      ],
      "properties": {
        "label": {
          "type": "string",
          "minLength": 1
        },
        "value": {
          "type": "integer",
          "minimum": 0
        },
        "probability": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        }
      }
    },
    "DecisionSimilarity": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "value",
        "similarity"
      ],
      "properties": {
        "value": {
          "type": "string",
          "minLength": 1
        },
        "similarity": {
          "type": "number",
          "minimum": -1,
          "maximum": 1
        }
      }
    },
    "DecisionUsage": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "input_tokens",
        "output_tokens"
      ],
      "properties": {
        "input_tokens": {
          "type": "integer",
          "minimum": 0,
          "description": "Encoded tokens including repeated input text for split model tasks."
        },
        "output_tokens": {
          "type": "integer",
          "minimum": 0,
          "description": "Zero for classifiers, which generate no tokens."
        }
      }
    },
    "EmbeddingChoiceAnswer": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "type",
        "decision_method",
        "similarity_metric",
        "similarities",
        "margin",
        "status",
        "prototype_set_hash",
        "choice"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "type": {
          "type": "string",
          "enum": [
            "choice"
          ]
        },
        "decision_method": {
          "type": "string",
          "enum": [
            "embedding_similarity"
          ]
        },
        "similarity_metric": {
          "type": "string",
          "enum": [
            "cosine"
          ],
          "description": "Cosine is fixed for this embedding recipe and its threshold artifacts. Index distance settings are independent."
        },
        "similarities": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/DecisionSimilarity"
          },
          "minItems": 2
        },
        "margin": {
          "type": "number",
          "minimum": 0,
          "maximum": 2
        },
        "status": {
          "type": "string",
          "enum": [
            "selected",
            "abstained"
          ]
        },
        "prototype_set_hash": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "calibration_id": {
          "type": "string"
        },
        "abstention_reason": {
          "type": "string",
          "enum": [
            "tie",
            "min_similarity",
            "min_margin"
          ]
        },
        "choice": {
          "type": [
            "string",
            "null"
          ],
          "description": "Selected identifier, or null on abstention."
        }
      },
      "description": "Raw cosine scores are neither probabilities nor confidence. Empty means no label met its threshold; abstained means the requested margin could not be established."
    },
    "EmbeddingMultiChoiceAnswer": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "type",
        "decision_method",
        "similarity_metric",
        "similarities",
        "margin",
        "status",
        "prototype_set_hash",
        "choices",
        "similarity_thresholds"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "type": {
          "type": "string",
          "enum": [
            "multi_choice"
          ]
        },
        "decision_method": {
          "type": "string",
          "enum": [
            "embedding_similarity"
          ]
        },
        "similarity_metric": {
          "type": "string",
          "enum": [
            "cosine"
          ],
          "description": "Cosine is fixed for this embedding recipe and its threshold artifacts. Index distance settings are independent."
        },
        "similarities": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/DecisionSimilarity"
          },
          "minItems": 2
        },
        "margin": {
          "type": "number",
          "minimum": 0,
          "maximum": 2
        },
        "status": {
          "type": "string",
          "enum": [
            "selected",
            "empty",
            "abstained"
          ]
        },
        "prototype_set_hash": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "calibration_id": {
          "type": "string"
        },
        "abstention_reason": {
          "type": "string",
          "enum": [
            "tie",
            "min_similarity",
            "min_margin"
          ]
        },
        "choices": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "similarity_thresholds": {
          "type": "object",
          "additionalProperties": {
            "type": "number",
            "minimum": -1,
            "maximum": 1
          },
          "description": "Effective cosine selection threshold for every choice, including fitted calibration thresholds."
        }
      },
      "description": "Raw cosine scores are neither probabilities nor confidence. Empty means no label met its threshold; abstained means the requested margin could not be established."
    },
    "GeneratedChoiceAnswer": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "type",
        "decision_method",
        "probability_source",
        "raw_structured_answer",
        "choice",
        "probabilities"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "type": {
          "type": "string",
          "enum": [
            "choice"
          ]
        },
        "decision_method": {
          "type": "string",
          "enum": [
            "generated"
          ]
        },
        "probability_source": {
          "type": "string",
          "enum": [
            "token_logprobs",
            "verdict"
          ],
          "description": "Measured decoder evidence, or an explicit verdict-only 0/1 assertion. No model-written confidence."
        },
        "raw_structured_answer": {
          "type": "string"
        },
        "choice": {
          "type": "string"
        },
        "probabilities": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/DecisionChoiceProbability"
          }
        }
      }
    },
    "GeneratedMultiChoiceAnswer": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "type",
        "decision_method",
        "probability_source",
        "raw_structured_answer",
        "choices",
        "probabilities"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "type": {
          "type": "string",
          "enum": [
            "multi_choice"
          ]
        },
        "decision_method": {
          "type": "string",
          "enum": [
            "generated"
          ]
        },
        "probability_source": {
          "type": "string",
          "enum": [
            "token_logprobs",
            "verdict"
          ],
          "description": "Measured decoder evidence, or an explicit verdict-only 0/1 assertion. No model-written confidence."
        },
        "raw_structured_answer": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "uniqueItems": true
        },
        "choices": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "type": "string"
          }
        },
        "probabilities": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/DecisionChoiceProbability"
          }
        }
      }
    },
    "GeneratedPredicateAnswer": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "type",
        "decision_method",
        "probability_source",
        "raw_structured_answer",
        "probability"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "type": {
          "type": "string",
          "enum": [
            "predicate"
          ]
        },
        "decision_method": {
          "type": "string",
          "enum": [
            "generated"
          ]
        },
        "probability_source": {
          "type": "string",
          "enum": [
            "token_logprobs",
            "verdict"
          ],
          "description": "Measured decoder evidence, or an explicit verdict-only 0/1 assertion. No model-written confidence."
        },
        "raw_structured_answer": {
          "type": "boolean"
        },
        "probability": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        }
      }
    },
    "GeneratedScoreAnswer": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "type",
        "decision_method",
        "probability_source",
        "raw_structured_answer",
        "score"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "type": {
          "type": "string",
          "enum": [
            "score"
          ]
        },
        "decision_method": {
          "type": "string",
          "enum": [
            "generated"
          ]
        },
        "probability_source": {
          "type": "string",
          "enum": [
            "token_logprobs",
            "verdict"
          ],
          "description": "Measured decoder evidence, or an explicit verdict-only 0/1 assertion. No model-written confidence."
        },
        "raw_structured_answer": {
          "type": "number"
        },
        "score": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        }
      }
    },
    "InferenceDecideAnswer": {
      "oneOf": [
        {
          "$ref": "#/$defs/GeneratedChoiceAnswer"
        },
        {
          "$ref": "#/$defs/GeneratedMultiChoiceAnswer"
        },
        {
          "$ref": "#/$defs/GeneratedPredicateAnswer"
        },
        {
          "$ref": "#/$defs/GeneratedScoreAnswer"
        },
        {
          "$ref": "#/$defs/TrainedChoiceAnswer"
        },
        {
          "$ref": "#/$defs/TrainedScoreAnswer"
        },
        {
          "$ref": "#/$defs/TrainedPredicateAnswer"
        },
        {
          "$ref": "#/$defs/EmbeddingChoiceAnswer"
        },
        {
          "$ref": "#/$defs/EmbeddingMultiChoiceAnswer"
        }
      ]
    },
    "TrainedChoiceAnswer": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "type",
        "decision_method",
        "choice",
        "probabilities",
        "confidence",
        "confidence_method"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "type": {
          "type": "string",
          "enum": [
            "choice"
          ]
        },
        "decision_method": {
          "type": "string",
          "enum": [
            "typed"
          ]
        },
        "confidence": {
          "type": "number",
          "minimum": 0,
          "maximum": 1,
          "description": "Model diagnostic; entropy confidence is not the probability that the chosen label is correct."
        },
        "confidence_method": {
          "type": "string",
          "enum": [
            "normalized_inverse_entropy",
            "max_probability"
          ]
        },
        "act_probability": {
          "type": "number",
          "minimum": 0,
          "maximum": 1,
          "description": "Applicable action-head diagnostic. It does not authorize or execute an action."
        },
        "choice": {
          "type": "string",
          "minLength": 1
        },
        "probabilities": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/DecisionChoiceProbability"
          },
          "minItems": 2
        }
      }
    },
    "TrainedPredicateAnswer": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "type",
        "decision_method",
        "probability"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "type": {
          "type": "string",
          "enum": [
            "predicate"
          ]
        },
        "decision_method": {
          "type": "string",
          "enum": [
            "typed"
          ]
        },
        "confidence": {
          "type": "number",
          "minimum": 0,
          "maximum": 1,
          "description": "Model diagnostic; entropy confidence is not the probability that the chosen label is correct."
        },
        "confidence_method": {
          "type": "string",
          "enum": [
            "normalized_inverse_entropy",
            "max_probability"
          ]
        },
        "act_probability": {
          "type": "number",
          "minimum": 0,
          "maximum": 1,
          "description": "Applicable action-head diagnostic. It does not authorize or execute an action."
        },
        "probability": {
          "type": "number",
          "minimum": 0,
          "maximum": 1,
          "description": "The model-estimated probability that the condition in instructions holds."
        }
      }
    },
    "TrainedScoreAnswer": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "type",
        "decision_method",
        "score",
        "probabilities",
        "confidence",
        "confidence_method"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "type": {
          "type": "string",
          "enum": [
            "score"
          ]
        },
        "decision_method": {
          "type": "string",
          "enum": [
            "typed"
          ]
        },
        "confidence": {
          "type": "number",
          "minimum": 0,
          "maximum": 1,
          "description": "Model diagnostic; entropy confidence is not the probability that the chosen label is correct."
        },
        "confidence_method": {
          "type": "string",
          "enum": [
            "normalized_inverse_entropy",
            "max_probability"
          ]
        },
        "act_probability": {
          "type": "number",
          "minimum": 0,
          "maximum": 1,
          "description": "Applicable action-head diagnostic. It does not authorize or execute an action."
        },
        "score": {
          "type": "number",
          "minimum": 0
        },
        "probabilities": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/DecisionLevelProbability"
          },
          "minItems": 2
        }
      }
    }
  }
}