# `LlmComposer.LlmResponse`
[🔗](https://github.com/doofinder/llm_composer/blob/master/lib/llm_composer/llm_response.ex#L1)

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.

# `provider`

```elixir
@type provider() ::
  :open_ai | :open_ai_responses | :ollama | :open_router | :bedrock | :google
```

# `t`

```elixir
@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` — `:ok` or `:error`.
- `:main_response` — the primary assistant `Message.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 (see `provider/0` type).
- `: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 of `LlmComposer.StreamChunk.t()` when streaming is enabled, otherwise `nil`.
- `:cost_info` — `CostInfo.t()` with cost breakdown when `:track_costs` is enabled.
- `:metadata` — arbitrary map for provider-specific extra data.
- `:raw` — original decoded provider payload, useful for debugging.

# `function_calls`

```elixir
@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.

# `new`

```elixir
@spec new(map()) :: t()
```

Builds an `LlmResponse` struct from an attribute map, defaulting `:metadata` to `%{}`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
