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
usage.prompt_tokens / completion_tokens already exist in responses.
But most chat UIs (LibreChat, AnythingLLM, Open-WebUI) don't surface
them — either at all, or only in tooltips. For an operator running
multi-model setups where compression, routing or fallback may kick in,
the user seeing the response doesn't know which model answered, whether compression fired, or how big the request was.
Our production UX at walcz.de appends a tiny one-line footer under
each response:
walcz.de production (prompt-optimizer service) renders this via
post-processing. Moving it into LocalAI removes one layer of our proxy
chain and benefits any LocalAI operator with end-user-facing chat UIs.
Implementation outline
UsageFooterConfig in core/config/model_config.go:32.
Problem
usage.prompt_tokens/completion_tokensalready exist in responses.But most chat UIs (LibreChat, AnythingLLM, Open-WebUI) don't surface
them — either at all, or only in tooltips. For an operator running
multi-model setups where compression, routing or fallback may kick in,
the user seeing the response doesn't know which model answered,
whether compression fired, or how big the request was.
Our production UX at walcz.de appends a tiny one-line footer under
each response:
Users like it. It's observability built into the answer, not hidden
in
/metrics.Proposal
Opt-in, per-model middleware that appends a compact footer to the
final assistant content, delimited by an HTML comment so it's
client-strippable:
Config
Flow
string from
usage.*already in hand.SSE stream.
Why content-embedded instead of just usage.* visibility
content— no UI changes needed.desired:
re.sub(r'<!-- localai-usage-footer -->.*$', '', content, flags=re.DOTALL).work we don't control.
Non-goals
Prometheus, doesn't replace them.
Backward compatibility
Opt-in. Default off. No change when absent.
Open questions
Marker format — HTML comment is markdown-safe in most renderers.
Alternative: a ZWSP-delimited line. Preference?
Label localization — embedded
de/enor operator-suppliedtemplate string? Template is more flexible but widens the surface.
Metric emission — do we also emit
localai_usage_footer_rendered_totalor is that over-instrumentation for a UX feature?
Interaction with compression (RFC RFC: Optional server-side context-compression middleware for /v1/chat/completions #9534) — when compression
fires, footer should show the ratio. Coordination: footer middleware
runs after compression middleware in the chain, reads
usage.compression_metato populatecompression_ratiofield.Prior art
walcz.de production (prompt-optimizer service) renders this via
post-processing. Moving it into LocalAI removes one layer of our proxy
chain and benefits any LocalAI operator with end-user-facing chat UIs.
Implementation outline
UsageFooterConfigincore/config/model_config.go:32.core/http/middleware/usage_footer.go— Echoresponse-writer wrapper.
pkg/usage_footer/i18n.go— tiny label map.docs/content/features/usage_footer.md.Approx 1-2 days.
Assisted-by: Claude:claude-opus-4-7