> ## 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
)
```

**id** `String` *required*

Server-assigned message ID.

**role** `String` *required*

Always `"assistant"`.

**parts** `List\<Part\>` *required*

The response content — text, tool calls, and tool results.

**metadata** `ResponseMetadata` *required*

**properties**

**messageId** `String?`

Same as `ChatResponse.id`.

**userMessageId** `String?`

Server-assigned ID for the user's message.

**conversationId** `String?`

The conversation ID. Pass this to continue the conversation.

**finishReason** `FinishReason`

Why the stream ended: `STOP`, `ERROR`, `TOOL_CALLS`, or `UNKNOWN`.

**usage** `Usage?`

**properties**

**credits** `Double`

Credits consumed by this request.

## Part

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

**Text**

### Part.Text

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

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

**text** `String` *required*

The text content.

**ToolCall**

### Part.ToolCall

A tool invocation requested by the AI agent.

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

**toolCallId** `String` *required*

Unique tool call identifier.

**toolName** `String` *required*

Name of the tool.

**input** `JsonElement?`

The tool's input parameters.

**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
```

**toolCallId** `String` *required*

Matches the originating `ToolCall.toolCallId`.

**toolName** `String` *required*

Name of the tool.

**output** `JsonElement?`

The tool's output.

## 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
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.