# ChatResponse

## Methods Summarized

| Type                                                     | Name                                  | Summary                                                              |
| -------------------------------------------------------- | ------------------------------------- | -------------------------------------------------------------------- |
| [enum](/reference/servoycore/dev-api/enum.md)            | [getFinishReason()](#getfinishreason) | Returns the reason why the model finished generating the response.   |
| [String](/reference/servoycore/dev-api/js-lib/string.md) | [getId()](#getid)                     | Returns the unique identifier for this chat response.                |
| [String](/reference/servoycore/dev-api/js-lib/string.md) | [getPrompt()](#getprompt)             | Returns the original user prompt that led to this response.          |
| [String](/reference/servoycore/dev-api/js-lib/string.md) | [getResponse()](#getresponse)         | Returns the full response text that should be shown to the end user. |
| [String](/reference/servoycore/dev-api/js-lib/string.md) | [getThinking()](#getthinking)         | Returns the 'thinking' text produced by the AI message, if any.      |
| [Object](/reference/servoycore/dev-api/js-lib/object.md) | [getTokenUsage()](#gettokenusage)     | 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](/reference/servoycore/dev-api/enum.md) 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](/reference/servoycore/dev-api/js-lib/string.md) 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](/reference/servoycore/dev-api/js-lib/string.md) 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](/reference/servoycore/dev-api/js-lib/string.md) 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](/reference/servoycore/dev-api/js-lib/string.md) 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](/reference/servoycore/dev-api/js-lib/object.md) the token usage details reported by the underlying response, or null if not available

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.servoy.com/reference/servoyextensions/server-plugins/ai/chatresponse.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
