{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://benilli.net/data/ai-models/v1.schema.json",
  "title": "Benilli AI Model Guide v1",
  "type": "object",
  "required": [
    "schema_version",
    "prepared_on",
    "published_on",
    "last_verified_on",
    "providers",
    "catalogues",
    "sources"
  ],
  "properties": {
    "schema_version": {
      "const": 1
    },
    "prepared_on": {
      "type": "string",
      "format": "date"
    },
    "published_on": {
      "type": [
        "string",
        "null"
      ],
      "format": "date"
    },
    "last_verified_on": {
      "type": "string",
      "format": "date"
    },
    "title": {
      "type": "string"
    },
    "unit_notes": {
      "type": "object"
    },
    "providers": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "display_name"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "display_name": {
            "type": "string"
          },
          "website": {
            "type": "string",
            "format": "uri"
          }
        },
        "additionalProperties": true
      }
    },
    "catalogues": {
      "type": "object",
      "minProperties": 1,
      "additionalProperties": {
        "$ref": "#/$defs/catalogue"
      }
    },
    "editorial_policy": {
      "type": "object"
    },
    "sources": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "url",
          "type"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "type": {
            "type": "string"
          }
        },
        "additionalProperties": true
      }
    },
    "release_date_definition": {
      "type": "string"
    },
    "task_catalogue": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/task"
      },
      "uniqueItems": true
    }
  },
  "additionalProperties": true,
  "$defs": {
    "catalogue": {
      "type": "object",
      "required": [
        "display_name",
        "provider_id",
        "status",
        "models",
        "recommendations"
      ],
      "properties": {
        "display_name": {
          "type": "string"
        },
        "provider_id": {
          "type": "string",
          "minLength": 1
        },
        "status": {
          "type": "string"
        },
        "models": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/model"
          }
        },
        "recommendations": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/recommendation"
          }
        }
      },
      "additionalProperties": true
    },
    "model": {
      "type": "object",
      "required": [
        "id",
        "display_name",
        "provider_id",
        "pricing",
        "sources",
        "last_verified_on"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "display_name": {
          "type": "string",
          "minLength": 1
        },
        "provider_id": {
          "type": "string",
          "minLength": 1
        },
        "family": {
          "type": "string"
        },
        "tier": {
          "type": "string"
        },
        "lifecycle": {
          "type": "string"
        },
        "usage_contexts": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "uniqueItems": true
        },
        "pricing": {
          "type": "object",
          "additionalProperties": {
            "$ref": "#/$defs/rateCard"
          },
          "minProperties": 1
        },
        "sources": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "last_verified_on": {
          "type": "string",
          "format": "date"
        },
        "release_date": {
          "type": [
            "string",
            "null"
          ],
          "format": "date",
          "description": "Date the model was initially publicly released through the provider API, in ISO 8601 YYYY-MM-DD format. Null when unverified."
        },
        "release_date_source": {
          "type": [
            "string",
            "null"
          ],
          "description": "Reference to a source ID within the catalogue root sources list confirming the API release date."
        }
      },
      "additionalProperties": true
    },
    "rateCard": {
      "type": "object",
      "required": [
        "unit",
        "input",
        "cached_input",
        "output"
      ],
      "properties": {
        "currency": {
          "type": "string"
        },
        "unit": {
          "type": "string"
        },
        "processing": {
          "type": "string"
        },
        "context": {
          "type": "string"
        },
        "input": {
          "type": [
            "number",
            "null"
          ],
          "minimum": 0
        },
        "cached_input": {
          "type": [
            "number",
            "null"
          ],
          "minimum": 0
        },
        "output": {
          "type": [
            "number",
            "null"
          ],
          "minimum": 0
        }
      },
      "additionalProperties": true
    },
    "task": {
      "type": "object",
      "required": [
        "id",
        "label",
        "category",
        "product_contexts"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "label": {
          "type": "string",
          "minLength": 1
        },
        "category": {
          "type": "string",
          "minLength": 1
        },
        "product_contexts": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "minItems": 1,
          "uniqueItems": true
        }
      },
      "additionalProperties": true
    },
    "recommendation": {
      "type": "object",
      "required": [
        "task_id",
        "task_name",
        "economy",
        "balanced",
        "maximum_capability",
        "rationale"
      ],
      "properties": {
        "task_id": {
          "type": "string",
          "minLength": 1
        },
        "task_name": {
          "type": "string",
          "minLength": 1
        },
        "product_contexts": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "uniqueItems": true
        },
        "economy": {
          "type": "string",
          "minLength": 1
        },
        "balanced": {
          "type": "string",
          "minLength": 1
        },
        "maximum_capability": {
          "type": "string",
          "minLength": 1
        },
        "rationale": {
          "type": "string"
        }
      },
      "additionalProperties": true
    }
  }
}
