{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://loop.firmiana.si/prices/v1/rankings.schema.json",
  "title": "LLM capability rankings",
  "description": "Scores copied from public leaderboards, matched to the model keys of models.json (provider/id), and composite rankings computed from them. Version 1: fields are only ever added, never renamed or removed.",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema", "version", "generated_at", "license", "attribution", "note", "sources", "boards", "composites"],
  "$defs": {
    "text": {
      "type": "object",
      "additionalProperties": false,
      "required": ["en", "zh"],
      "properties": { "en": { "type": "string", "minLength": 1 }, "zh": { "type": "string", "minLength": 1 } }
    },
    "key": { "type": "string", "pattern": "^[a-z0-9-]+/[^/\\s]+$", "description": "Model key in models.json: provider/id." },
    "date": { "type": "string", "format": "date" },
    "datetime": { "type": "string", "format": "date-time" }
  },
  "properties": {
    "schema": { "type": "string", "format": "uri" },
    "version": { "const": 1 },
    "generated_at": { "$ref": "#/$defs/datetime" },
    "license": { "type": "string", "description": "Licence of this file; each source's own licence and credit line are in `sources`." },
    "attribution": { "type": "array", "items": { "type": "string" }, "minItems": 1 },
    "note": { "type": "string" },
    "sources": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "name", "name_zh", "url", "data_url", "license", "attribution", "terms", "method", "retrieved_at", "revision"],
        "properties": {
          "id": { "type": "string", "pattern": "^[a-z0-9-]+$" },
          "name": { "type": "string" },
          "name_zh": { "type": "string" },
          "url": { "type": "string", "format": "uri", "description": "The leaderboard people read." },
          "data_url": { "type": "string", "format": "uri", "description": "Where the numbers were read from." },
          "license": { "type": "string" },
          "attribution": { "type": "string" },
          "terms": { "type": "string", "description": "What the source's terms allow, and when that was checked." },
          "method": { "type": "string" },
          "retrieved_at": { "$ref": "#/$defs/datetime" },
          "revision": { "type": ["string", "null"], "description": "The publisher's dataset revision or release id that was read." }
        }
      }
    },
    "boards": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "source", "title", "metric", "higher_is_better", "url", "published", "retrieved_at", "entry_count", "unmatched_count", "entries"],
        "properties": {
          "id": { "type": "string", "pattern": "^[a-z0-9-]+$" },
          "source": { "type": "string", "description": "A `sources[].id`." },
          "title": { "$ref": "#/$defs/text" },
          "metric": { "$ref": "#/$defs/text" },
          "higher_is_better": { "type": "boolean" },
          "url": { "type": "string", "format": "uri" },
          "published": { "$ref": "#/$defs/date", "description": "The date the publisher gives this board." },
          "retrieved_at": { "$ref": "#/$defs/datetime" },
          "entry_count": { "type": "integer", "minimum": 0, "description": "Entries on the board, matched or not." },
          "unmatched_count": { "type": "integer", "minimum": 0, "description": "Entries that matched no model in models.json (older models, models not listed there)." },
          "entries": {
            "type": "array",
            "description": "One entry per matched model (its best entry on the board), highest score first.",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": ["key", "name", "source_rank", "score"],
              "properties": {
                "key": { "$ref": "#/$defs/key" },
                "name": { "type": "string", "description": "The entry's name on the board, setting included, e.g. \"Claude Opus 5.5 (High)\"." },
                "source_rank": { "type": "number", "minimum": 1, "description": "Rank on the board itself, among all its entries." },
                "score": { "type": "number" },
                "ci": { "type": "array", "items": { "type": ["number", "null"] }, "minItems": 2, "maxItems": 2, "description": "Lower and upper confidence bound, where the board gives one." },
                "votes": { "type": ["integer", "null"], "minimum": 0 }
              }
            }
          }
        }
      }
    },
    "composites": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "title", "inputs", "min_inputs", "model_count", "rule", "entries"],
        "properties": {
          "id": { "enum": ["overall", "coding", "reasoning"] },
          "title": { "$ref": "#/$defs/text" },
          "inputs": { "type": "array", "items": { "type": "string" }, "minItems": 1, "description": "`boards[].id` combined." },
          "min_inputs": { "type": "integer", "minimum": 1 },
          "model_count": { "type": "integer", "minimum": 0 },
          "rule": { "$ref": "#/$defs/text" },
          "entries": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": ["rank", "key", "score", "parts"],
              "properties": {
                "rank": { "type": "integer", "minimum": 1 },
                "key": { "$ref": "#/$defs/key" },
                "score": { "type": "number", "minimum": 0, "maximum": 100, "description": "Mean percentile across the inputs." },
                "parts": {
                  "type": "object",
                  "description": "Per input board: the board's own score and the percentile it gave.",
                  "additionalProperties": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": ["score", "percentile"],
                    "properties": { "score": { "type": "number" }, "percentile": { "type": "number", "minimum": 0, "maximum": 100 } }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
