Skip to main content

Module proxy_usage

Module proxy_usage 

Source
Expand description

On-disk record of the proxy’s measured provider spend (proxy_usage.json).

The proxy’s usage meter (proxy::usage_meter) aggregates the real provider usage of every finalized turn into these per-model sums and persists them; the dashboard, CLI, stats and the savings ledger (which run in other processes) read them back through load_persisted to learn the user’s real provider bill.

Structs§

CohortUsage
Cumulative holdout cohort totals. Keyed by arm name: "control" | "treatment" for output savings (#895 Track B), "compression:control" | "compression:treatment" for input compression (#1905). The average tokens per turn are *_tokens / requests. Only populated while a holdout is active.
LastModel
The model the proxy saw last, with the time it saw it.
MeasuredSlice
Token/cost sums of the turns that reported a measured provider charge.
ModelUsage
Cumulative real token counts for one model. Cost is derived at read time so a pricing-table change re-values historical usage consistently.
PersistedUsage
On-disk shape of the measured spend totals.
ResponseObservation
Payload-free local measurement. Unknown cost stays unknown; neither HTTP status nor receipt of usage supplies the private runtime’s quality label.
SessionUsage
One app session’s totals per model and when the proxy last saw it.

Enums§

UsageBoundary
Where provider usage was observed, not an assertion of answer quality or successful generation. Terminal usage also accompanies failed responses.

Functions§

load_persisted
Cross-process read of the persisted measured spend (dashboard / CLI / ledger).
persisted_dominant_model
The model carrying the most measured tokens (excludes the “unknown” bucket). Used to value savings against the real dominant model when no explicit model is configured.
usage_path
Where the measured spend totals live in the data directory.