{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/azure-document-intelligence/json-schema/azure-document-intelligence-model-schema.json",
  "title": "Model",
  "description": "Response to the get custom model operation.",
  "x-generated": "2026-11-12",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_superseded/azure-document-intelligence-custom-api-openapi.yml#/components/schemas/Model",
  "type": "object",
  "required": [
    "modelInfo"
  ],
  "properties": {
    "modelInfo": {
      "$ref": "#/$defs/ModelInfo"
    },
    "keys": {
      "$ref": "#/$defs/KeysResult"
    },
    "trainResult": {
      "description": "Training result for custom model.",
      "$ref": "#/$defs/TrainResult"
    },
    "composedTrainResults": {
      "type": "array",
      "description": "Training result for composed model.",
      "items": {
        "$ref": "#/$defs/TrainResult"
      }
    }
  },
  "$defs": {
    "Attributes": {
      "description": "Optional model attributes.",
      "type": "object",
      "properties": {
        "isComposed": {
          "description": "Is this model composed? (default: false).",
          "type": "boolean",
          "default": false
        }
      }
    },
    "ErrorInformation": {
      "type": "object",
      "required": [
        "code",
        "message"
      ],
      "properties": {
        "code": {
          "type": "string"
        },
        "message": {
          "type": "string"
        }
      }
    },
    "FormFieldsReport": {
      "description": "Report for a custom model training field.",
      "type": "object",
      "required": [
        "fieldName",
        "accuracy"
      ],
      "properties": {
        "fieldName": {
          "description": "Training field name.",
          "type": "string"
        },
        "accuracy": {
          "description": "Estimated extraction accuracy for this field.",
          "type": "number"
        }
      }
    },
    "KeysResult": {
      "description": "Keys extracted by the custom model.",
      "type": "object",
      "required": [
        "clusters"
      ],
      "properties": {
        "clusters": {
          "description": "Object mapping clusterIds to a list of keys.",
          "type": "object",
          "additionalProperties": {
            "type": "array",
            "uniqueItems": true,
            "items": {
              "type": "string"
            }
          }
        }
      }
    },
    "ModelInfo": {
      "description": "Basic custom model information.",
      "type": "object",
      "required": [
        "modelId",
        "status",
        "createdDateTime",
        "lastUpdatedDateTime"
      ],
      "properties": {
        "modelId": {
          "description": "Model identifier.",
          "type": "string",
          "format": "uuid"
        },
        "status": {
          "description": "Status of the model.",
          "enum": [
            "creating",
            "ready",
            "invalid"
          ],
          "type": "string",
          "x-ms-enum": {
            "name": "ModelStatus",
            "modelAsString": false
          }
        },
        "createdDateTime": {
          "format": "date-time",
          "description": "Date and time (UTC) when the model was created.",
          "type": "string"
        },
        "lastUpdatedDateTime": {
          "format": "date-time",
          "description": "Date and time (UTC) when the status was last updated.",
          "type": "string"
        },
        "modelName": {
          "$ref": "#/$defs/ModelName"
        },
        "attributes": {
          "$ref": "#/$defs/Attributes"
        }
      }
    },
    "ModelName": {
      "description": "Optional user defined model name (max length: 1024).",
      "type": "string"
    },
    "TrainResult": {
      "description": "Custom model training result.",
      "type": "object",
      "required": [
        "trainingDocuments"
      ],
      "properties": {
        "trainingDocuments": {
          "description": "List of the documents used to train the model and any errors reported in each document.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/TrainingDocumentInfo"
          }
        },
        "fields": {
          "description": "List of fields used to train the model and the train operation error reported by each.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/FormFieldsReport"
          }
        },
        "averageModelAccuracy": {
          "description": "Average accuracy.",
          "type": "number"
        },
        "modelId": {
          "description": "Model identifier.",
          "type": "string",
          "format": "uuid"
        },
        "errors": {
          "description": "Errors returned during the training operation.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/ErrorInformation"
          }
        }
      }
    },
    "TrainingDocumentInfo": {
      "description": "Report for a custom model training document.",
      "type": "object",
      "required": [
        "documentName",
        "pages",
        "errors",
        "status"
      ],
      "properties": {
        "documentName": {
          "description": "Training document name.",
          "type": "string"
        },
        "pages": {
          "format": "int32",
          "description": "Total number of pages trained.",
          "type": "integer"
        },
        "errors": {
          "description": "List of errors.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/ErrorInformation"
          }
        },
        "status": {
          "description": "Status of the training operation.",
          "enum": [
            "succeeded",
            "partiallySucceeded",
            "failed"
          ],
          "type": "string",
          "x-ms-enum": {
            "name": "TrainStatus",
            "modelAsString": false
          }
        }
      }
    }
  }
}