{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://apitracker.io/schemas/llm-price-history-v1.json",
  "title": "API Tracker LLM API Price Watch snapshot",
  "type": "object",
  "required": ["schema", "title", "as_of", "source", "unit", "series", "observation_count", "history_start", "coverage", "backfill", "methodology", "citation", "rows"],
  "properties": {
    "schema": {"const": "https://apitracker.io/schemas/llm-price-history-v1.json"},
    "title": {"type": "string"},
    "as_of": {"type": "string", "format": "date"},
    "source": {"const": "OpenRouter routed model quotes"},
    "unit": {"const": "USD per 1 million tokens"},
    "series": {"type": "integer", "minimum": 0},
    "observation_count": {"type": "integer", "minimum": 0},
    "history_start": {"type": ["string", "null"], "format": "date"},
    "coverage": {"type": "object", "required": ["from", "through", "observation_days"], "properties": {"from": {"type": ["string", "null"], "format": "date"}, "through": {"type": "string", "format": "date"}, "observation_days": {"type": "integer", "minimum": 0}}, "additionalProperties": false},
    "backfill": {"type": ["object", "null"]},
    "methodology": {"type": "string"},
    "citation": {"type": "string"},
    "rows": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["observed_date_utc", "source", "model_id", "model", "provider", "input_usd_per_1m_tokens", "output_usd_per_1m_tokens", "variable_pricing", "additional_charges", "provenance", "source_url", "source_commit", "source_run"],
        "properties": {
          "observed_date_utc": {"type": "string", "format": "date"},
          "source": {"const": "OpenRouter"},
          "model_id": {"type": "string"},
          "model": {"type": "string"},
          "provider": {"type": "string"},
          "input_usd_per_1m_tokens": {"type": ["number", "null"], "minimum": 0},
          "output_usd_per_1m_tokens": {"type": ["number", "null"], "minimum": 0},
          "variable_pricing": {"type": ["boolean", "null"]},
          "additional_charges": {"type": ["boolean", "null"]},
          "provenance": {"enum": ["git-snapshot", "source-fetch", "external-change-log"]},
          "source_url": {"type": "string", "format": "uri"},
          "source_commit": {"type": "string"},
          "source_run": {"type": "string"},
          "source_run_commit": {"type": "string"}
        },
        "allOf": [
          {"if": {"properties": {"provenance": {"const": "git-snapshot"}}, "required": ["provenance"]}, "then": {"properties": {"source_commit": {"pattern": "^[a-f0-9]{40}$"}, "variable_pricing": {"type": "boolean"}, "additional_charges": {"type": "boolean"}}}},
          {"if": {"properties": {"provenance": {"const": "source-fetch"}}, "required": ["provenance"]}, "then": {"properties": {"variable_pricing": {"type": "boolean"}, "additional_charges": {"type": "boolean"}}}},
          {"if": {"properties": {"provenance": {"const": "external-change-log"}}, "required": ["provenance"]}, "then": {"properties": {"source_commit": {"pattern": "^[a-f0-9]{40}$"}, "source_run_commit": {"pattern": "^[a-f0-9]{40}$"}, "variable_pricing": {"type": "null"}, "additional_charges": {"type": "null"}}}}
        ]
      }
    }
  }
}
