The result object-type returned by the useChat hook that provides functions and state for interacting with the chat.
API
interface UseChatResult<Tools extends Chat.AnyTool> {error: Error | undefined;exhaustedRetries: boolean;generatingError: Error | undefined;isGenerating: boolean;isLoading: boolean;isLoadingThread: boolean;isReceiving: boolean;isRunningToolCalls: boolean;isSavingThread: boolean;isSending: boolean;lastAssistantMessage: Chat.AssistantMessage <
string,
Tools
> | undefined;messages: (Chat.Message < string, Tools > []);reload: () => void;sendingError: Error | undefined;sendMessage: (message: Chat.Message<string, Tools>) => void;setMessages: (messages: Chat.Message<string, Tools>[]) => void;stop: (clearStreamingMessage?: boolean) => void;threadLoadError: {
error: string;
stacktrace?: string;
} | undefined;threadSaveError: {
error: string;
stacktrace?: string;
} | undefined;}@typeToolsChat.AnyToolError | undefinedThe error encountered during chat operations, if any.
booleanWhether the current request has exhausted retries.
Error | undefinedError emitted during generation frames.
booleanWhether the chat is currently generating (between start and finish/error frames).
booleanAggregate loading flag across transport, generation, tool-calls, and thread load/save.
booleanWhether a thread load request is in flight.
booleanWhether the chat is receiving a response.
booleanWhether the chat is running tool calls.
booleanWhether a thread save request is in flight.
booleanWhether the chat is sending a response.
Chat.AssistantMessage<string, Tools> | undefinedThe last assistant message.
Chat.Message<string, Tools>[]An array of chat messages.
() => voidReload the chat, useful for retrying when an error occurs.
Error | undefinedTransport/request failure before generation frames arrive.
(message: Chat.Message<string, Tools>) => voidFunction to send a new chat message.
(messages: Chat.Message<string, Tools>[]) => voidFunction to update the chat messages.
(clearStreamingMessage?: boolean) => voidFunction to stop the chat.
{
error: string;
stacktrace?: string;
} | undefinedThread loading error, if present.
{
error: string;
stacktrace?: string;
} | undefinedThread saving error, if present.