public final class ChatResponse
- Object
- 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
Inherited methods
Constructor details
ChatResponse
public ChatResponse(ChatMessage assistantMessage, List<ToolCall> toolCalls, String finishReason, Usage usage, String modelUsed)Creates a normalized terminal response.
Parameters
assistantMessageChatMessage- aggregated assistant output, or
null toolCallsList<ToolCall>- requested tool calls;
nullbecomes empty finishReasonString- normalized provider finish reason
usageUsage- token accounting, or
null modelUsedString- 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 lengthgetUsage
public Usage getUsage()Returns
token accounting, or
null when the provider omitted itgetModelUsed
public String getModelUsed()Returns
provider-reported model id, or
null when omitted