{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/beatapi/json-schema/beatapi-decision-request-schema.json",
  "title": "DecisionRequest",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/beatapi-decisions-api-openapi.yml#/components/schemas/DecisionRequest",
  "type": "object",
  "required": [
    "state",
    "questions"
  ],
  "properties": {
    "model": {
      "type": "string",
      "default": "jev-1.14",
      "description": "Use a published decision model, such as jev-1.14 or jev-1.14-free; jev-1.13 and jev-1.13-free remain available."
    },
    "state": {
      "description": "Shared application state. Billed once across all named questions.",
      "oneOf": [
        {
          "type": "string",
          "minLength": 1,
          "pattern": "\\S"
        },
        {
          "type": "object",
          "additionalProperties": true
        },
        {
          "type": "array",
          "items": {}
        }
      ]
    },
    "questions": {
      "type": "object",
      "minProperties": 1,
      "additionalProperties": {
        "oneOf": [
          {
            "$ref": "#/$defs/DecisionNoulQuestion"
          },
          {
            "$ref": "#/$defs/DecisionChoiceQuestion"
          },
          {
            "$ref": "#/$defs/DecisionScoreQuestion"
          },
          {
            "$ref": "#/$defs/DecisionBoxQuestion"
          }
        ]
      }
    },
    "assets": {
      "type": "object",
      "minProperties": 1,
      "description": "Images, each under a reference string that you also write in state, instructions or criteria where the picture belongs. PNG or JPEG, 280 to 1568 px a side, up to 16 MiB each; the whole body up to 32 MiB. Images are billed as input tokens. JSON only; multipart is not accepted.",
      "additionalProperties": {
        "$ref": "#/$defs/DecisionAsset"
      }
    },
    "stream": {
      "type": "boolean",
      "enum": [
        false
      ],
      "description": "Only false is supported; decisions are synchronous and never stream."
    }
  },
  "$defs": {
    "DecisionAsset": {
      "type": "object",
      "required": [
        "format",
        "data_base64"
      ],
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "image"
          ]
        },
        "format": {
          "type": "string",
          "enum": [
            "png",
            "jpg",
            "jpeg"
          ]
        },
        "data_base64": {
          "type": "string",
          "minLength": 1,
          "description": "Standard base64 of the image bytes, without a data URL prefix."
        }
      }
    },
    "DecisionBoxQuestion": {
      "type": "object",
      "required": [
        "type"
      ],
      "description": "Locates what the instructions describe in the request's image. jev-1.14 only; the request needs an image in assets.",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "box"
          ]
        },
        "instructions": {
          "$ref": "#/$defs/DecisionInstructions"
        }
      }
    },
    "DecisionChoiceQuestion": {
      "type": "object",
      "required": [
        "type",
        "criteria"
      ],
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "choice"
          ]
        },
        "instructions": {
          "oneOf": [
            {
              "$ref": "#/$defs/DecisionInstructions"
            },
            {
              "type": "null"
            }
          ]
        },
        "criteria": {
          "type": "object",
          "minProperties": 1,
          "maxProperties": 255,
          "additionalProperties": {
            "$ref": "#/$defs/DecisionEntry"
          },
          "description": "Option key to its meaning; one call can rank many options."
        }
      }
    },
    "DecisionEntry": {
      "description": "A criterion description; text, JSON object, array, or null.",
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "object",
          "additionalProperties": true
        },
        {
          "type": "array",
          "items": {}
        },
        {
          "type": "null"
        }
      ]
    },
    "DecisionInstructions": {
      "description": "The question in words, or structured instructions. Required for noul.",
      "oneOf": [
        {
          "type": "string",
          "minLength": 1,
          "pattern": "\\S"
        },
        {
          "type": "object",
          "additionalProperties": true
        },
        {
          "type": "array",
          "minItems": 1,
          "items": {}
        }
      ]
    },
    "DecisionNoulQuestion": {
      "type": "object",
      "required": [
        "type",
        "instructions"
      ],
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "noul"
          ]
        },
        "instructions": {
          "$ref": "#/$defs/DecisionInstructions"
        },
        "criteria": {
          "description": "Optional descriptions of true and false.",
          "oneOf": [
            {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "true": {
                  "$ref": "#/$defs/DecisionEntry"
                },
                "false": {
                  "$ref": "#/$defs/DecisionEntry"
                }
              }
            },
            {
              "type": "null"
            }
          ]
        }
      }
    },
    "DecisionScoreQuestion": {
      "type": "object",
      "required": [
        "type",
        "criteria"
      ],
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "score"
          ]
        },
        "instructions": {
          "oneOf": [
            {
              "$ref": "#/$defs/DecisionInstructions"
            },
            {
              "type": "null"
            }
          ]
        },
        "criteria": {
          "type": "array",
          "minItems": 1,
          "maxItems": 10,
          "items": {
            "$ref": "#/$defs/DecisionEntry"
          },
          "description": "Ordered scale labels, lowest first. More than 10 is rejected."
        }
      }
    }
  }
}