Two-Tier Streaming API
The SDK provides two levels of abstraction for streaming:sendMessage()— High-level API with a callback DSL. Handles tool calls automatically (up to 10 iterations). Recommended for most use cases.sendMessageStream()— Low-level API returning aFlow<ChatStreamEvent>. Tool calls are not handled automatically, giving you full control over event processing.
sendMessage
interface ChatbaseClient — Package: com.chatbase.sdk
ChatResponse when the stream completes.
String
required
The user message to send to the agent.
String?
Continue an existing conversation. Omit to use
currentConversationId or start a new one.StreamCallbacks.() -> Unit
Streaming callback DSL.
StreamCallbacks
class StreamCallbacks — Package: com.chatbase.sdk
ChatResponse
data class ChatResponse — Package: com.chatbase.sdk.model
The aggregated result after streaming completes.
String
required
Server-assigned message ID.
String
required
Always
"assistant".List<Part>
required
The response content — text, tool calls, and tool results. See ChatResponse.
ResponseMetadata
required
sendMessageStream
Flow of raw streaming events. Tool calls are not handled in Flow mode — registered tool handlers are not invoked, and the SDK exposes no API for submitting tool results manually.
String
required
The user message to send to the agent.
String?
Continue an existing conversation. Omit to use
currentConversationId or start a new one.Stream Events
TheFlow returned by sendMessageStream emits ChatStreamEvent objects — text deltas, tool input/output, step lifecycle, and errors. See Streaming Events for the full type reference.
Continuing a Conversation
The SDK automatically tracks the current conversation. After sending a message, subsequent calls reuse the same conversation:retry
sendMessage.
String
required
The conversation containing the failed message.
String
required
The ID of the assistant message to retry.
StreamCallbacks.() -> Unit
Streaming callback DSL.
ChatResponse:
retryStream
retry. Tool calls are not handled automatically.
Related
Client-Side Tools
Register tool handlers the agent can invoke
Error Handling
Exception hierarchy and error handling patterns
