{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/api-stock-com/json-schema/api-stock-com-stats-response-dto-schema.json",
  "title": "StatsResponseDto",
  "x-generated": "2026-10-30",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/api-stock-com-openapi.json#/components/schemas/StatsResponseDto",
  "type": "object",
  "properties": {
    "from": {
      "type": "string",
      "description": "Period start actually used (ISO 8601)"
    },
    "to": {
      "type": "string",
      "description": "Period end actually used (ISO 8601)"
    },
    "totals": {
      "$ref": "#/$defs/StatsTotalsDto"
    },
    "byDay": {
      "description": "Spend per day, ascending, gaps filled with zeroes",
      "type": "array",
      "items": {
        "$ref": "#/$defs/StatsBucketDto"
      }
    },
    "byModel": {
      "description": "Spend per model, most expensive first",
      "type": "array",
      "items": {
        "$ref": "#/$defs/StatsBucketDto"
      }
    },
    "byType": {
      "description": "Spend per generation type",
      "type": "array",
      "items": {
        "$ref": "#/$defs/StatsBucketDto"
      }
    }
  },
  "required": [
    "from",
    "to",
    "totals",
    "byDay",
    "byModel",
    "byType"
  ],
  "$defs": {
    "StatsBucketDto": {
      "type": "object",
      "properties": {
        "key": {
          "type": "string",
          "description": "Bucket key — a date (YYYY-MM-DD) or model id"
        },
        "count": {
          "type": "number",
          "description": "Number of generations in the bucket"
        },
        "cost": {
          "type": "number",
          "description": "Amount spent in the bucket, in cents; refunded failures excluded"
        }
      },
      "required": [
        "key",
        "count",
        "cost"
      ]
    },
    "StatsTotalsDto": {
      "type": "object",
      "properties": {
        "balance": {
          "type": "number",
          "description": "Current balance, in cents"
        },
        "spent": {
          "type": "number",
          "description": "Spent within the selected period, in cents. Failed generations are refunded, so they are not counted here even though they count as requests"
        },
        "spentAllTime": {
          "type": "number",
          "description": "Spent since registration, in cents; refunded failures excluded"
        },
        "requests": {
          "type": "number",
          "description": "Generations created within the period"
        },
        "succeeded": {
          "type": "number",
          "description": "Generations finished successfully"
        },
        "failed": {
          "type": "number",
          "description": "Generations that ended in an error"
        },
        "inProgress": {
          "type": "number",
          "description": "Generations still running"
        },
        "llmRequests": {
          "type": "number",
          "description": "LLM chat requests within the period"
        },
        "llmTokens": {
          "type": "number",
          "description": "LLM tokens consumed within the period"
        }
      },
      "required": [
        "balance",
        "spent",
        "spentAllTime",
        "requests",
        "succeeded",
        "failed",
        "inProgress",
        "llmRequests",
        "llmTokens"
      ]
    }
  }
}