{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://gabriellash.github.io/ai-model-tracker/schema.json",
  "title": "AI Model Tracker dataset",
  "description": "models.json: one entry per model. Prices are USD per 1M text tokens on the provider's own API.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "models"
  ],
  "properties": {
    "$schema": {
      "type": "string"
    },
    "schema_version": {
      "const": 1
    },
    "models": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/model"
      }
    }
  },
  "$defs": {
    "date": {
      "type": "string",
      "format": "date"
    },
    "nullableDate": {
      "type": [
        "string",
        "null"
      ],
      "format": "date"
    },
    "httpsUrl": {
      "type": "string",
      "format": "uri",
      "pattern": "^https://"
    },
    "price": {
      "type": "number",
      "minimum": 0
    },
    "nullablePrice": {
      "type": [
        "number",
        "null"
      ],
      "minimum": 0
    },
    "modality": {
      "enum": [
        "text",
        "image",
        "audio",
        "video",
        "pdf"
      ]
    },
    "sourceField": {
      "enum": [
        "pricing",
        "context_window",
        "max_output_tokens",
        "modalities",
        "release_date",
        "status",
        "open_weights",
        "availability"
      ]
    },
    "tier": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "above_input_tokens",
        "input",
        "output"
      ],
      "properties": {
        "above_input_tokens": {
          "type": "integer",
          "minimum": 1
        },
        "input": {
          "$ref": "#/$defs/price"
        },
        "output": {
          "$ref": "#/$defs/price"
        },
        "cached_input": {
          "$ref": "#/$defs/nullablePrice"
        },
        "cache_write": {
          "$ref": "#/$defs/nullablePrice"
        },
        "batch_input": {
          "$ref": "#/$defs/nullablePrice"
        },
        "batch_output": {
          "$ref": "#/$defs/nullablePrice"
        }
      },
      "description": "Thresholds are recorded as the provider writes them, with k = 1,000 (e.g. '200k' = 200000)."
    },
    "scheduledPrice": {
      "type": "object",
      "additionalProperties": false,
      "description": "A price change the provider has announced for a future date. The current price stays in the main fields until the date passes.",
      "required": [
        "effective_date",
        "input",
        "output"
      ],
      "properties": {
        "effective_date": {
          "$ref": "#/$defs/date"
        },
        "input": {
          "$ref": "#/$defs/price"
        },
        "output": {
          "$ref": "#/$defs/price"
        },
        "cached_input": {
          "$ref": "#/$defs/nullablePrice"
        },
        "batch_input": {
          "$ref": "#/$defs/nullablePrice"
        },
        "batch_output": {
          "$ref": "#/$defs/nullablePrice"
        }
      }
    },
    "pricing": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "input",
        "output"
      ],
      "properties": {
        "input": {
          "$ref": "#/$defs/price"
        },
        "output": {
          "$ref": "#/$defs/price"
        },
        "cached_input": {
          "$ref": "#/$defs/nullablePrice"
        },
        "cache_write": {
          "$ref": "#/$defs/nullablePrice"
        },
        "batch_input": {
          "$ref": "#/$defs/nullablePrice"
        },
        "batch_output": {
          "$ref": "#/$defs/nullablePrice"
        },
        "free": {
          "type": "boolean",
          "description": "True only when the provider explicitly lists the model as free of charge."
        },
        "tiers": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/tier"
          }
        },
        "scheduled": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/scheduledPrice"
          }
        }
      }
    },
    "source": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "url",
        "fields"
      ],
      "properties": {
        "url": {
          "$ref": "#/$defs/httpsUrl"
        },
        "fields": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "$ref": "#/$defs/sourceField"
          }
        }
      }
    },
    "model": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "provider",
        "name",
        "api_id",
        "release_date",
        "status",
        "deprecation_date",
        "retirement_date",
        "pricing",
        "context_window",
        "max_output_tokens",
        "modalities",
        "open_weights",
        "availability",
        "sources",
        "last_verified"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z0-9-]+/[a-z0-9][a-z0-9._-]*$"
        },
        "provider": {
          "type": "string",
          "minLength": 1
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "api_id": {
          "type": [
            "string",
            "null"
          ],
          "minLength": 1
        },
        "release_date": {
          "$ref": "#/$defs/nullableDate"
        },
        "status": {
          "description": "ga only when the provider states general availability; available = listed and callable, status not stated.",
          "enum": [
            "preview",
            "available",
            "ga",
            "deprecated",
            "retired"
          ]
        },
        "deprecation_date": {
          "$ref": "#/$defs/nullableDate"
        },
        "retirement_date": {
          "$ref": "#/$defs/nullableDate"
        },
        "announcement_url": {
          "anyOf": [
            {
              "$ref": "#/$defs/httpsUrl"
            },
            {
              "type": "null"
            }
          ]
        },
        "pricing": {
          "anyOf": [
            {
              "$ref": "#/$defs/pricing"
            },
            {
              "type": "null"
            }
          ]
        },
        "context_window": {
          "type": "integer",
          "minimum": 1000,
          "maximum": 100000000
        },
        "max_output_tokens": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 1
        },
        "modalities": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "input",
            "output"
          ],
          "properties": {
            "input": {
              "anyOf": [
                {
                  "type": "array",
                  "minItems": 1,
                  "uniqueItems": true,
                  "items": {
                    "$ref": "#/$defs/modality"
                  }
                },
                {
                  "type": "null"
                }
              ],
              "description": "Input/output types the provider states. null when not stated."
            },
            "output": {
              "anyOf": [
                {
                  "type": "array",
                  "minItems": 1,
                  "uniqueItems": true,
                  "items": {
                    "$ref": "#/$defs/modality"
                  }
                },
                {
                  "type": "null"
                }
              ],
              "description": "Input/output types the provider states. null when not stated."
            }
          }
        },
        "open_weights": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "available",
            "license"
          ],
          "properties": {
            "available": {
              "type": [
                "boolean",
                "null"
              ],
              "description": "null when the provider does not say."
            },
            "license": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        },
        "availability": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "enum": [
              "first-party",
              "self-hosted",
              "aws-bedrock",
              "google-vertex",
              "azure",
              "oci",
              "ibm-watsonx",
              "snowflake",
              "databricks",
              "nvidia-nim"
            ]
          }
        },
        "sources": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/source"
          }
        },
        "last_verified": {
          "$ref": "#/$defs/date"
        }
      }
    },
    "changelogEntry": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "date",
        "model_id",
        "provider",
        "type",
        "field",
        "old",
        "new",
        "source"
      ],
      "properties": {
        "date": {
          "$ref": "#/$defs/date"
        },
        "model_id": {
          "type": "string",
          "minLength": 1
        },
        "provider": {
          "type": "string",
          "minLength": 1
        },
        "type": {
          "enum": [
            "launch",
            "price",
            "spec",
            "status",
            "correction",
            "seed"
          ]
        },
        "field": {
          "type": "string",
          "minLength": 1,
          "description": "Dotted path such as pricing.input, or * for a whole new model."
        },
        "old": {},
        "new": {},
        "source": {
          "$ref": "#/$defs/httpsUrl"
        },
        "note": {
          "type": "string"
        }
      }
    },
    "changelog": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/changelogEntry"
      }
    },
    "status": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "last_checked",
        "last_changed",
        "last_run_url"
      ],
      "properties": {
        "last_checked": {
          "type": "string",
          "format": "date-time"
        },
        "last_changed": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "last_run_url": {
          "anyOf": [
            {
              "$ref": "#/$defs/httpsUrl"
            },
            {
              "type": "null"
            }
          ]
        }
      }
    }
  }
}
