Skip to content

Generated by sema doc from stdlib/sema/usage.sema. Import with from std.usage import …. For a narrative introduction see std.usage.

std.usage — model usage accounting (design ①).

Accumulate token usage across calls and price it. Replaces eai-search’s (result, usage) tuple threading and SymbolicAI’s ~470-line MetadataTracker. Pricing is passed in by the caller — rates are never hardcoded. (For ambient, automatic accounting see the with meter as u: scope, §3.6.)

Fields

fieldtypedescriptor
prompt_tokensint
completion_tokensint
reasoning_tokensint
cached_tokensint
total_callsint
total_tokensint
cost_estimatef64

Fields

fieldtypedescriptor
inputf64
cached_inputf64
outputf64
callsf64
def zero() -> Usage !{}

Returns Usage

Effects !{}

def estimate_cost(u: Usage, p: Pricing) -> f64 !{}

Parameters

nametype
uUsage
pPricing

Returns f64

Effects !{}