LiteLLMTokenConsumption

@Serializable
data class LiteLLMTokenConsumption(val inputTokens: Long = 0, val outputTokens: Long = 0, val totalTokens: Long = 0) : LLMConsumption

Token-based consumption for the LiteLLM provider.

Tracks tokens with detailed breakdown:

Constructors

Link copied to clipboard
constructor(inputTokens: Long = 0, outputTokens: Long = 0, totalTokens: Long = 0)

Types

Link copied to clipboard
object Companion

Factory for reconstructing LiteLLMTokenConsumption from its pretty-JSON form.

Properties

Link copied to clipboard
val inputTokens: Long = 0

Tokens in the prompt/input.

Link copied to clipboard

Tokens in the completion/output.

Link copied to clipboard
open override val total: Double

The single scalar total used for comparisons (e.g. against a spend cap).

Link copied to clipboard
val totalTokens: Long = 0

Total tokens consumed.

Link copied to clipboard
open override val unit: LLMConsumptionUnit

The unit this consumption is measured in.

Functions

Link copied to clipboard
open operator override fun plus(consumption: LLMConsumption): LLMConsumption

Adds two consumptions of the same flavor. Implementations reject mismatched flavors.

Link copied to clipboard
open override fun toPrettyJson(): JsonObject

The flavor-specific fields as pretty JSON (without the top-level "unit" field).

Link copied to clipboard
open override fun toPrettyString(): String

Human-readable form, typically with input/output breakdown where applicable.

Link copied to clipboard

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).