ChatResponse

Methods Summarized

Type
Name
Summary

Returns the reason why the model finished generating the response.

Returns the unique identifier for this chat response.

Returns the original user prompt that led to this response.

Returns the full response text that should be shown to the end user.

Returns the 'thinking' text produced by the AI message, if any.

Returns token usage information for this response.

Methods Detailed

getFinishReason()

Returns the reason why the model finished generating the response. For example, the finish reason could indicate it completed normally or was stopped because of reaching a token limit. See FinishReason for possible values.

Returns: enum the finish reason reported by the underlying response, or null if not provided

getId()

Returns the unique identifier for this chat response. This is typically generated by the underlying model or client library and can be used to correlate logs, trace requests, or debug conversation history.

Returns: String the response id as a String, or null if the underlying response does not provide one

getPrompt()

Returns the original user prompt that led to this response.

Returns: String the user prompt

getResponse()

Returns the full response text that should be shown to the end user. This value was provided when constructing this wrapper and may include post-processed, combined or trimmed text in addition to the raw AI message.

Returns: String the full response text (never null if constructed correctly)

getThinking()

Returns the 'thinking' text produced by the AI message, if any. Some models or streaming APIs include incremental "thinking" or intermediate text while composing the final answer. This method exposes that value from the underlying langchain4j AI message.

Returns: String the thinking text, or null if none is available

getTokenUsage()

Returns token usage information for this response. Token usage typically contains counts for prompt, completion and total tokens and can be useful for billing, monitoring or debugging token consumption.

Returns: Object the token usage details reported by the underlying response, or null if not available


Last updated

Was this helpful?