{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://quotas.md/schema/v1",
  "title": "API Quota Description Schema v1",
  "type": "object",
  "required": [
    "service",
    "version",
    "endpoints"
  ],
  "properties": {
    "service": {
      "type": "string",
      "minLength": 1
    },
    "version": {
      "type": "string",
      "minLength": 1
    },
    "provider": {
      "type": "string"
    },
    "description": {
      "type": "string"
    },
    "endpoints": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "path",
          "quotas"
        ],
        "properties": {
          "path": {
            "type": "string",
            "minLength": 1
          },
          "method": {
            "type": "string"
          },
          "identifier": {
            "type": "string"
          },
          "models": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "quotas": {
            "type": "object",
            "required": [
              "rate_limit"
            ],
            "properties": {
              "rate_limit": {
                "type": "object",
                "required": [
                  "unit"
                ],
                "properties": {
                  "requests_per_unit": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "tokens_per_unit": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "unit": {
                    "type": "string",
                    "enum": [
                      "second",
                      "minute",
                      "hour",
                      "day"
                    ]
                  },
                  "burst_multiplier": {
                    "type": "number",
                    "minimum": 1
                  },
                  "strategy": {
                    "type": "string",
                    "enum": [
                      "token_bucket",
                      "leaky_bucket",
                      "fixed_window",
                      "sliding_window"
                    ]
                  }
                },
                "additionalProperties": false
              },
              "pricing": {
                "type": "object",
                "properties": {
                  "input_cost_per_1k": {
                    "type": "number",
                    "minimum": 0
                  },
                  "output_cost_per_1k": {
                    "type": "number",
                    "minimum": 0
                  },
                  "request_cost": {
                    "type": "number",
                    "minimum": 0
                  },
                  "currency": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "additionalProperties": false
              }
            },
            "additionalProperties": false
          },
          "error_handling": {
            "type": "object",
            "properties": {
              "rate_limit_status_codes": {
                "type": "array",
                "items": {
                  "type": "integer"
                }
              },
              "retry_after_header": {
                "type": "string"
              },
              "backoff_multiplier": {
                "type": "number",
                "minimum": 1
              },
              "max_backoff_seconds": {
                "type": "integer",
                "minimum": 0
              }
            },
            "additionalProperties": false
          }
        },
        "additionalProperties": false
      }
    },
    "metadata": {
      "type": "object",
      "properties": {
        "schema_version": {
          "type": "string"
        },
        "documentation_url": {
          "type": "string",
          "format": "uri"
        },
        "last_updated": {
          "type": "string",
          "format": "date-time"
        }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}


