外观
计费规则 / 套餐
本节介绍计费规则(/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
}
]响应字段(单条规则)
| 字段 | 类型 | 说明 |
|---|---|---|
id | int | 规则 ID |
type | string | 计费类型,见下表 |
models | string[] | 该规则覆盖的模型列表 |
input | float32 | 输入单价(元 / 1K tokens,仅 token-billing 有效) |
output | float32 | 输出单价(元 / 1K tokens,或每次调用单价) |
anonymous | bool | 是否允许匿名调用 |
计费类型(type)
| 值 | 常量 | 说明 |
|---|---|---|
non-billing | globals.NonBilling | 不计费 |
times-billing | globals.TimesBilling | 按次计费(以 output 为单次价格) |
token-billing | globals.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"]
}
]
}
]响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
level | int | 套餐等级(1 ~ 3) |
price | float32 | 价格 |
items | array | 套餐内条目 |
items[].id | string | 条目唯一标识(用于用量统计) |
items[].name | string | 条目名称 |
items[].icon | string | 图标标识 |
items[].value | int64 | 额度上限(-1 表示无限) |
items[].models | string[] | 该条目覆盖的模型 |
未启用套餐
当 subscription.enabled = false 时,GetPlans() 返回空数组 []。
示例
bash
curl https://app.1in2.top/api/v1/charge
curl https://app.1in2.top/api/v1/plans