Normalized response returned by LLM.generate/2 and LLM.Stream.collect/2.
Fields
:message— the model's final response turn as anLLM.Message.t():messages— the messages produced in this session: the user prompt that started the loop plus every assistant turn and tool-result message generated during the auto-tool loop. Does not include prior conversation passed in via the:messagesoption — append these to that prior list to continue the conversation:usage— token usage as anLLM.Usage.t()(may benil):stop_reason— why generation stopped (:stop,:length,:tool_calls, etc.):provider_state— provider-specific state for multi-turn conversations (e.g., OpenAI Responsesprevious_response_id):raw— the original provider response body for debugging
Examples
{:ok, response} = LLM.generate("Hello", provider: :openai, model: "gpt-4")
response.message.content
#=> "Hi there!"
response.usage
#=> %LLM.Usage{input_tokens: 10, output_tokens: 8, total_tokens: 18}
response.stop_reason
#=> :stop
Summary
Types
@type t() :: %LLM.Response{ message: LLM.Message.t(), messages: [LLM.Message.t()] | nil, provider_state: map() | nil, raw: map() | nil, stop_reason: atom() | nil, usage: LLM.Usage.t() | nil }