Normalized representation of a response coming from any provider.
Parser modules are responsible for translating provider-specific HTTP results into this normalized struct so the rest of the library can stay provider-agnostic.
Summary
Functions
Returns the function calls from the main response message.
Builds an LlmResponse struct from an attribute map, defaulting :metadata to %{}.
Types
@type provider() ::
:open_ai | :open_ai_responses | :ollama | :open_router | :bedrock | :google
@type t() :: %LlmComposer.LlmResponse{ cached_tokens: non_neg_integer() | nil, cost_info: LlmComposer.CostInfo.t() | nil, input_tokens: non_neg_integer() | nil, main_response: LlmComposer.Message.t() | nil, metadata: map(), output_tokens: non_neg_integer() | nil, previous_response: map() | nil, provider: provider(), provider_model: String.t() | nil, raw: any(), reasoning_tokens: non_neg_integer() | nil, response_id: String.t() | nil, status: :ok | :error, stream: nil | Enumerable.t() }
Normalized response from any LLM provider.
:status—:okor:error.:main_response— the primary assistantMessage.t().:input_tokens— number of input tokens consumed.:output_tokens— number of output tokens generated.:cached_tokens— number of tokens served from provider cache.:reasoning_tokens— tokens used for internal reasoning (where supported).:provider— atom identifying the provider (seeprovider/0type).:provider_model— model identifier string as reported by the provider.:response_id— provider-assigned response ID, used for multi-turn continuations.:previous_response— raw previous response map, used by stateful APIs (e.g. OpenAI Responses).:stream— enumerable ofLlmComposer.StreamChunk.t()when streaming is enabled, otherwisenil.:cost_info—CostInfo.t()with cost breakdown when:track_costsis enabled.:metadata— arbitrary map for provider-specific extra data.:raw— original decoded provider payload, useful for debugging.
Functions
@spec function_calls(t()) :: [LlmComposer.FunctionCall.t()] | nil
Returns the function calls from the main response message.
Delegates to main_response.function_calls for convenience.
Builds an LlmResponse struct from an attribute map, defaulting :metadata to %{}.