You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[REQUEST] Expose llama.cpp-style top-level timings and cached/draft token stats in OAI responses #454
When consuming tabbyAPI behind a metrics-aware proxy (e.g. llama-swap), per-request speed and cache stats don't surface, because the stats live only in the non-standard usage object while the standard places consumers look are empty.
Problem
Speeds are only in usage.UsageStats carries prompt_tokens_per_sec / completion_tokens_per_sec, but there is no top-level timings (llama.cpp-style) or metrics (vLLM-style) object. Consumers that read top-level timings/metrics for prompt/prediction speed show "unknown" even though token counts populate.
Cached prompt tokens are dropped. The backend (exllamav3) finish chunk already reports cached_tokens, but get_usage_stats discards it when building UsageStats, so the OpenAI-standard usage.prompt_tokens_details.cached_tokens is never emitted.
Spec-decoding draft stats are dropped. The finish chunk carries draft_accept / draft_reject, but they are not surfaced anywhere in the response.
Prompt count/speed mismatch.usage.prompt_tokens reports the total (including cached), while prompt_tokens_per_sec is computed over new tokens only — so the count and the speed disagree.
This is solvable and is working for us. We run a patched tabbyAPI image that exposes these fields, and the metrics populate correctly in our setup. We have a working patch set against v1.4.2 that we're happy to share for reference; we're not asking to own the implementation.
General direction for a fix
Emit a top-level timings object on /chat/completions and /completions (streaming + non-streaming) with llama.cpp-compatible keys: prompt_n, prompt_per_second, predicted_n, predicted_per_second, and draft_n / draft_n_accepted when spec-decoding is active.
Add prompt_tokens_details: {cached_tokens} to UsageStats, populated from the backend finish chunk's cached_tokens.
Add draft_tokens / draft_tokens_accepted to UsageStats from draft_accept / draft_reject.
Decide on prompt_tokens semantics: report new-only (total − cached) to match llama.cpp, or keep total and document it.
Activity
DenysAshikhin commentedon Sep 2, 2026
#452
Won't cover it fully but I did open this roughly same time as you posted this lol
API: Add llama.cpp-compatible timings to completion responses