Reference

SendMessageResult

Type
Describes what a completed `sendMessage` call resolves to: the stop reason and token usage.

The value the sendMessage promise resolves with once the stream completes: why the agent stopped, and the input and output token counts for the whole turn. The streamed text has already arrived through onText, so this is the closing summary.

SendMessageResult.ts
interface SendMessageResult {
  stopReason: string
  usage: { inputTokens: number; outputTokens: number }
}
Fields
stopReason
string
Why the agent stopped, for example end_turn or max_tokens.
usage
{ inputTokens, outputTokens }
Token counts for the full agent loop.
Read the result
const { stopReason, usage } = await chat.sendMessage(threadId, text, { onText });
console.log(stopReason, usage.outputTokens);