{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://loop.firmiana.si/api/v1/schemas/models.schema.json",
  "title": "Compact list of models (api/v1/models.json and every api/v1/models/by-*/… slice)",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema", "version", "generated_at", "license", "unit", "filter", "count", "models"],
  "properties": {
    "schema": { "type": "string", "format": "uri" }, "version": { "const": 1 }, "generated_at": { "type": "string", "format": "date-time" }, "license": { "const": "CC-BY-4.0" },
    "unit": { "const": "per 1M tokens" },
    "filter": { "type": ["object", "null"], "description": "The filter this slice applies, null for all models" },
    "count": { "type": "integer" },
    "models": { "type": "array", "items": { "$ref": "#/$defs/model" } }
  },
  "$defs": {
    "price": {
      "type": ["object", "null"],
      "additionalProperties": false,
      "required": ["currency", "input", "output", "cache_read", "cache_write", "usd"],
      "description": "Main price (standard tier, no region) in the currency the maker publishes, per 1M tokens",
      "properties": {
        "currency": { "enum": ["USD", "CNY", "EUR"] },
        "input": { "type": ["number", "null"] },
        "output": { "type": ["number", "null"] },
        "cache_read": { "type": ["number", "null"] },
        "cache_write": { "type": ["number", "null"] },
        "usd": {
          "type": ["object", "null"],
          "additionalProperties": false,
          "required": ["input", "output", "fx_date"],
          "description": "Converted with the ECB rate of fx_date, for comparison only; null when already USD",
          "properties": { "input": { "type": ["number", "null"] }, "output": { "type": ["number", "null"] }, "fx_date": { "type": "string", "format": "date" } }
        }
      }
    },
    "model": {
      "type": "object",
      "additionalProperties": false,
      "required": ["key", "provider", "id", "name", "family", "status", "region", "release_date", "context_window", "max_output", "open_weights", "modalities", "capabilities", "price", "upcoming", "offers", "verified", "url"],
      "properties": {
        "key": { "type": "string", "description": "provider/id, stable" },
        "provider": { "type": "string" },
        "id": { "type": "string", "description": "The maker's own model id" },
        "name": { "type": "string" },
        "family": { "type": ["string", "null"] },
        "status": { "type": "string" },
        "region": { "enum": ["intl", "cn"], "description": "Where the maker is based" },
        "release_date": { "type": ["string", "null"] },
        "context_window": { "type": ["integer", "null"] },
        "max_output": { "type": ["integer", "null"] },
        "open_weights": { "type": ["boolean", "null"] },
        "modalities": { "type": ["object", "null"] },
        "capabilities": { "type": ["object", "null"] },
        "price": { "$ref": "#/$defs/price" },
        "upcoming": { "type": "boolean", "description": "An announced future price exists; see the model file" },
        "offers": { "type": "integer", "description": "Number of cloud and router offers for this model" },
        "verified": { "type": "string", "format": "date" },
        "url": { "type": "string", "format": "uri", "description": "The model's own file with all price rows and offers" }
      }
    }
  }
}
