{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://codingplans.dev/schemas/providers.schema.json",
  "title": "Provider catalogue",
  "description": "Per-million-token rates for API providers.",
  "type": "object",
  "required": ["providers"],
  "properties": {
    "providers": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": ["id", "name", "website", "rates_per_m", "source", "source_date"],
        "properties": {
          "id": { "type": "string", "pattern": "^[a-z0-9][a-z0-9-]*$" },
          "name": { "type": "string", "minLength": 1 },
          "website": { "type": "string", "pattern": "^https://" },
          "rates_per_m": {
            "type": "object",
            "minProperties": 1,
            "additionalProperties": {
              "type": "object",
              "required": ["input", "output"],
              "properties": {
                "input": { "type": "number", "minimum": 0 },
                "output": { "type": "number", "minimum": 0 },
                "cache_hit": { "type": "number", "minimum": 0 },
                "peak_input": { "type": "number", "minimum": 0 },
                "peak_output": { "type": "number", "minimum": 0 },
                "peak_cache_hit": { "type": "number", "minimum": 0 },
                "is_off_peak_rate": { "type": "boolean" }
              },
              "additionalProperties": true
            }
          },
          "source": { "type": "string", "pattern": "^https://" },
          "source_date": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$" }
        },
        "additionalProperties": true
      }
    }
  },
  "additionalProperties": false
}
