public final class ChatResponse

  1. Object
  2. ChatResponse

The terminal response from a chat call. For streaming requests, the ChatResponse carries the aggregated final assistant message – the individual deltas were delivered through StreamingListener before this object was produced.

finishReason is one of: "stop", "length", "tool_calls", "content_filter", "error" (normalized across providers).

Constructors

public ChatResponse(ChatMessage assistantMessage, List<ToolCall> toolCalls, String finishReason, Usage usage, String modelUsed)Creates a normalized terminal response.

Methods

public ChatMessage getAssistantMessage()
public List<ToolCall> getToolCalls()
public String getText()Convenience: the assembled assistant text.
public String getFinishReason()
public Usage getUsage()
public String getModelUsed()

Inherited methods

Constructor details

ChatResponse

public ChatResponse(ChatMessage assistantMessage, List<ToolCall> toolCalls, String finishReason, Usage usage, String modelUsed)
Creates a normalized terminal response.

Parameters

assistantMessage ChatMessage
aggregated assistant output, or null
toolCalls List<ToolCall>
requested tool calls; null becomes empty
finishReason String
normalized provider finish reason
usage Usage
token accounting, or null
modelUsed String
provider-reported model id, or null

Method details

getAssistantMessage

public ChatMessage getAssistantMessage()

Returns

normalized assistant message, including any multimodal parts

getToolCalls

public List<ToolCall> getToolCalls()

Returns

immutable tool calls requested by the model

getText

public String getText()
Convenience: the assembled assistant text. Equivalent to getAssistantMessage().getText() when there is one.

Returns

assistant text, or an empty string without a message

getFinishReason

public String getFinishReason()

Returns

provider finish reason such as stop or length

getUsage

public Usage getUsage()

Returns

token accounting, or null when the provider omitted it

getModelUsed

public String getModelUsed()

Returns

provider-reported model id, or null when omitted