{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/upriver-ai/json-schema/upriver-ai-usage-response-schema.json",
  "title": "UsageResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/upriver-ai-account-api-openapi.yml#/components/schemas/UsageResponse",
  "properties": {
    "created_at": {
      "type": "integer",
      "title": "Created At"
    },
    "name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Name"
    },
    "email": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Email"
    },
    "usage_by_range": {
      "additionalProperties": {
        "$ref": "#/$defs/UsageByRange"
      },
      "type": "object",
      "title": "Usage By Range"
    },
    "usage_period": {
      "$ref": "#/$defs/UsagePeriod"
    },
    "pricing": {
      "anyOf": [
        {
          "additionalProperties": {
            "$ref": "#/$defs/PricingInfo"
          },
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Pricing"
    }
  },
  "type": "object",
  "required": [
    "created_at",
    "name",
    "email",
    "usage_by_range",
    "usage_period"
  ],
  "$defs": {
    "CreditFeatureData": {
      "properties": {
        "name": {
          "type": "string",
          "title": "Name"
        },
        "balance": {
          "type": "number",
          "title": "Balance"
        },
        "usage": {
          "type": "number",
          "title": "Usage"
        },
        "included_usage": {
          "type": "number",
          "title": "Included Usage"
        },
        "next_reset_at": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Next Reset At",
          "description": "Aggregate reset in UTC milliseconds. May be null for mixed schedules; inspect breakdown for individual resets."
        },
        "interval": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Interval",
          "description": "Reset cadence; multiple indicates combined credit schedules."
        },
        "interval_count": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Interval Count",
          "description": "Number of cadence units between resets, when known."
        },
        "breakdown": {
          "items": {
            "$ref": "#/$defs/FeatureBreakdown"
          },
          "type": "array",
          "title": "Breakdown",
          "description": "Current allowances grouped by credit schedule. These balances do not change with the requested history range. No main schedule is implied."
        },
        "usage_by_feature": {
          "additionalProperties": {
            "$ref": "#/$defs/UsageByFeature"
          },
          "type": "object",
          "title": "Usage By Feature"
        }
      },
      "type": "object",
      "required": [
        "name",
        "balance",
        "usage",
        "included_usage",
        "usage_by_feature"
      ],
      "title": "CreditFeatureData"
    },
    "FeatureBreakdown": {
      "properties": {
        "interval": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Interval",
          "description": "Reset cadence, or lifetime for no scheduled reset."
        },
        "interval_count": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Interval Count",
          "description": "Number of cadence units between resets, when known."
        },
        "balance": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Balance",
          "description": "Current remaining allowance for this credit schedule."
        },
        "usage": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Usage",
          "description": "Current usage charged to this credit schedule."
        },
        "included_usage": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Included Usage",
          "description": "Total allowance for this credit schedule."
        },
        "next_reset_at": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Next Reset At",
          "description": "Next reset in UTC milliseconds, or null when none is supplied."
        },
        "unlimited": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "title": "Unlimited",
          "description": "Whether this credit schedule has unlimited usage."
        }
      },
      "type": "object",
      "title": "FeatureBreakdown"
    },
    "PeriodUsage": {
      "properties": {
        "period": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "string"
            }
          ],
          "title": "Period"
        },
        "features": {
          "additionalProperties": {
            "type": "integer"
          },
          "type": "object",
          "title": "Features"
        }
      },
      "type": "object",
      "required": [
        "period",
        "features"
      ],
      "title": "PeriodUsage"
    },
    "PricingInfo": {
      "properties": {
        "amount": {
          "type": "number",
          "title": "Amount"
        },
        "unit": {
          "type": "string",
          "title": "Unit"
        },
        "interval": {
          "type": "string",
          "title": "Interval"
        },
        "included_usage": {
          "type": "integer",
          "title": "Included Usage"
        }
      },
      "type": "object",
      "required": [
        "amount",
        "unit",
        "interval",
        "included_usage"
      ],
      "title": "PricingInfo"
    },
    "SimpleFeatureData": {
      "properties": {
        "name": {
          "type": "string",
          "title": "Name"
        },
        "balance": {
          "type": "number",
          "title": "Balance"
        },
        "usage": {
          "type": "number",
          "title": "Usage"
        },
        "included_usage": {
          "type": "number",
          "title": "Included Usage"
        },
        "next_reset_at": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Next Reset At",
          "description": "Aggregate reset in UTC milliseconds. May be null for mixed schedules; inspect breakdown for individual resets."
        },
        "interval": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Interval",
          "description": "Reset cadence; multiple indicates combined credit schedules."
        },
        "interval_count": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Interval Count",
          "description": "Number of cadence units between resets, when known."
        },
        "breakdown": {
          "items": {
            "$ref": "#/$defs/FeatureBreakdown"
          },
          "type": "array",
          "title": "Breakdown",
          "description": "Current allowances grouped by credit schedule. These balances do not change with the requested history range. No main schedule is implied."
        }
      },
      "type": "object",
      "required": [
        "name",
        "balance",
        "usage",
        "included_usage"
      ],
      "title": "SimpleFeatureData"
    },
    "UsageByFeature": {
      "properties": {
        "credit_rate": {
          "type": "number",
          "title": "Credit Rate"
        },
        "quantity": {
          "type": "integer",
          "title": "Quantity"
        },
        "credits_used": {
          "type": "number",
          "title": "Credits Used"
        }
      },
      "type": "object",
      "required": [
        "credit_rate",
        "quantity",
        "credits_used"
      ],
      "title": "UsageByFeature"
    },
    "UsageByRange": {
      "properties": {
        "features": {
          "additionalProperties": {
            "anyOf": [
              {
                "$ref": "#/$defs/SimpleFeatureData"
              },
              {
                "$ref": "#/$defs/CreditFeatureData"
              }
            ]
          },
          "type": "object",
          "title": "Features"
        },
        "time_series": {
          "items": {
            "$ref": "#/$defs/PeriodUsage"
          },
          "type": "array",
          "title": "Time Series",
          "default": []
        }
      },
      "type": "object",
      "required": [
        "features"
      ],
      "title": "UsageByRange"
    },
    "UsagePeriod": {
      "properties": {
        "start": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Start",
          "description": "Shared current usage period start in UTC milliseconds, or null if no unambiguous shared period is available."
        },
        "end": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "End",
          "description": "Shared current usage period end in UTC milliseconds, or null if no unambiguous shared period is available."
        }
      },
      "type": "object",
      "required": [
        "start",
        "end"
      ],
      "title": "UsagePeriod"
    }
  }
}