LLMProxy.Usage (llm_proxy v0.1.0)

Copy Markdown View Source

Token usage accounting and protocol usage-map rendering.

Summary

Types

t()

@type t() :: %LLMProxy.Usage{
  cache_read_tokens: non_neg_integer(),
  cache_write_tokens: non_neg_integer(),
  input_tokens: non_neg_integer(),
  output_tokens: non_neg_integer()
}

Functions

from_anthropic(usage)

@spec from_anthropic(map()) :: t()

from_openai(usage)

@spec from_openai(map()) :: t()

from_responses(usage)

@spec from_responses(map()) :: t()

merge_max(usage, event_usage)

@spec merge_max(t(), t()) :: t()

new(input_tokens, output_tokens, cache_read_tokens \\ 0, cache_write_tokens \\ 0)

put_output_tokens(usage, output_tokens)

@spec put_output_tokens(t(), non_neg_integer()) :: t()

to_openai(usage)

@spec to_openai(map() | t() | nil) :: map()

to_responses(usage)

@spec to_responses(map() | t() | nil) :: map()

zero()

@spec zero() :: t()