{
  "openapi": "3.1.0",
  "info": {
    "title": "MorpheusAI Network Throughput API",
    "version": "1.0.0",
    "description": "Read-only, public JSON endpoints powering the tech.mor.org throughput dashboard. All values are on-chain aggregates mined from the MorpheusAI Inference Contract's SessionClosed receipts on Base. Aggregates only — no prompts, no user data, no PII. No authentication required; all endpoints are HTTP GET.",
    "contact": { "name": "MorpheusAI", "url": "https://mor.org" },
    "license": { "name": "Public educational content" }
  },
  "servers": [
    { "url": "https://tech.mor.org/api/throughput", "description": "Throughput rollups" }
  ],
  "tags": [
    { "name": "summary", "description": "Headline aggregates" },
    { "name": "rollups", "description": "Time-series rollups" },
    { "name": "breakdowns", "description": "Per-model / per-provider breakdowns" },
    { "name": "health", "description": "Network health" }
  ],
  "paths": {
    "/summary.json": {
      "get": {
        "tags": ["summary"],
        "operationId": "getSummary",
        "summary": "Headline network aggregates",
        "description": "Top-line totals across the tracked windows (24h / 7d / 30d / all): total on-chain tokens, session counts, and time-to-first-token (TTFT) figures.",
        "responses": {
          "200": {
            "description": "Summary aggregates",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Summary" } } }
          }
        }
      }
    },
    "/rollup/{bucket}.json": {
      "get": {
        "tags": ["rollups"],
        "operationId": "getRollup",
        "summary": "Time-series rollup at a given granularity",
        "description": "A series of time buckets with per-bucket aggregates. Retention by bucket: hourly ≈ last 14 days, daily ≈ last 365 days, monthly ≈ all time.",
        "parameters": [
          {
            "name": "bucket",
            "in": "path",
            "required": true,
            "description": "Rollup granularity.",
            "schema": { "type": "string", "enum": ["hourly", "daily", "monthly"] }
          }
        ],
        "responses": {
          "200": {
            "description": "Rollup series",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Rollup" } } }
          },
          "404": { "description": "Unknown bucket" }
        }
      }
    },
    "/rollup/by-model-daily.json": {
      "get": {
        "tags": ["breakdowns"],
        "operationId": "getByModelDaily",
        "summary": "Daily totals broken down by model",
        "responses": {
          "200": {
            "description": "Per-model daily series",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ByModelDaily" } } }
          }
        }
      }
    },
    "/rollup/by-provider-daily.json": {
      "get": {
        "tags": ["breakdowns"],
        "operationId": "getByProviderDaily",
        "summary": "Daily totals broken down by provider",
        "responses": {
          "200": {
            "description": "Per-provider daily series",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ByProviderDaily" } } }
          }
        }
      }
    },
    "/stuck-sessions.json": {
      "get": {
        "tags": ["health"],
        "operationId": "getStuckSessions",
        "summary": "Stuck-session health snapshot",
        "description": "Count and recent examples of sessions that opened but have not closed within the expected window — a network-health signal. Aggregates and on-chain identifiers only.",
        "responses": {
          "200": {
            "description": "Stuck-session health",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/StuckSessions" } } }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Bucket": {
        "type": "object",
        "description": "Aggregates for one time bucket.",
        "properties": {
          "ts": { "type": "integer", "description": "Unix timestamp (seconds) for the start of the bucket." },
          "tokens": { "type": "number", "description": "Total on-chain tokens settled in the bucket." },
          "sessions": { "type": "integer", "description": "Number of sessions closed in the bucket." },
          "ttft": { "type": "number", "description": "Representative time-to-first-token (seconds), where available." }
        },
        "additionalProperties": true
      },
      "Summary": {
        "type": "object",
        "description": "Headline aggregates keyed by window (e.g. 24h, 7d, 30d, all). Field set may evolve; treat as additive.",
        "additionalProperties": true
      },
      "Rollup": {
        "type": "object",
        "properties": {
          "bucket": { "type": "string", "enum": ["hourly", "daily", "monthly"] },
          "series": { "type": "array", "items": { "$ref": "#/components/schemas/Bucket" } }
        },
        "additionalProperties": true
      },
      "ByModelDaily": {
        "type": "object",
        "properties": {
          "models": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "modelId": { "type": "string" },
                "name": { "type": "string" },
                "series": { "type": "array", "items": { "$ref": "#/components/schemas/Bucket" } }
              },
              "additionalProperties": true
            }
          }
        },
        "additionalProperties": true
      },
      "ByProviderDaily": {
        "type": "object",
        "properties": {
          "providers": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "provider": { "type": "string" },
                "series": { "type": "array", "items": { "$ref": "#/components/schemas/Bucket" } }
              },
              "additionalProperties": true
            }
          }
        },
        "additionalProperties": true
      },
      "StuckSessions": {
        "type": "object",
        "properties": {
          "count": { "type": "integer", "description": "Number of currently stuck sessions." },
          "sessions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "sessionId": { "type": "string" },
                "openedAt": { "type": "integer", "description": "Unix timestamp (seconds)." }
              },
              "additionalProperties": true
            }
          }
        },
        "additionalProperties": true
      }
    }
  }
}
