mirror of
https://github.com/jasonxu114514/opencode2api.git
synced 2026-12-06 08:03:47 +00:00
feat: split usage by server key (#58)
Usage was only broken down by model and tier, so a gateway shared by several callers could not tell how much each server key consumed. authenticate now records the fingerprint of the key that matched, and the monitor keeps requests and tokens per key in usage.server_keys for both the lifetime and the last hour; the entries sum to the aggregate totals. /api/api-keys attaches each key's usage and the WebUI shows it in the key list. Playground traffic borrows the first enabled key, so it is counted under "playground" instead. Like the rest of the monitor, the figures survive hot reloads and reset on restart. Closes #58.
This commit is contained in:
1 parent
d434794866
commit
25afadd303
9 files changed
+118
-35
No files matched your search
@@ -20,7 +20,8 @@
|
||||
|
||||
- 管理的是网关的 `server_keys`,不修改 OpenCode Go 的上游 Key。
|
||||
- 自动生成 192 位随机密钥;自定义密钥为 16–256 位英文字母、数字、`-`、`_` 或 `.`。
|
||||
- 列表只显示名称、尾码、状态和创建时间。创建后可复制完整密钥及环境变量。
|
||||
- 列表只显示名称、尾码、状态、用量和创建时间。创建后可复制完整密钥及环境变量。
|
||||
- 用量按认证命中的 Key 统计请求数和 token,分近 1 小时和累计两个窗口;`GET /api/monitor` 的 `usage.server_keys` 给出同一份数据,各项之和等于聚合口径。Playground 调试流量单独归入 `playground`,不计入任何 Key。与其他监控数据一样只存于内存:热重载保留,进程重启后清零。
|
||||
- 变更热应用;停用和删除后,新请求返回 401。在途请求可以完成。至少保留一个启用的 Key。
|
||||
- 所有管理接口需要登录,写操作需要 CSRF Token。
|
||||
- 元数据以 `server_key_metadata` 保存在原配置中,按 Key 指纹关联;已有 `server_keys` 自动兼容。
|
||||
|
||||
Reference in new issue
Block a user