> ## Documentation Index
> Fetch the complete documentation index at: https://chatbase.co/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# ChatResponse

> Reference for ChatResponse, ResponseMetadata, Part, and related types returned by sendMessage and retry.

## ChatResponse

`data class ChatResponse` — **Package:** `com.chatbase.sdk.model`

The aggregated result returned by `sendMessage` and `retry`.

```kotlin theme={null}
data class ChatResponse(
    val id: String,
    val role: String,
    val parts: List<Part>,
    val metadata: ResponseMetadata
)
```

<ResponseField name="id" type="String" required>
  Server-assigned message ID.
</ResponseField>

<ResponseField name="role" type="String" required>
  Always `"assistant"`.
</ResponseField>

<ResponseField name="parts" type="List<Part>" required>
  The response content — text, tool calls, and tool results.
</ResponseField>

<ResponseField name="metadata" type="ResponseMetadata" required>
  <Expandable title="properties">
    <ResponseField name="messageId" type="String?">
      Same as `ChatResponse.id`.
    </ResponseField>

    <ResponseField name="userMessageId" type="String?">
      Server-assigned ID for the user's message.
    </ResponseField>

    <ResponseField name="conversationId" type="String?">
      The conversation ID. Pass this to continue the conversation.
    </ResponseField>

    <ResponseField name="finishReason" type="FinishReason">
      Why the stream ended: `STOP`, `ERROR`, `TOOL_CALLS`, or `UNKNOWN`.
    </ResponseField>

    <ResponseField name="usage" type="Usage?">
      <Expandable title="properties">
        <ResponseField name="credits" type="Double">
          Credits consumed by this request.
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

## Part

`sealed interface Part` — **Package:** `com.chatbase.sdk.model`

<Tabs>
  <Tab title="Text">
    ### Part.Text

    Text content generated by the agent or sent by the user.

    ```kotlin theme={null}
    data class Text(val text: String) : Part
    ```

    <ResponseField name="text" type="String" required>
      The text content.
    </ResponseField>
  </Tab>

  <Tab title="ToolCall">
    ### Part.ToolCall

    A tool invocation requested by the agent.

    ```kotlin theme={null}
    data class ToolCall(
        val toolCallId: String,
        val toolName: String,
        val input: JsonElement?
    ) : Part
    ```

    <ResponseField name="toolCallId" type="String" required>
      Unique tool call identifier.
    </ResponseField>

    <ResponseField name="toolName" type="String" required>
      Name of the tool.
    </ResponseField>

    <ResponseField name="input" type="JsonElement?">
      The tool's input parameters.
    </ResponseField>
  </Tab>

  <Tab title="ToolResult">
    ### Part.ToolResult

    The result of a tool execution.

    ```kotlin theme={null}
    data class ToolResult(
        val toolCallId: String,
        val toolName: String,
        val output: JsonElement?
    ) : Part
    ```

    <ResponseField name="toolCallId" type="String" required>
      Matches the originating `ToolCall.toolCallId`.
    </ResponseField>

    <ResponseField name="toolName" type="String" required>
      Name of the tool.
    </ResponseField>

    <ResponseField name="output" type="JsonElement?">
      The tool's output.
    </ResponseField>
  </Tab>
</Tabs>

## Enums

### Role

```kotlin theme={null}
enum class Role {
    USER,       // serialized as "user"
    ASSISTANT   // serialized as "assistant"
}
```

### FinishReason

```kotlin theme={null}
enum class FinishReason {
    STOP,       // serialized as "stop" — normal completion
    ERROR,      // serialized as "error" — an error occurred
    TOOL_CALLS, // serialized as "tool-calls" — waiting for tool results
    UNKNOWN     // serialized as "unknown" — unrecognized finish reason
}
```
