Syntropy.LLMClient.Usage (syntropy v0.1.0)

Copy Markdown

Provider usage accounting for hosted model calls.

Usage events are logged for Railway inspection and recorded in UsageRecorder. Completed run envelopes persist the summarized usage when Postgres run-envelope persistence is enabled.

Summary

Types

usage()

@type usage() :: %{
  input_tokens: non_neg_integer(),
  cached_input_tokens: non_neg_integer(),
  output_tokens: non_neg_integer(),
  total_tokens: non_neg_integer()
}

Functions

estimated_cost_usd(model, usage)

@spec estimated_cost_usd(String.t() | nil, usage() | nil) :: float() | nil

log_completion(config, agent, response_body, duration_ms)

@spec log_completion(Syntropy.LLMClient.Config.t(), map(), map(), non_neg_integer()) ::
  :ok

pricing_for_model(model)

@spec pricing_for_model(String.t() | nil) :: map() | nil

usage_from_body(arg1)

@spec usage_from_body(map()) :: usage() | nil