Skip to content

UseChatOptions

Defined in: types.ts:137

Chat hook options.

Supports two modes:

  1. HTTP Mode (default): Uses api endpoint with fetch
  2. Direct Mode: Uses direct.backend with wrapper-ir for direct backend access

optional api: string

Defined in: types.ts:150

API endpoint for chat


optional body: Record<string, unknown>

Defined in: types.ts:154

Request body extras


optional direct: DirectModeOptions

Defined in: types.ts:168

Direct backend mode configuration. When provided, bypasses HTTP and uses the backend adapter directly.


optional generateId: () => string

Defined in: types.ts:175

Generate unique message IDs

string


optional headers: Record<string, string>

Defined in: types.ts:152

Request headers


optional id: string

Defined in: types.ts:143

Chat ID for persistence


optional initialInput: string

Defined in: types.ts:141

Initial input value


optional initialMessages: Message[]

Defined in: types.ts:139

Initial messages


optional keepLastMessageOnError: boolean

Defined in: types.ts:181

Keep last message on error


optional maxToolRoundtrips: number

Defined in: types.ts:183

Max number of automatic tool retries


optional onError: (error) => void

Defined in: types.ts:179

Called on error

Error

void


optional onFinish: (message) => void

Defined in: types.ts:177

Called when response stream finishes

Message

void


optional onResponse: (response) => void

Defined in: types.ts:158

Called for each response chunk (HTTP mode only)

Response

void


optional sendExtraMessageFields: boolean

Defined in: types.ts:185

Send extra message fields


optional streamProtocol: "text" | "data"

Defined in: types.ts:156

Stream protocol