View Source LlmComposer.Cost.CostAssembler (llm_composer v0.13.0)
Centralized cost information assembly module.
Handles the extraction of cost-related data from provider responses and
assembles CostInfo structs. This module consolidates all cost logic that
was previously scattered across the response handler.
Responsibilities
- Extract tokens from provider-specific response formats
- Resolve model names (from response or options)
- Prepare pricing options for cost calculation
- Assemble complete CostInfo structs
Provider-Specific Handling
- OpenAI/OpenRouter: Extracts tokens from
usagefield, model from response - Google: Extracts tokens from
usageMetadatafield, model from options
Summary
Functions
@spec extract_tokens(atom(), map()) :: {non_neg_integer(), non_neg_integer()}
@spec get_cost_info( provider :: atom(), raw_response :: map(), opts :: keyword() ) :: LlmComposer.CostInfo.t() | nil