Android SDK
ChatResponse
Reference for ChatResponse, MessagePart and the enums that send and retry return
ChatResponse
data class ChatResponse, Package: com.qwryai.sdk
What send, sendNonStreaming and retry return once the agent's answer is complete.
data class ChatResponse(
val message: Message,
val conversationId: String,
val userMessageId: String?,
val userId: String?,
val finishReason: FinishReason,
val credits: Double
)message Message required
The agent's answer. message.id is the ID the server gave it, message.role is always ASSISTANT, message.parts holds its text, tool calls and tool results, and message.text joins its text. message.createdAt is when the answer finished on the device. See Conversation & Message.
conversationId String required
The conversation the answer belongs to. Pass it to continue that conversation.
userMessageId String?
The ID the server gave the message you sent.
userId String?
The identified user, or null while the SDK is anonymous.
finishReason FinishReason required
Why the answer ended: STOP, ERROR or TOOL_CALLS.
credits Double required
Message credits the answer used.
MessagePart
sealed interface MessagePart, Package: com.qwryai.sdk
MessagePart.Text
Text the agent wrote, or the text a user sent.
data class Text(val text: String) : MessageParttext String required
The text.
MessagePart.ToolCall
A tool the agent called. Tools registered with client.tool run on the device; others run on the server.
data class ToolCall(
val id: String,
val name: String,
val input: Any?
) : MessagePartid String required
The tool call's ID.
name String required
The tool's name, which is the action's name.
input Any?
The agent's input as a JSON value read by org.json, usually a JSONObject.
MessagePart.ToolResult
What a tool returned.
data class ToolResult(
val id: String,
val name: String,
val output: Any?
) : MessagePartid String required
The id of the ToolCall it answers.
name String required
The tool's name.
output Any?
The result as a JSON value. A failed tool's output is a JSONObject with an error field.
Enums
Message.Role
enum class Role {
USER, // sent by the user
ASSISTANT // written by the agent, or by a person on your team
}ChatResponse.FinishReason
enum class FinishReason {
STOP, // the answer is complete
ERROR, // the answer ended with an error
TOOL_CALLS // the agent is waiting for tool results
}