Interface: ChatRouteChatOptions
Defined in: react/src/hooks/useChat.ts:63
Chat with a createChatRoute server, which keeps the conversation.
Extends
CommonChatOptions
Properties
api
api:
string
Defined in: react/src/hooks/useChat.ts:65
URL of the createChatRoute handler.
credentials?
optionalcredentials?:RequestCredentials
Defined in: react/src/hooks/useChat.ts:71
fetch?
optionalfetch?: (input,init?) =>Promise<Response>
Defined in: react/src/hooks/useChat.ts:70
e.g. expo/fetch on React Native, which can stream response bodies.
Parameters
input
RequestInfo | URL
init?
RequestInit
Returns
Promise<Response>
headers?
optionalheaders?:Record<string,string> |Headers
Defined in: react/src/hooks/useChat.ts:68
messages?
optionalmessages?:UIMessage<unknown,UIDataTypes,UITools>[]
Defined in: react/src/hooks/useChat.ts:73
Messages to show at first, such as a conversation stored by the app.
onApprovalRequest?
optionalonApprovalRequest?: (approval) =>void
Defined in: react/src/hooks/useChat.ts:52
Called once for each tool call that waits for the user (auto-approved ones excepted).
Parameters
approval
Returns
void
Inherited from
CommonChatOptions.onApprovalRequest
onError?
optionalonError?: (error) =>void
Defined in: react/src/hooks/useChat.ts:50
Parameters
error
Error
Returns
void
Inherited from
CommonChatOptions.onError
sessionId
sessionId:
string
Defined in: react/src/hooks/useChat.ts:67
The conversation the route keeps; a new id starts a new chat.
shouldAskApproval?
optionalshouldAskApproval?: (toolName) =>boolean
Defined in: react/src/hooks/useChat.ts:57
Whether a gated tool asks the user. Return false to approve its calls without asking. Default: every gated tool asks.
Parameters
toolName
string
Returns
boolean
Inherited from
CommonChatOptions.shouldAskApproval
throttle?
optionalthrottle?:number
Defined in: react/src/hooks/useChat.ts:59
Throttle for message updates while streaming, in ms. Default: none.
Inherited from
CommonChatOptions.throttle