Skip to content

计费规则 / 套餐 ​

本节介绍计费规则(/v1/charge)与订阅套餐(/v1/plans)两个只读接口。

GET /v1/charge ​

返回当前所有计费规则列表。

响应示例 ​

json
[
  {
    "id": 1,
    "type": "token-billing",
    "models": ["gpt-3.5-turbo", "gpt-4o"],
    "input": 0.0015,
    "output": 0.002,
    "anonymous": false
  },
  {
    "id": 2,
    "type": "times-billing",
    "models": ["dall-e-3"],
    "input": 0,
    "output": 0.04,
    "anonymous": false
  },
  {
    "id": 3,
    "type": "non-billing",
    "models": ["web-gpt-3.5-turbo"],
    "input": 0,
    "output": 0,
    "anonymous": false
  }
]

响应字段(单条规则) ​

字段类型说明
idint规则 ID
typestring计费类型,见下表
modelsstring[]该规则覆盖的模型列表
inputfloat32输入单价(元 / 1K tokens,仅 token-billing 有效)
outputfloat32输出单价(元 / 1K tokens,或每次调用单价)
anonymousbool是否允许匿名调用

计费类型(type) ​

值常量说明
non-billingglobals.NonBilling不计费
times-billingglobals.TimesBilling按次计费(以 output 为单次价格)
token-billingglobals.TokenBilling按 token 计费(input + output)

计费与额度

计费类型决定了 quota 的扣减方式。当某模型未命中任何规则时,按 non-billing(不计费)处理。

GET /v1/plans ​

返回订阅套餐列表。当套餐功能未启用时返回空数组。

  • 方法:GET
  • 鉴权:无强制要求
  • 来源:manager/router.go → PlanAPI → channel.PlanInstance.GetPlans()

响应示例 ​

json
[
  {
    "level": 1,
    "price": 19.9,
    "items": [
      {
        "id": "basic-chat",
        "name": "基础对话额度",
        "icon": "chat",
        "value": 100000,
        "models": ["gpt-3.5-turbo"]
      }
    ]
  }
]

响应字段 ​

字段类型说明
levelint套餐等级(1 ~ 3)
pricefloat32价格
itemsarray套餐内条目
items[].idstring条目唯一标识(用于用量统计)
items[].namestring条目名称
items[].iconstring图标标识
items[].valueint64额度上限(-1 表示无限)
items[].modelsstring[]该条目覆盖的模型

未启用套餐

当 subscription.enabled = false 时,GetPlans() 返回空数组 []。

示例 ​

bash
curl https://app.1in2.top/api/v1/charge
curl https://app.1in2.top/api/v1/plans