{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://loop.firmiana.si/prices/v1/models.schema.json",
  "title": "LLM Pricebook models.json (v1)",
  "description": "Merged dataset of official LLM API prices. Token prices are per 1M tokens in the currency the provider publishes. The `converted` objects are for display only.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema",
    "version",
    "generated_at",
    "unit",
    "license",
    "homepage",
    "repository",
    "fx",
    "providers",
    "models"
  ],
  "properties": {
    "schema": {
      "const": "https://loop.firmiana.si/prices/v1/models.schema.json"
    },
    "version": {
      "const": 1
    },
    "generated_at": {
      "type": "string",
      "format": "date-time"
    },
    "unit": {
      "const": "per 1M tokens"
    },
    "license": {
      "const": "CC-BY-4.0"
    },
    "homepage": {
      "type": "string",
      "format": "uri"
    },
    "repository": {
      "type": "string",
      "format": "uri"
    },
    "fx": {
      "description": "Exchange rates used for the `converted` fields. Units of each currency per 1 USD.",
      "type": "object",
      "additionalProperties": false,
      "required": [
        "date",
        "source",
        "source_url",
        "per_usd"
      ],
      "properties": {
        "date": {
          "type": "string",
          "format": "date"
        },
        "source": {
          "type": "string"
        },
        "source_url": {
          "type": "string",
          "format": "uri"
        },
        "per_usd": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "USD",
            "CNY",
            "EUR"
          ],
          "properties": {
            "USD": {
              "const": 1
            },
            "CNY": {
              "type": "number",
              "exclusiveMinimum": 0
            },
            "EUR": {
              "type": "number",
              "exclusiveMinimum": 0
            }
          }
        }
      }
    },
    "providers": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "name",
          "name_zh",
          "kind",
          "region",
          "website",
          "pricing_pages",
          "model_count"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "name_zh": {
            "type": [
              "string",
              "null"
            ]
          },
          "region": {
            "enum": [
              "intl",
              "cn"
            ]
          },
          "website": {
            "type": "string",
            "format": "uri"
          },
          "pricing_pages": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri"
            }
          },
          "model_count": {
            "type": "integer",
            "minimum": 0
          },
          "kind": {
            "enum": [
              "maker",
              "cloud",
              "router"
            ]
          }
        }
      }
    },
    "models": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/model"
      }
    }
  },
  "$defs": {
    "num": {
      "type": [
        "number",
        "null"
      ],
      "minimum": 0
    },
    "converted": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "rate",
        "input",
        "output",
        "cache_write",
        "cache_write_long",
        "cache_read",
        "cache_storage_per_hour"
      ],
      "properties": {
        "rate": {
          "type": "number",
          "exclusiveMinimum": 0,
          "description": "Units of this currency per 1 unit of the row's currency."
        },
        "input": {
          "$ref": "#/$defs/num"
        },
        "output": {
          "$ref": "#/$defs/num"
        },
        "cache_write": {
          "$ref": "#/$defs/num"
        },
        "cache_write_long": {
          "$ref": "#/$defs/num"
        },
        "cache_read": {
          "$ref": "#/$defs/num"
        },
        "cache_storage_per_hour": {
          "$ref": "#/$defs/num"
        }
      }
    },
    "price": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "tier",
        "region",
        "currency",
        "input",
        "output",
        "cache_write",
        "cache_write_ttl",
        "cache_write_long",
        "cache_write_long_ttl",
        "cache_read",
        "cache_storage_per_hour",
        "when",
        "note",
        "source",
        "converted",
        "from",
        "until"
      ],
      "properties": {
        "tier": {
          "enum": [
            "standard",
            "batch",
            "flex",
            "priority",
            "fast"
          ]
        },
        "region": {
          "type": [
            "string",
            "null"
          ]
        },
        "currency": {
          "enum": [
            "USD",
            "CNY",
            "EUR"
          ]
        },
        "input": {
          "$ref": "#/$defs/num"
        },
        "output": {
          "$ref": "#/$defs/num"
        },
        "cache_write": {
          "$ref": "#/$defs/num"
        },
        "cache_write_ttl": {
          "type": [
            "string",
            "null"
          ]
        },
        "cache_write_long": {
          "$ref": "#/$defs/num"
        },
        "cache_write_long_ttl": {
          "type": [
            "string",
            "null"
          ]
        },
        "cache_read": {
          "$ref": "#/$defs/num"
        },
        "cache_storage_per_hour": {
          "$ref": "#/$defs/num"
        },
        "when": {
          "type": [
            "object",
            "null"
          ],
          "additionalProperties": false,
          "properties": {
            "input_tokens_gt": {
              "type": "integer"
            },
            "input_tokens_lte": {
              "type": "integer"
            },
            "output_tokens_gt": {
              "type": "integer"
            },
            "output_tokens_lte": {
              "type": "integer"
            },
            "mode": {
              "enum": [
                "thinking",
                "non-thinking"
              ]
            },
            "time": {
              "type": "string"
            }
          }
        },
        "note": {
          "type": [
            "string",
            "null"
          ]
        },
        "source": {
          "type": "string",
          "format": "uri"
        },
        "converted": {
          "description": "Display-only conversion into the other currencies, using the top-level fx rates. Not an official price.",
          "type": "object",
          "additionalProperties": false,
          "required": [
            "fx_date"
          ],
          "properties": {
            "fx_date": {
              "type": "string",
              "format": "date"
            },
            "USD": {
              "$ref": "#/$defs/converted"
            },
            "CNY": {
              "$ref": "#/$defs/converted"
            },
            "EUR": {
              "$ref": "#/$defs/converted"
            }
          }
        },
        "from": {
          "type": [
            "string",
            "null"
          ],
          "format": "date"
        },
        "until": {
          "type": [
            "string",
            "null"
          ],
          "format": "date"
        }
      }
    },
    "model": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "key",
        "provider",
        "id",
        "name",
        "family",
        "aliases",
        "status",
        "context_window",
        "max_output",
        "release_date",
        "knowledge",
        "modalities",
        "open_weights",
        "capabilities",
        "prices",
        "upcoming",
        "sources",
        "verified",
        "unverified",
        "notes"
      ],
      "properties": {
        "key": {
          "type": "string",
          "description": "provider/id, unique across the dataset"
        },
        "provider": {
          "type": "string"
        },
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "family": {
          "type": [
            "string",
            "null"
          ]
        },
        "aliases": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "status": {
          "enum": [
            "active",
            "preview",
            "legacy",
            "deprecated"
          ]
        },
        "context_window": {
          "type": [
            "integer",
            "null"
          ]
        },
        "max_output": {
          "type": [
            "integer",
            "null"
          ]
        },
        "release_date": {
          "type": [
            "string",
            "null"
          ],
          "format": "date"
        },
        "knowledge": {
          "type": [
            "string",
            "null"
          ]
        },
        "modalities": {
          "type": [
            "object",
            "null"
          ],
          "additionalProperties": false,
          "required": [
            "input",
            "output"
          ],
          "properties": {
            "input": {
              "type": "array",
              "items": {
                "enum": [
                  "text",
                  "image",
                  "audio",
                  "video",
                  "pdf",
                  "file"
                ]
              }
            },
            "output": {
              "type": "array",
              "items": {
                "enum": [
                  "text",
                  "image",
                  "audio",
                  "video",
                  "pdf",
                  "file"
                ]
              }
            }
          }
        },
        "open_weights": {
          "type": [
            "boolean",
            "null"
          ]
        },
        "capabilities": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "tools",
            "vision",
            "reasoning",
            "prompt_caching",
            "structured_output"
          ],
          "properties": {
            "tools": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "vision": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "reasoning": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "prompt_caching": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "structured_output": {
              "type": [
                "boolean",
                "null"
              ]
            }
          }
        },
        "prices": {
          "description": "prices[0] is the provider's main price (standard tier, no region). Rows with `when` apply only inside that band.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/price"
          }
        },
        "upcoming": {
          "description": "Announced prices that start later (each row has `from`). They move into `prices` on that day.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/price"
          }
        },
        "sources": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "pricing",
            "specs"
          ],
          "properties": {
            "pricing": {
              "type": "string",
              "format": "uri"
            },
            "specs": {
              "type": [
                "string",
                "null"
              ],
              "format": "uri"
            }
          }
        },
        "verified": {
          "type": "string",
          "format": "date"
        },
        "unverified": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "notes": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    }
  }
}
