Skip to main content

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?​

optional credentials?: RequestCredentials

Defined in: react/src/hooks/useChat.ts:71


fetch?​

optional fetch?: (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?​

optional headers?: Record<string, string> | Headers

Defined in: react/src/hooks/useChat.ts:68


messages?​

optional messages?: 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?​

optional onApprovalRequest?: (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​

PendingApproval

Returns​

void

Inherited from​

CommonChatOptions.onApprovalRequest


onError?​

optional onError?: (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?​

optional shouldAskApproval?: (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?​

optional throttle?: number

Defined in: react/src/hooks/useChat.ts:59

Throttle for message updates while streaming, in ms. Default: none.

Inherited from​

CommonChatOptions.throttle