ChatResponse
struct ChatResponse: Sendable
What send, retry, and sendNonStreaming give you back.
The AI agent’s reply. See Message.
Why the reply ended. See FinishReason.
How many credits it used. See Usage.
When the AI agent uses tools, the reply takes several rounds.
message.text is all the text from every round joined together, and message.id is the ID of the final message.Message
struct Message: Identifiable, Sendable
Used both for the reply inside ChatResponse and for each item from listMessages.
When the message was created. Falls back to the current time if the server does not send one.
MessagePart
- text
- toolCall
- toolResult
MessageSender
.agent, including messages typed by a person who has taken over the conversation.
MessageFeedback
FinishReason
After
send or retry, this is almost always .stop, because the SDK runs the tools for you and waits for the real answer. You will see .toolCalls from sendNonStreaming, which skips tools: the AI agent wanted one and never got an answer.Any finish reason the SDK does not recognize is treated as .stop.Usage
Related
Streaming
The methods that return a ChatResponse
Conversation & Pagination
Conversation, status, and paging types
JSONValue
Reading tool data
Streaming Types
Callbacks and stream types