{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/apipass/main/json-schema/apipass-calculate-credits-response-schema.json",
  "title": "CalculateCreditsResponse",
  "description": "计算积分响应",
  "x-generated": "2026-10-16",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/apipass-openapi.json#/components/schemas/CalculateCreditsResponse",
  "properties": {
    "credit_cost": {
      "type": "number",
      "title": "Credit Cost",
      "description": "积分消耗"
    },
    "cost_unit": {
      "type": "string",
      "title": "Cost Unit",
      "description": "收费单位，如 per run/per second/per video/per million tokens",
      "default": "per run"
    },
    "matched_rule_name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Matched Rule Name",
      "description": "匹配的规则名称"
    },
    "matched_rule_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Matched Rule Id",
      "description": "匹配的规则ID"
    },
    "channel_type": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Channel Type",
      "description": "实际计费类别：starter / enterprise / custom_enterprise / regular / official"
    },
    "matched_rule": {
      "anyOf": [
        {
          "$ref": "#/$defs/CreditRuleInfo"
        },
        {
          "type": "null"
        }
      ],
      "description": "真实计费路径命中的完整积分规则"
    },
    "matched_rules": {
      "items": {
        "$ref": "#/$defs/CreditRuleInfo"
      },
      "type": "array",
      "title": "Matched Rules",
      "description": "当前参数跨渠道命中的规则列表"
    },
    "is_default": {
      "type": "boolean",
      "title": "Is Default",
      "description": "是否使用默认积分"
    }
  },
  "type": "object",
  "required": [
    "credit_cost",
    "is_default"
  ],
  "$defs": {
    "CreditRuleInfo": {
      "properties": {
        "id": {
          "type": "string",
          "title": "Id",
          "description": "规则ID"
        },
        "name": {
          "type": "string",
          "title": "Name",
          "description": "规则名称"
        },
        "description": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Description",
          "description": "规则描述"
        },
        "conditions": {
          "additionalProperties": true,
          "type": "object",
          "title": "Conditions",
          "description": "匹配条件"
        },
        "credit_cost": {
          "type": "number",
          "title": "Credit Cost",
          "description": "积分消耗"
        },
        "token_prices": {
          "anyOf": [
            {
              "additionalProperties": true,
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "title": "Token Prices",
          "description": "Token 分项价格，如 input/output/cache_read"
        },
        "competitor_prices": {
          "anyOf": [
            {
              "items": {
                "additionalProperties": true,
                "type": "object"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "title": "Competitor Prices",
          "description": "规则级竞品价格列表"
        },
        "cost_unit": {
          "type": "string",
          "title": "Cost Unit",
          "description": "收费单位，如 per run/per second/per video",
          "default": "per run"
        },
        "priority": {
          "type": "integer",
          "title": "Priority",
          "description": "优先级"
        },
        "sort_order": {
          "type": "integer",
          "title": "Sort Order",
          "description": "价格展示排序，数值越大越靠前",
          "default": 0
        },
        "channel_type": {
          "type": "string",
          "title": "Channel Type",
          "description": "价格类别：starter / enterprise / regular / official",
          "default": "regular"
        },
        "starter_call_limit": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Starter Call Limit",
          "description": "Starter 每用户次数上限"
        },
        "starter_credit_limit": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Starter Credit Limit",
          "description": "Starter 每用户积分上限"
        }
      },
      "type": "object",
      "required": [
        "id",
        "name",
        "conditions",
        "credit_cost",
        "priority"
      ],
      "title": "CreditRuleInfo",
      "description": "积分规则信息"
    }
  }
}