Agentic.CostCalculator
(agentic v0.2.2)
Copy Markdown
Calculates LLM costs from token counts and model pricing data.
Uses a hardcoded fallback pricing table. All rates are per million tokens (mtok).
Summary
Functions
Calculate cost in USD from token counts and model pricing.
Look up pricing for a model. Returns {input_rate, output_rate} or nil.
Returns the hardcoded fallback pricing table as a map of
%{model_id => {input_rate, output_rate}}.
Functions
@spec calculate( String.t() | nil, String.t() | nil, non_neg_integer(), non_neg_integer() ) :: float()
Calculate cost in USD from token counts and model pricing.
Returns 0.0 if pricing cannot be determined.
Look up pricing for a model. Returns {input_rate, output_rate} or nil.
Returns the hardcoded fallback pricing table as a map of
%{model_id => {input_rate, output_rate}}.