Skip to main content

Interface: UseChatOptions<TResponse>

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

Configuration options for useChat hook

Type Parameters

TResponse

TResponse = string

Properties

chatBot?

optional chatBot?: Processable<string, TResponse>

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

Optional: Provide your own Processable (e.g., Pipeline) to use as chatBot


fetch?

optional fetch?: typeof fetch

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

Optional: Custom fetch implementation (e.g., expo/fetch for React Native streaming)


headers?

optional headers?: Record<string, string>

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

Optional: Extra headers to include in proxy requests (e.g., Authorization)


maxToolIterations?

optional maxToolIterations?: number

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

Maximum tool call iterations (default: 50)


model?

optional model?: string | ModelConfig | AISDKLanguageModel

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

Model to use (default: gpt-5.6-luna) - can be string or provider-specific model


onApprovalRequest?

optional onApprovalRequest?: (approval) => void

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

Callback when a tool requires approval before execution. Called for tools with requiresApproval: true. Return { approved: true } to allow, or { approved: false, reason: '...' } to deny.

Parameters

approval

PendingApproval

Returns

void


onError?

optional onError?: (error) => void

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

Error callback

Parameters

error

Error

Returns

void


onEvent?

optional onEvent?: (event, meta?) => void

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

Callback for every raw stream event. Called before segment reduction. Use for logging, analytics, custom side effects, or filtering tool sub-events (e.g. crew worker events).

Parameters

event

StreamEvent

meta?
agentId?

string

agentName?

string

Returns

void


proxyUrl?

optional proxyUrl?: string

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

Proxy URL for API requests (optional) - use this to avoid CORS errors in the browser


responseSchema?

optional responseSchema?: unknown

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

Schema for the assistant's response structure (optional) Can be a JSON Schema object or a Zod schema for type safety If not provided, defaults to simple text responses


sessionId?

optional sessionId?: string

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

Optional: Session ID for server-side persistence. Forwarded to the proxy via providerOptions.


shouldAskApproval?

optional shouldAskApproval?: (toolName) => boolean

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

Function to check if a tool should ask for approval. Return false to auto-approve, true to show approval UI. If not provided, all tools with requiresApproval will trigger onApprovalRequest.

Parameters

toolName

string

Returns

boolean


skills?

optional skills?: Skill[]

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

Skills available to the assistant — keyword-triggered instruction sheets that bundle their own tools. Emits skill_activated stream events when one shapes a turn (surfaced via onSkillActivated / the segment stream).


storage?

optional storage?: HistoryStorage

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

Optional: Provide custom storage for history persistence (e.g., SupabaseStorage). Defaults to in-memory.


systemPrompt?

optional systemPrompt?: string

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

System prompt for the assistant


tools?

optional tools?: Record<string, ZodToolDefinition<ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>, unknown> | ToolDefinition<(...args) => unknown>>

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

Tools available to the assistant