{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schemas.kxm.dev/prices.schema.json",
  "title": "KXM price catalog",
  "type": "object",
  "required": [
    "schema",
    "date",
    "sha256",
    "models"
  ],
  "properties": {
    "schema": {
      "const": "kxm.prices.v1"
    },
    "date": {
      "type": "string",
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
    },
    "sha256": {
      "type": "string",
      "pattern": "^(?:sha256:)?[a-f0-9]{64}$"
    },
    "currency": {
      "type": "string",
      "pattern": "^[A-Z]{3}$"
    },
    "models": {
      "type": "array",
      "minItems": 1,
      "maxItems": 256,
      "items": {
        "type": "object",
        "required": [
          "id",
          "provider",
          "model",
          "tiers"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          },
          "provider": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "model": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          },
          "aliases": {
            "type": "array",
            "maxItems": 32,
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            }
          },
          "tiers": {
            "type": "array",
            "minItems": 1,
            "maxItems": 32,
            "items": {
              "type": "object",
              "required": [
                "inputPerMillion",
                "outputPerMillion"
              ],
              "properties": {
                "upToContextTokens": {
                  "type": [
                    "integer",
                    "null"
                  ],
                  "minimum": 1
                },
                "inputPerMillion": {
                  "type": "number",
                  "minimum": 0
                },
                "outputPerMillion": {
                  "type": "number",
                  "minimum": 0
                },
                "cacheReadPerMillion": {
                  "type": [
                    "number",
                    "null"
                  ],
                  "minimum": 0
                },
                "cacheWritePerMillion": {
                  "type": [
                    "number",
                    "null"
                  ],
                  "minimum": 0
                }
              },
              "additionalProperties": false
            }
          }
        },
        "additionalProperties": false
      }
    }
  },
  "additionalProperties": false
}
