Skip to main content

Function: useChat()

@baleybots/react

React hooks for Baleybots - Build AI-powered applications with ease

Example

import { useChat, useBaleybot } from '@baleybots/react';

// Chat hook
const { segments, sendStreaming } = useChat({
model: openai('gpt-5.6-luna'),
});

// Structured output hook
const { process, results, streamingText } = useBaleybot({
name: 'analyzer',
analysisGoal: 'Analyze text',
outputSchema: { ... }
});

// Single item
const result = await process("analyze this");

// Multiple items
for await (const result of process(["item1", "item2"])) {
console.log(result);
}

Call Signature

useChat<TSchema>(options): UseChatReturn<InferSchemaOutput<TSchema>>

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

Type Parameters

TSchema

TSchema extends object

Parameters

options

UseChatOptions<InferSchemaOutput<TSchema>> & object

Returns

UseChatReturn<InferSchemaOutput<TSchema>>

Call Signature

useChat<TResponse>(options): UseChatReturn<TResponse>

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

Type Parameters

TResponse

TResponse = string

Parameters

options

UseChatOptions<TResponse>

Returns

UseChatReturn<TResponse>