API Reference
Overview

API Reference

Complete reference for every export in the react-ai-stream packages.


useAIChat

The core React hook. Manages messages, streaming state, and abort.

import { useAIChat } from '@react-ai-stream/react'
 
const { messages, sendMessage, loading, stop, error, clearMessages } = useAIChat({
  endpoint: '/api/chat',
})

Full reference


createAIClient

Creates a reusable client you can share across multiple hook instances via AIChatProvider.

import { createAIClient } from '@react-ai-stream/core'
import { AIChatProvider } from '@react-ai-stream/react'
 
const client = createAIClient({ endpoint: '/api/chat' })
 
export function App() {
  return (
    <AIChatProvider client={client}>
      <MyApp />
    </AIChatProvider>
  )
}

Full reference


Types

All TypeScript types exported from @react-ai-stream/core: Message, Role, StreamChunk, AIClient, AIProvider, and option interfaces.

import type {
  Message,
  UseAIChatOptions,
  UseAIChatReturn,
  AIClient,
} from '@react-ai-stream/core'

Full reference