Lite LLMToken Consumption
Token-based consumption for the LiteLLM provider.
Tracks tokens with detailed breakdown:
inputTokens: Tokens in the prompt/input
outputTokens: Tokens in the completion/output
totalTokens: Total tokens consumed
All three come from the provider as-is, with no arithmetic on our side. So inputTokens + outputTokens can fall below totalTokens: a provider that bills reasoning tokens may count them in its total and leave them out of the completion count. Observed with gemini-3-flash via LiteLLM, where the gap was 4-10% of the total. total reports totalTokens, so spend limits already see the larger figure.
TODO: track reasoning/thinking tokens as their own count or account them in outputTokens, so the breakdown adds up.
Types
Factory for reconstructing LiteLLMTokenConsumption from its pretty-JSON form.
Properties
Functions
Adds two consumptions of the same flavor. Implementations reject mismatched flavors.
The flavor-specific fields as pretty JSON (without the top-level "unit" field).
Human-readable form, typically with input/output breakdown where applicable.
Total-only short form, e.g. "330,329.00 tokens" / "150.00 credits". Used where the input/output breakdown would be misleading or off-topic — most notably the spend-limit abort message, where there is no such thing as a separate input/output cap (cap is a single total).