createAI

AI SDK RSC is currently experimental. We recommend using AI SDK UI for production. For guidance on migrating from RSC to UI, see our migration guide.

Creates a client-server context provider that can be used to wrap parts of your application tree to easily manage both UI and AI states of your application.

Import

import { createAI } from "@ai-sdk/rsc"

API Signature

Parameters

actions:

Record<string, Action>

initialAIState:

any

initialUIState:

any

onGetUIState:

() => UIState

onSetAIState:

(Event) => void
Event

state:

AIState

done:

boolean

Returns

It returns an <AI/> context provider.

Examples

Learn to manage AI and UI states in Next.js
Learn to persist and restore states UI/AI states in Next.js