aeat.adapters.outbound.llm._pricing module¶
Provider pricing helpers for cost estimation.
Holds the public per-million-token pricing table for each supported
adapters.outbound.llm.LLMProvider and exposes
estimate_cost_usd() so adapters.outbound.llm.LLMClient
can stamp every adapters.outbound.llm.LLMResponse with a
deterministic USD cost estimate. The local provider always reports zero.
- estimate_cost_usd(provider, model, input_tokens, output_tokens)[source]¶
Estimate request cost in USD from known public pricing.
Looks up the first pricing entry whose
modelfield is a prefix of the lowercasedmodelargument so model variants (versioned suffixes, dated minor releases) inherit their family’s rates. Unknownprovider/modelcombinations evaluate to zero rather than raising — the caller’s downstream usage record always carries a well-typeddecimal.Decimal.- Parameters:
provider (
LLMProvider) – Theadapters.outbound.llm.LLMProviderthat produced the response.model (
str) – Provider-resolved model identifier (e.g."claude-sonnet-4-6-20260101").input_tokens (
int) – Prompt-side token count.output_tokens (
int) – Completion-side token count.
- Return type:
- Returns:
Estimated cost in USD, quantised to 6 decimal places using banker-rounded
decimal.ROUND_HALF_UP. Returnsdecimal.Decimal('0')for the local provider and unknown models.