{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/parallel-ai/json-schema/parallel-ai-grounded-decision-response-schema.json",
  "title": "Decision response",
  "x-generated": "2026-11-17",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/parallel-ai-decisions-api-openapi.yml#/components/schemas/GroundedDecisionResponse",
  "properties": {
    "mode": {
      "type": "string",
      "const": "fast",
      "title": "Mode"
    },
    "answers": {
      "additionalProperties": {
        "oneOf": [
          {
            "$ref": "#/$defs/GroundedChoiceAnswer"
          },
          {
            "$ref": "#/$defs/GroundedScoreAnswer"
          },
          {
            "$ref": "#/$defs/GroundedNoulAnswer"
          },
          {
            "$ref": "#/$defs/GroundedRefusalAnswer"
          }
        ]
      },
      "type": "object",
      "title": "Answers",
      "description": "Answers keyed by the question names from the request. Any question can return a refusal."
    },
    "usage": {
      "$ref": "#/$defs/GroundedDecisionUsage"
    },
    "citations": {
      "items": {
        "$ref": "#/$defs/GroundedDecisionCitation"
      },
      "type": "array",
      "title": "Citations",
      "description": "Web sources included in the shared decision context. Applies to the whole request, without a per-answer source mapping. Can be empty."
    },
    "decision_id": {
      "type": "string",
      "title": "Decision Id",
      "description": "Decision ID: `decisions_` followed by a UUID without hyphens. Include this ID when reporting an issue or giving feedback so we can find the request's logs and trace."
    }
  },
  "type": "object",
  "required": [
    "mode",
    "answers",
    "usage",
    "citations",
    "decision_id"
  ],
  "$defs": {
    "GroundedChoiceAnswer": {
      "properties": {
        "type": {
          "type": "string",
          "const": "choice",
          "title": "Type",
          "default": "choice"
        },
        "choice": {
          "type": "string",
          "title": "Choice",
          "description": "Selected option name from the question criteria."
        },
        "probabilities": {
          "additionalProperties": {
            "type": "number"
          },
          "type": "object",
          "title": "Probabilities",
          "description": "Estimated probability for each option, keyed by option name."
        },
        "confidence": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Confidence",
          "description": "Model-reported confidence, when available. This is distinct from the probability assigned to the selected option."
        }
      },
      "type": "object",
      "required": [
        "choice",
        "probabilities"
      ],
      "title": "Choice"
    },
    "GroundedDecisionCitation": {
      "properties": {
        "url": {
          "type": "string",
          "title": "Url",
          "description": "Source page URL."
        },
        "title": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Title",
          "description": "Page title. Omitted when unavailable."
        },
        "excerpts": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "title": "Excerpts",
          "description": "Passages used to ground the decision. Empty when advanced_settings.include_excerpts is false."
        }
      },
      "type": "object",
      "required": [
        "url",
        "excerpts"
      ],
      "title": "Citation"
    },
    "GroundedDecisionUsage": {
      "properties": {
        "input_tokens": {
          "type": "integer",
          "title": "Input Tokens"
        },
        "output_tokens": {
          "type": "integer",
          "const": 0,
          "title": "Output Tokens",
          "description": "Always 0 for compatibility with the upstream contract."
        }
      },
      "type": "object",
      "required": [
        "input_tokens",
        "output_tokens"
      ],
      "title": "Usage"
    },
    "GroundedNoulAnswer": {
      "properties": {
        "type": {
          "type": "string",
          "const": "noul",
          "title": "Type",
          "default": "noul"
        },
        "noul": {
          "type": "number",
          "title": "Noul",
          "description": "Estimated probability that the condition is true, from 0 to 1."
        }
      },
      "type": "object",
      "required": [
        "noul"
      ],
      "title": "Predicate"
    },
    "GroundedRefusalAnswer": {
      "properties": {
        "type": {
          "type": "string",
          "const": "refusal",
          "title": "Type",
          "description": "The downstream decision provider refused this question; no value or probabilities are returned.",
          "default": "refusal"
        }
      },
      "type": "object",
      "title": "Refusal"
    },
    "GroundedScoreAnswer": {
      "properties": {
        "type": {
          "type": "string",
          "const": "score",
          "title": "Type",
          "default": "score"
        },
        "score": {
          "type": "number",
          "title": "Score",
          "description": "Probability-weighted mean of the zero-based level indices. Can be fractional."
        },
        "legend": {
          "additionalProperties": {
            "type": "string"
          },
          "type": "object",
          "title": "Legend",
          "description": "Maps string indices to the level descriptions from the question criteria."
        },
        "probabilities": {
          "additionalProperties": {
            "type": "number"
          },
          "type": "object",
          "title": "Probabilities",
          "description": "Estimated probability for each level, keyed by its string index."
        },
        "confidence": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Confidence",
          "description": "Model-reported confidence, when available. This is distinct from any one level's probability."
        }
      },
      "type": "object",
      "required": [
        "score",
        "legend",
        "probabilities"
      ],
      "title": "Score"
    }
  }
}