Ledger of the chargeable calls made while serving one operation.
Retain and recall open a ledger in the calling process, the LLM adapter and the
remote embedder record every call they make into it, and the operation closes it
and reports the entries on its result under "usage". Each entry names the kind
of call, the provider and model, the token counts the provider reported, the
request id when one was returned, and whether the call succeeded, so a consumer
can attribute cost deterministically and audit it against the provider's own
records.
"usage" is nil when no chargeable call happened: local embedders and the Noop
LLM record nothing, so the default configuration is unchanged.
Summary
Functions
Close the ledger and return its entries in call order.
Build an LLM entry from an LlmCore.LLM.Response-shaped struct or map.
Build an LLM entry for a call that failed before any usage was reported.
Record one call. A no-op when no ledger is open, so adapters can always call it.
Missing token counts default to zero; "status" defaults to "ok".
Summarise entries for a result: token totals over successful calls plus the
calls themselves. nil for an empty ledger.
Open a fresh ledger in the current process.
Types
Functions
@spec drain() :: [entry()]
Close the ledger and return its entries in call order.
Build an LLM entry from an LlmCore.LLM.Response-shaped struct or map.
Build an LLM entry for a call that failed before any usage was reported.
@spec record(map()) :: :ok
Record one call. A no-op when no ledger is open, so adapters can always call it.
Missing token counts default to zero; "status" defaults to "ok".
Summarise entries for a result: token totals over successful calls plus the
calls themselves. nil for an empty ledger.
@spec start() :: :ok
Open a fresh ledger in the current process.