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 model field is a prefix of the lowercased model argument so model variants (versioned suffixes, dated minor releases) inherit their family’s rates. Unknown provider / model combinations evaluate to zero rather than raising — the caller’s downstream usage record always carries a well-typed decimal.Decimal.

Parameters:
  • provider (LLMProvider) – The adapters.outbound.llm.LLMProvider that 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:

Decimal

Returns:

Estimated cost in USD, quantised to 6 decimal places using banker-rounded decimal.ROUND_HALF_UP. Returns decimal.Decimal('0') for the local provider and unknown models.