feat: show first-token latency, decode tok/s, per-key colors

- logs page adds First (first_token_ms) and Tok/s columns; Tok/s is
  output_tokens / (latency - first_token) over the decode window
- detail line shows the same rate after first-token latency
- API key names render in a stable per-key color (crc32 over a 10-color
  palette) so rows from the same key group visually; --once stays plain
- --once --logs prints the new first/tok-s columns

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-21 11:19:06 +08:00
parent 7d78f1ab63
commit 2d3d433f4f
5 changed files with 104 additions and 10 deletions
+8 -2
View File
@@ -83,13 +83,19 @@ Sub2API admin usage API and refreshes every 60 seconds by default
(`--logs-refresh-seconds` / `SHUSUB2_LOGS_REFRESH_SECONDS`). Columns:
```text
Key | Account | Model | Type | Tokens | Cost | Latency | Time
Key | Account | Model | Type | Tokens | Cost | Latency | First | Tok/s | Time
```
`Type` is the Sub2API `request_type` (`sync` / `stream` / `ws_v2` / `cyber`).
`Tokens` is input + output + cache write + cache read; the detail line below
the table shows the per-bucket breakdown, actual cost, first-token latency,
upstream model mapping, user, and request id.
decode speed, upstream model mapping, user, and request id.
`First` is the first-token latency (`first_token_ms`). `Tok/s` is the decode
throughput computed as `output_tokens / (latency - first_token)`; it shows
`-` when there is no output or no positive decode window. In the TUI each
API key name is rendered in a stable per-key color so rows from the same
key are easy to group visually (`--once --logs` output stays plain text).
The logs URL defaults to `https://sub2apicn.shujk.top/api/v1/admin/usage` and
can be overridden with `--logs-url` / `SHUSUB2_LOGS_URL` /