{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/beatapi/json-schema/beatapi-usage-response-schema.json",
  "title": "UsageResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/beatapi-usage-api-openapi.yml#/components/schemas/UsageResponse",
  "type": "object",
  "required": [
    "data"
  ],
  "properties": {
    "data": {
      "$ref": "#/$defs/Usage"
    }
  },
  "$defs": {
    "Usage": {
      "type": "object",
      "required": [
        "object",
        "period",
        "credit_balance",
        "total_tasks",
        "credits_settled",
        "credits_refunded",
        "concurrency",
        "by_workflow",
        "by_capability",
        "by_model",
        "by_api_key"
      ],
      "properties": {
        "object": {
          "type": "string",
          "enum": [
            "usage"
          ]
        },
        "period": {
          "type": "string",
          "enum": [
            "all",
            "24h",
            "7d",
            "30d"
          ],
          "description": "The window `total_tasks`, `credits_settled`, `credits_refunded` and the breakdowns cover. `credit_balance` and `concurrency` are always current."
        },
        "since": {
          "type": "integer",
          "description": "Unix start of the window, inclusive. Absent when `period` is `all`."
        },
        "until": {
          "type": "integer",
          "description": "Unix end of the window, exclusive. Absent when `period` is `all`."
        },
        "credit_balance": {
          "type": "number",
          "format": "double",
          "multipleOf": 0.01,
          "description": "Current USD balance. The compatibility field name is retained; 1 Credit equals $1 USD. The balance may be negative."
        },
        "total_tasks": {
          "type": "integer"
        },
        "credits_settled": {
          "type": "number",
          "format": "double",
          "multipleOf": 0.01
        },
        "credits_refunded": {
          "type": "number",
          "format": "double",
          "multipleOf": 0.01
        },
        "concurrency": {
          "type": "object",
          "required": [
            "limit",
            "active"
          ],
          "properties": {
            "limit": {
              "type": "integer"
            },
            "active": {
              "type": "integer",
              "description": "Active processing tasks currently using BeatAPI processing resources. Music Video storyboard_ready and requires_action tasks can have settled USD usage without counting toward this value."
            }
          }
        },
        "by_workflow": {
          "type": "array",
          "description": "Compatibility view containing workflow tasks only. Image, video, and Effect tasks are reported under by_capability instead.",
          "items": {
            "type": "object",
            "required": [
              "workflow",
              "tasks",
              "credits_settled"
            ],
            "properties": {
              "workflow": {
                "type": "string",
                "enum": [
                  "music-video",
                  "ecommerce-video",
                  "video-analysis"
                ]
              },
              "tasks": {
                "type": "integer"
              },
              "credits_settled": {
                "type": "number",
                "format": "double",
                "multipleOf": 0.01
              }
            }
          }
        },
        "by_capability": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "task_kind",
              "capability_id",
              "tasks",
              "credits_settled"
            ],
            "properties": {
              "task_kind": {
                "type": "string",
                "enum": [
                  "workflow",
                  "effect",
                  "image",
                  "video"
                ]
              },
              "capability_id": {
                "type": "string"
              },
              "tasks": {
                "type": "integer"
              },
              "credits_settled": {
                "type": "number",
                "format": "double",
                "multipleOf": 0.01
              }
            }
          }
        },
        "by_model": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "media_type",
              "model",
              "tasks",
              "credits_settled"
            ],
            "properties": {
              "media_type": {
                "type": "string",
                "enum": [
                  "image",
                  "video"
                ]
              },
              "model": {
                "type": "string"
              },
              "tasks": {
                "type": "integer"
              },
              "credits_settled": {
                "type": "number",
                "format": "double",
                "multipleOf": 0.01
              }
            }
          }
        },
        "by_api_key": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "api_key_id",
              "title",
              "key_prefix",
              "tasks",
              "credits_settled"
            ],
            "properties": {
              "api_key_id": {
                "type": "string"
              },
              "title": {
                "type": "string"
              },
              "key_prefix": {
                "type": "string"
              },
              "tasks": {
                "type": "integer"
              },
              "credits_settled": {
                "type": "number",
                "format": "double",
                "multipleOf": 0.01
              }
            }
          }
        },
        "realtime": {
          "type": "object",
          "required": [
            "sessions",
            "credits",
            "active"
          ],
          "properties": {
            "sessions": {
              "type": "integer",
              "description": "Total BeatAPI realtime sessions for this account."
            },
            "credits": {
              "type": "number",
              "format": "double",
              "multipleOf": 0.01,
              "description": "USD amount settled by connected realtime sessions."
            },
            "active": {
              "type": "integer",
              "description": "Realtime sessions in ready, connecting, or active state."
            }
          }
        }
      }
    }
  }
}